]> code.delx.au - gnu-emacs/blob - man/tramp.texi
*** empty log message ***
[gnu-emacs] / man / tramp.texi
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename ../info/tramp
4 @settitle TRAMP User Manual
5 @setchapternewpage odd
6 @c %**end of header
7
8 @c This is *so* much nicer :)
9 @footnotestyle end
10
11 @c In the Tramp CVS, the version number is auto-frobbed from
12 @c configure.ac, so you should edit that file and run
13 @c "autoconf && ./configure" to change the version number.
14
15 @c Additionally, flags are set with respect to the Emacs flavor; and
16 @c depending whether Tramp is packaged into (X)Emacs, or standalone.
17
18 @include trampver.texi
19
20 @c Macro to make formatting of the tramp program name consistent.
21 @macro tramp
22 @sc{tramp}
23 @end macro
24
25 @c Macros for formatting a filename.
26 @c trampfn is for a full filename, trampfnmhp means method, host, localname
27 @c were given, and so on.
28 @macro trampfn(method, user, host, localname)
29 @value{tramp-prefix}@value{method}@value{user}@@@value{host}@value{tramp-postfix}@value{localname}
30 @end macro
31
32 @copying
33 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003 Free Software
34 Foundation, Inc.
35
36 @quotation
37 Permission is granted to copy, distribute and/or modify this document
38 under the terms of the GNU Free Documentation License, Version 1.1 or
39 any later version published by the Free Software Foundation; with no
40 Invariant Sections, with the Front-Cover texts being ``A GNU
41 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
42 license is included in the section entitled ``GNU Free Documentation
43 License'' in the Emacs manual.
44
45 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
46 this GNU Manual, like GNU software. Copies published by the Free
47 Software Foundation raise funds for GNU development.''
48
49 This document is part of a collection distributed under the GNU Free
50 Documentation License. If you want to distribute this document
51 separately from the collection, you can do so by adding a copy of the
52 license to the document, as described in section 6 of the license.
53 @end quotation
54 @end copying
55
56 @c Entries for @command{install-info} to use
57 @dircategory Emacs
58 @direntry
59 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
60 Emacs remote file access via rsh and rcp.
61 @end direntry
62
63 @tex
64
65 @titlepage
66 @title @tramp{} version @trampver{} User Manual
67
68 @author by Daniel Pittman
69 @author based on documentation by Kai Gro@ss{}johann
70
71 @page
72 @insertcopying
73
74 @end titlepage
75 @page
76
77 @end tex
78
79 @ifnottex
80 @node Top, Overview, (dir), (dir)
81 @top @tramp{} version @trampver{} User Manual
82
83 This file documents @tramp{} version @trampver{}, a remote file
84 editing package for @value{emacs-name}.
85
86 @tramp{} stands for `Transparent Remote (file) Access, Multiple
87 Protocol'. This package provides remote file editing, similar to
88 @value{ftp-package-name}.
89
90 The difference is that @value{ftp-package-name} uses FTP to transfer
91 files between the local and the remote host, whereas @tramp{} uses a
92 combination of @command{rsh} and @command{rcp} or other work-alike
93 programs, such as @command{ssh}/@command{scp}.
94
95 You can find the latest version of this document on the web at
96 @uref{http://www.freesoftware.fsf.org/tramp/}.
97
98 @c Pointer to the other Emacs flavor is necessary only in case of
99 @c standalone installation. Text taken from trampinst.texi.
100 @ifset tramp-inst
101 @otherflavor{}
102 @end ifset
103
104 @ifhtml
105 This manual is also available as a @uref{tramp_ja.html, Japanese
106 translation}.
107
108 The latest release of @tramp{} is available for
109 @uref{http://savannah.gnu.org/download/tramp/,
110 download}, or you may see @ref{Obtaining @tramp{}} for more details,
111 including the CVS server details.
112
113 @tramp{} also has a @uref{https://savannah.gnu.org/projects/tramp/,
114 Savannah Project Page}.
115 @end ifhtml
116
117 There is a mailing list for @tramp{}, available at
118 @email{tramp-devel@@mail.freesoftware.fsf.org}, and archived at
119 @uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/} as
120 well as the usual Savannah archives.
121
122 @insertcopying
123
124 @end ifnottex
125
126 @menu
127 * Overview:: What @tramp{} can and cannot do.
128
129 For the end user:
130
131 * Obtaining @tramp{}:: How to obtain @tramp{}.
132 * History:: History of @tramp{}.
133 @ifset tramp-inst
134 * Installation:: Installing @tramp{} with your @value{emacs-name}.
135 @end ifset
136 * Configuration:: Configuring @tramp{} for use.
137 * Usage:: An overview of the operation of @tramp{}.
138 * Bug Reports:: Reporting Bugs and Problems.
139 * Frequently Asked Questions:: Questions and answers from the mailing list.
140 * Concept Index:: An item for each concept
141
142 For the developer:
143
144 * Version Control:: The inner workings of remote version control.
145 * Files directories and localnames:: How file names, directories and localnames are mangled and managed.
146 * Issues:: Debatable Issues and What Was Decided.
147
148 @detailmenu
149 --- The Detailed Node Listing ---
150 @c
151 @ifset tramp-inst
152 Installing @tramp{} with your @value{emacs-name}
153
154 * Installation parameters:: Parameters in order to control installation.
155 * Load paths:: How to plug-in @tramp{} into your environment.
156
157 @end ifset
158
159 Configuring @tramp{} for use
160
161 * Connection types:: Types of connections made to remote machines.
162 * Inline methods:: Inline methods.
163 * External transfer methods:: External transfer methods.
164 * Multi-hop Methods:: Connecting to a remote host using multiple hops.
165 * Default Method:: Selecting a default method.
166 * Customizing Methods:: Using Non-Standard Methods.
167 * Customizing Completion:: Selecting config files for user/host name completion.
168 * Remote Programs:: How @tramp{} finds and uses programs on the remote machine.
169 * Remote shell setup:: Remote shell setup hints.
170 * Windows setup hints:: Issues with Cygwin ssh.
171 * Auto-save and Backup:: Auto-save and Backup.
172
173 Using @tramp
174
175 * Filename Syntax:: @tramp{} filename conventions.
176 * Multi-hop filename syntax:: Multi-hop filename conventions.
177 * Filename completion:: Filename completion.
178 * Dired:: Dired.
179
180 The inner workings of remote version control
181
182 * Version Controlled Files:: Determining if a file is under version control.
183 * Remote Commands:: Executing the version control commands on the remote machine.
184 * Changed workfiles:: Detecting if the working file has changed.
185 * Checking out files:: Bringing the workfile out of the repository.
186 * Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
187
188 Things related to Version Control that don't fit elsewhere
189
190 * Remote File Ownership:: How VC determines who owns a workfile.
191 * Back-end Versions:: How VC determines what release your RCS is.
192
193 How file names, directories and localnames are mangled and managed
194
195 * Localname deconstruction:: Breaking a localname into its components.
196
197 @end detailmenu
198 @end menu
199
200 @node Overview
201 @chapter An overview of @tramp
202 @cindex overview
203
204 After the installation of @tramp{} into your @value{emacs-name}, you
205 will be able to access files on remote machines as though they were
206 local. Access to the remote file system for editing files, version
207 control, and @command{dired} are transparently enabled.
208
209 Your access to the remote machine can be with the @command{rsh},
210 @command{rlogin}, @command{telnet} programs or with any similar
211 connection method. This connection must pass ASCII successfully to be
212 usable but need not be 8-bit clean.
213
214 The package provides support for @command{ssh} connections out of the
215 box, one of the more common uses of the package. This allows
216 relatively secure access to machines, especially if @command{ftp}
217 access is disabled.
218
219 The majority of activity carried out by @tramp{} requires only that
220 the remote login is possible and is carried out at the terminal. In
221 order to access remote files @tramp{} needs to transfer their content
222 to the local machine temporarily.
223
224 @tramp{} can transfer files between the machines in a variety of ways.
225 The details are easy to select, depending on your needs and the
226 machines in question.
227
228 The fastest transfer methods (for large files) rely on a remote file
229 transfer package such as @command{rcp}, @command{scp} or
230 @command{rsync}. The use of these methods is only possible if the
231 file copy command does not ask for a password for the remote machine.
232
233 If the remote copy methods are not suitable for you, @tramp{} also
234 supports the use of encoded transfers directly through the shell.
235 This requires that the @command{mimencode} or @command{uuencode} tools
236 are available on the remote machine. These methods are generally
237 faster for small files.
238
239 Within these limitations, @tramp{} is quite powerful. It is worth
240 noting that, as of the time of writing, it is far from a polished
241 end-user product. For a while yet you should expect to run into rough
242 edges and problems with the code now and then.
243
244 It is finished enough that the developers use it for day to day work but
245 the installation and setup can be a little difficult to master, as can
246 the terminology.
247
248 @tramp{} is still under active development and any problems you encounter,
249 trivial or major, should be reported to the @tramp{} developers.
250 @xref{Bug Reports}.
251
252
253 @subsubheading Behind the scenes
254 @cindex behind the scenes
255 @cindex details of operation
256 @cindex how it works
257
258 This section tries to explain what goes on behind the scenes when you
259 access a remote file through @tramp{}.
260
261 Suppose you type @kbd{C-x C-f} and enter part of an @tramp{} file name,
262 then hit @kbd{@key{TAB}} for completion. Suppose further that this is
263 the first time that @tramp{} is invoked for the host in question. Here's
264 what happens:
265
266 @itemize
267 @item
268 @tramp{} discovers that it needs a connection to the host. So it
269 invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
270 @var{user}} or a similar tool to connect to the remote host.
271 Communication with this process happens through an
272 @value{emacs-name} buffer, that is, the output from the remote end
273 goes into a buffer.
274
275 @item
276 The remote host may prompt for a login name (for @command{telnet}). The
277 login name is given in the file name, so @tramp{} sends the login name and
278 a newline.
279
280 @item
281 The remote host may prompt for a password or pass phrase (for
282 @command{rsh} or for @command{telnet} after sending the login name).
283 @tramp{} displays the prompt in the minibuffer, asking you for the
284 password or pass phrase.
285
286 You enter the password or pass phrase. @tramp{} sends it to the remote
287 host, followed by a newline.
288
289 @item
290 @tramp{} now waits for the shell prompt or for a message that the login
291 failed.
292
293 If @tramp{} sees neither of them after a certain period of time (a minute,
294 say), then it issues an error message saying that it couldn't find the
295 remote shell prompt and shows you what the remote host has sent.
296
297 If @tramp{} sees a @samp{login failed} message, it tells you so,
298 aborts the login attempt and allows you to try again.
299
300 @item
301 Suppose that the login was successful and @tramp{} sees the shell prompt
302 from the remote host. Now @tramp{} invokes @command{/bin/sh} because
303 Bourne shells and C shells have different command
304 syntaxes.@footnote{Invoking @command{/bin/sh} will fail if your login
305 shell doesn't recognize @samp{exec /bin/sh} as a valid command.
306 Maybe you use the Scheme shell @command{scsh}@dots{}}
307
308 After the Bourne shell has come up, @tramp{} sends a few commands to
309 ensure a good working environment. It turns off echoing, it sets the
310 shell prompt, and a few other things.
311
312 @item
313 Now the remote shell is up and it good working order. Remember, what
314 was supposed to happen is that @tramp{} tries to find out what files exist
315 on the remote host so that it can do filename completion.
316
317 So, @tramp{} basically issues @command{cd} and @command{ls} commands and
318 also sometimes @command{echo} with globbing. Another command that is
319 often used is @command{test} to find out whether a file is writable or a
320 directory or the like. The output of each command is parsed for the
321 necessary operation.
322
323 @item
324 Suppose you are finished with filename completion, have entered @kbd{C-x
325 C-f}, a full file name and hit @kbd{@key{RET}}. Now comes the time to
326 transfer the file contents from the remote host to the local host so
327 that you can edit them.
328
329 See above for an explanation of how @tramp{} transfers the file contents.
330
331 For inline transfers, @tramp{} issues a command like @samp{mimencode -b
332 /path/to/remote/file}, waits until the output has accumulated in the
333 buffer that's used for communication, then decodes that output to
334 produce the file contents.
335
336 For out-of-band transfers, @tramp{} issues a command like the following:
337 @example
338 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
339 @end example
340 It then reads the local temporary file @file{/tmp/tramp.4711} into a
341 buffer and deletes the temporary file.
342
343 @item
344 You now edit the buffer contents, blithely unaware of what has happened
345 behind the scenes. (Unless you have read this section, that is.) When
346 you are finished, you type @kbd{C-x C-s} to save the buffer.
347
348 @item
349 Again, @tramp{} transfers the file contents to the remote host either
350 inline or out-of-band. This is the reverse of what happens when reading
351 the file.
352
353 @end itemize
354
355 I hope this has provided you with a basic overview of what happens
356 behind the scenes when you open a file with @tramp{}.
357
358
359 @c For the end user
360 @node Obtaining @tramp{}
361 @chapter Obtaining @tramp{}.
362 @cindex obtaining Tramp
363
364 @tramp{} is freely available on the Internet and the latest release
365 may be downloaded from
366 @uref{http://savannah.nongnu.org/download/tramp/}. This
367 release includes the full documentation and code for @tramp{},
368 suitable for installation. But Emacs (21.4 or later) includes
369 @tramp{} already, and there is a @tramp{} package for XEmacs, as well.
370 So maybe it is easier to just use those. But if you want the bleeding
371 edge, read on@dots{...}
372
373 For the especially brave, @tramp{} is available from CVS. The CVS
374 version is the latest version of the code and may contain incomplete
375 features or new issues. Use these versions at your own risk.
376
377 Instructions for obtaining the latest development version of @tramp{}
378 from CVS can be found by going to the Savannah project page at the
379 following URL and then clicking on the CVS link in the navigation bar
380 at the top.
381
382 @noindent
383 @uref{http://savannah.gnu.org/projects/tramp/}
384
385 @noindent
386 Or follow the example session below:
387
388 @example
389 ] @strong{cd ~/@value{emacs-dir}}
390 ] @strong{cvs -d:pserver:anoncvs@@subversions.gnu.org:/cvsroot/tramp login}
391
392 (Logging in to anoncvs@@subversions.gnu.org)
393 CVS password: @strong{(just hit RET here)}
394 @dots{}
395
396 ] @strong{cvs -z3 -d:pserver:anoncvs@@subversions.gnu.org:/cvsroot/tramp co tramp}
397 @end example
398
399 @noindent
400 You should now have a directory @file{~/@value{emacs-dir}/tramp}
401 containing the latest version of @tramp{}. You can fetch the latest
402 updates from the repository by issuing the command:
403
404 @example
405 ] @strong{cd ~/@value{emacs-dir}/tramp}
406 ] @strong{cvs update -d}
407 @end example
408
409 @noindent
410 Once you've got updated files from the CVS repository, you need to run
411 @command{autoconf} in order to get an up-to-date @file{configure}
412 script:
413
414 @example
415 ] @strong{cd ~/@value{emacs-dir}/tramp}
416 ] @strong{autoconf}
417 @end example
418
419
420 @node History
421 @chapter History of @tramp{}
422 @cindex history
423 @cindex development history
424
425 Development was started end of November 1998. The package was called
426 @file{rssh.el}, back then. It only provided one method to access a
427 file, using @command{ssh} to log in to a remote host and using
428 @command{scp} to transfer the file contents. After a while, the name
429 was changed to @file{rcp.el}, and now it's @tramp{}. Along the way,
430 many more methods for getting a remote shell and for transferring the
431 file contents were added. Support for VC was added.
432
433 The most recent addition of major features were the multi-hop methods
434 added in April 2000 and the unification of @tramp{} and Ange-FTP
435 filenames in July 2002.
436
437 @c Installation chapter is necessary only in case of standalone
438 @c installation. Text taken from trampinst.texi.
439 @ifset tramp-inst
440 @installationchapter{}
441 @end ifset
442
443 @node Configuration
444 @chapter Configuring @tramp{} for use
445 @cindex configuration
446
447 @cindex default configuration
448 @tramp{} is (normally) fully functional when it is initially
449 installed. It is initially configured to use the @command{ssh} program
450 to connect to the remote host and to use base-64 encoding (on the
451 remote host, via @command{mimencode}, and on the local host via the
452 built-in support for base-64 encoding in Emacs).
453
454 On some hosts, there are problems with opening a connection. These are
455 related to the behavior of the remote shell. See @xref{Remote shell
456 setup}, for details on this.
457
458 If you do not wish to use these commands to connect to the remote
459 host, you should change the default connection and transfer method
460 that @tramp uses. There are several different methods that @tramp{}
461 can use to connect to remote machines and transfer files
462 (@pxref{Connection types}).
463
464
465 @menu
466 * Connection types:: Types of connections made to remote machines.
467 * Inline methods:: Inline methods.
468 * External transfer methods:: External transfer methods.
469 * Multi-hop Methods:: Connecting to a remote host using multiple hops.
470 * Default Method:: Selecting a default method.
471 * Customizing Methods:: Using Non-Standard Methods.
472 * Customizing Completion:: Selecting config files for user/host name completion.
473 * Remote Programs:: How @tramp{} finds and uses programs on the remote machine.
474 * Remote shell setup:: Remote shell setup hints.
475 * Windows setup hints:: Issues with Cygwin ssh.
476 * Auto-save and Backup:: Auto-save and Backup.
477 @end menu
478
479
480 @node Connection types
481 @section Types of connections made to remote machines.
482 @cindex connection types, overview
483
484 There are two basic types of transfer methods, each with its own
485 advantages and limitations. Both types of connection make use of a
486 remote shell access program such as @command{rsh}, @command{ssh} or
487 @command{telnet} to connect to the remote machine.
488
489 This connection is used to perform many of the operations that @tramp
490 requires to make the remote file system transparently accessible from
491 the local machine. It is only when visiting files that the methods
492 differ.
493
494 @cindex inline methods
495 @cindex external transfer methods
496 @cindex external methods
497 @cindex out-of-band methods
498 @cindex methods, inline
499 @cindex methods, external transfer
500 @cindex methods, out-of-band
501 Loading or saving a remote file requires that the content of the file
502 be transfered between the two machines. The content of the file can be
503 transfered over the same connection used to log in to the remote
504 machine or the file can be transfered through another connection using
505 a remote copy program such as @command{rcp}, @command{scp} or
506 @command{rsync}. The former are called @dfn{inline methods}, the
507 latter are called @dfn{out-of-band methods} or @dfn{external transfer
508 methods} (@dfn{external methods} for short).
509
510 The performance of the external transfer methods is generally better
511 than that of the inline methods, at least for large files. This is
512 caused by the need to encode and decode the data when transferring
513 inline.
514
515 The one exception to this rule are the @command{scp} based transfer
516 methods. While these methods do see better performance when actually
517 transferring files, the overhead of the cryptographic negotiation at
518 startup may drown out the improvement in file transfer times.
519
520 External transfer methods do require that the remote copy command is not
521 interactive --- that is, the command does not prompt you for a password.
522 If you cannot perform remote copies without a password, you will need to
523 use an inline transfer method to work with @tramp{}.
524
525 @cindex multi-hop methods
526 @cindex methods, multi-hop
527 A variant of the inline methods are the @dfn{multi-hop methods}.
528 These methods allow you to connect a remote host using a number `hops',
529 each of which connects to a different host. This is useful if you are
530 in a secured network where you need to go through a bastion host to
531 connect to the outside world.
532
533
534 @node Inline methods
535 @section Inline methods
536 @cindex inline methods
537 @cindex methods, inline
538
539 The inline methods in @tramp{} are quite powerful and can work in
540 situations where you cannot use an external transfer program to connect.
541 Inline methods are the only methods that work when connecting to the
542 remote machine via telnet. (There are also strange inline methods which
543 allow you to transfer files between @emph{user identities} rather than
544 hosts, see below.)
545
546 These methods depend on the existence of a suitable encoding and
547 decoding command on remote machine. Locally, @tramp{} may be able to use
548 features of Emacs to decode and encode the files or it may require
549 access to external commands to perform that task.
550
551 @cindex uuencode
552 @cindex mimencode
553 @cindex base-64 encoding
554 @tramp{} checks the availability and usability of commands like
555 @command{mimencode} (part of the @command{metamail} package) or
556 @command{uuencode} on the remote host. The first reliable command
557 will be used. The search path can be customized, see @ref{Remote
558 Programs}.
559
560 If both commands aren't available on the remote host, @tramp{}
561 transfers a small piece of Perl code to the remote host, and tries to
562 apply it for encoding and decoding.
563
564
565 @table @asis
566 @item @option{rsh}
567 @cindex method rsh
568 @cindex rsh method
569
570 Connect to the remote host with @command{rsh}. Due to the unsecure
571 connection it is recommended for very local host topology only.
572
573 On operating systems which provide the command @command{remsh} instead
574 of @command{rsh}, you can use the method @option{remsh}. This is true
575 for HP-UX or Cray UNICOS, for example.
576
577
578 @item @option{ssh}
579 @cindex method ssh
580 @cindex ssh method
581
582 Connect to the remote host with @command{ssh}. This is identical to
583 the previous option except that the @command{ssh} package is used,
584 making the connection more secure.
585
586 There are also two variants, @option{ssh1} and @option{ssh2}, that
587 call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
588 explicitly select whether you want to use the SSH protocol version 1
589 or 2 to connect to the remote host. (You can also specify in
590 @file{~/.ssh/config}, the SSH configuration file, which protocol
591 should be used, and use the regular @option{ssh} method.)
592
593 Two other variants, @option{ssh1_old} and @option{ssh2_old}, use the
594 @command{ssh1} and @command{ssh2} commands explicitly. If you don't
595 know what these are, you do not need these options.
596
597 All the methods based on @command{ssh} have an additional kludgy
598 feature: you can specify a host name which looks like @file{host#42}
599 (the real host name, then a hash sign, then a port number). This
600 means to connect to the given host but to also pass @code{-p 42} as
601 arguments to the @command{ssh} command.
602
603
604 @item @option{telnet}
605 @cindex method telnet
606 @cindex telnet method
607
608 Connect to the remote host with @command{telnet}. This is as unsecure
609 as the @option{rsh} method.
610
611
612 @item @option{su}
613 @cindex method su
614 @cindex su method
615
616 This method does not connect to a remote host at all, rather it uses
617 the @command{su} program to allow you to edit files as another user.
618
619
620 @item @option{sudo}
621 @cindex method sudo
622 @cindex sudo method
623
624 This is similar to the @option{su} method, but it uses @command{sudo}
625 rather than @command{su} to become a different user.
626
627 Note that @command{sudo} must be configured to allow you to start a
628 shell as the user. It would be nice if it was sufficient if
629 @command{ls} and @command{mimencode} were allowed, but that is not
630 easy to implement, so I haven't got around to it, yet.
631
632
633 @item @option{sshx}
634 @cindex method sshx
635 @cindex sshx method
636 @cindex Cygwin (with sshx method)
637
638 As you expect, this is similar to @option{ssh}, only a little
639 different. Whereas @option{ssh} opens a normal interactive shell on
640 the remote host, this option uses @samp{ssh -t -t @var{host} -l
641 @var{user} /bin/sh} to open a connection. This is useful for users
642 where the normal login shell is set up to ask them a number of
643 questions when logging in. This procedure avoids these questions, and
644 just gives @tramp{} a more-or-less `standard' login shell to work
645 with.
646
647 Note that this procedure does not eliminate questions asked by
648 @command{ssh} itself. For example, @command{ssh} might ask ``Are you
649 sure you want to continue connecting?'' if the host key of the remote
650 host is not known. @tramp{} does not know how to deal with such a
651 question (yet), therefore you will need to make sure that you can log
652 in without such questions.
653
654 This is also useful for Windows users where @command{ssh}, when
655 invoked from an Emacs buffer, tells them that it is not allocating a
656 pseudo tty. When this happens, the login shell is wont to not print
657 any shell prompt, which confuses @tramp{} mightily. For reasons
658 unknown, some Windows ports for @command{ssh} (maybe the Cygwin one)
659 require the doubled @samp{-t} option.
660
661 This supports the @samp{-p} kludge.
662
663
664 @item @option{krlogin}
665 @cindex method krlogin
666 @cindex km krlogin
667 @cindex Kerberos (with krlogin method)
668
669 This method is also similar to @option{ssh}. It only uses the
670 @command{krlogin -x} command to log in to the remote host.
671
672
673 @item @option{plink}
674 @cindex method plink
675 @cindex plink method
676
677 This method is mostly interesting for Windows users using the PuTTY
678 implementation of SSH. It uses @samp{plink -ssh} to log in to the
679 remote host.
680
681 Additionally, the method @option{plink1} is provided, which calls
682 @samp{plink -1 -ssh} in order to use SSH protocol version 1
683 explicitely.
684
685 CCC: Do we have to connect to the remote host once from the command
686 line to accept the SSH key? Maybe this can be made automatic?
687
688 CCC: Does @command{plink} support the @samp{-p} option? @tramp{} will
689 support that, anyway.
690
691 @end table
692
693
694
695 @node External transfer methods
696 @section External transfer methods
697 @cindex methods, external transfer
698 @cindex methods, out-of-band
699 @cindex external transfer methods
700 @cindex out-of-band methods
701
702 The external transfer methods operate through multiple channels, using
703 the remote shell connection for many actions while delegating file
704 transfers to an external transfer utility.
705
706 This saves the overhead of encoding and decoding that multiplexing the
707 transfer through the one connection has with the inline methods.
708
709 If you want to use an external transfer method you @emph{must} be able
710 to execute the transfer utility to copy files to and from the remote
711 machine without any interaction.
712
713 @cindex ssh-agent
714 This means that you will need to use @command{ssh-agent} if you use the
715 @command{scp} program for transfers, or maybe your version of
716 @command{scp} accepts a password on the command line.@footnote{PuTTY's
717 @command{pscp} allows you to specify the password on the command line.}
718 If you use @command{rsync} via @command{ssh} then the same rule must
719 apply to that connection.
720
721 If you cannot get @command{scp} to run without asking for a password but
722 would still like to use @command{ssh} to secure your connection, have a
723 look at the @command{ssh} based inline methods.
724
725
726 @table @asis
727 @item @option{rcp} --- @command{rsh} and @command{rcp}
728 @cindex method rcp
729 @cindex rcp method
730 @cindex rcp (with rcp method)
731 @cindex rsh (with rcp method)
732
733 This method uses the @command{rsh} and @command{rcp} commands to connect
734 to the remote machine and transfer files. This is probably the fastest
735 connection method available.
736
737 The alternative method @option{remcp} uses the @command{remsh} and
738 @command{rcp} commands. It should be applied on machines where
739 @command{remsh} is used instead of @command{rsh}.
740
741
742 @item @option{scp} --- @command{ssh} and @command{scp}
743 @cindex method scp
744 @cindex scp method
745 @cindex scp (with scp method)
746 @cindex ssh (with scp method)
747
748 Using @command{ssh} to connect to the remote host and @command{scp} to
749 transfer files between the machines is the best method for securely
750 connecting to a remote machine and accessing files.
751
752 The performance of this option is also quite good. It may be slower than
753 the inline methods when you often open and close small files however.
754 The cost of the cryptographic handshake at the start of an @command{scp}
755 session can begin to absorb the advantage that the lack of encoding and
756 decoding presents.
757
758 There are also two variants, @option{scp1} and @option{scp2}, that
759 call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
760 explicitly select whether you want to use the SSH protocol version 1
761 or 2 to connect to the remote host. (You can also specify in
762 @file{~/.ssh/config}, the SSH configuration file, which protocol
763 should be used, and use the regular @option{ssh} method.)
764
765 Two other variants, @option{scp1_old} and @option{scp2_old}, use the
766 @command{ssh1} and @command{ssh2} commands explicitly. If you don't
767 know what these are, you do not need these options.
768
769 All the @command{ssh} based methods support the kludgy @samp{-p}
770 feature where you can specify a port number to connect to in the host
771 name. For example, the host name @file{host#42} tells @tramp{} to
772 specify @samp{-p 42} in the argument list for @command{ssh}.
773
774
775 @item @option{rsync} --- @command{ssh} and @command{rsync}
776 @cindex method rsync
777 @cindex rsync method
778 @cindex rsync (with rsync method)
779 @cindex ssh (with rsync method)
780
781 Using the @command{ssh} command to connect securely to the remote
782 machine and the @command{rsync} command to transfer files is almost
783 identical to the @option{scp} method.
784
785 While @command{rsync} performs much better than @command{scp} when
786 transferring files that exist on both hosts, this advantage is lost if
787 the file exists only on one side of the connection.
788
789 The @command{rsync} based method may be considerably faster than the
790 @command{rcp} based methods when writing to the remote system. Reading
791 files to the local machine is no faster than with a direct copy.
792
793 This method supports the @samp{-p} hack.
794
795
796 @item @option{scpx} --- @command{ssh} and @command{scp}
797 @cindex method scpx
798 @cindex scpx method
799 @cindex scp (with scpx method)
800 @cindex ssh (with scpx method)
801 @cindex Cygwin (with scpx method)
802
803 As you expect, this is similar to @option{scp}, only a little
804 different. Whereas @option{scp} opens a normal interactive shell on
805 the remote host, this option uses @samp{ssh -t -t @var{host} -l
806 @var{user} /bin/sh} to open a connection. This is useful for users
807 where the normal login shell is set up to ask them a number of
808 questions when logging in. This procedure avoids these questions, and
809 just gives @tramp{} a more-or-less `standard' login shell to work
810 with.
811
812 This is also useful for Windows users where @command{ssh}, when
813 invoked from an Emacs buffer, tells them that it is not allocating a
814 pseudo tty. When this happens, the login shell is wont to not print
815 any shell prompt, which confuses @tramp{} mightily. Maybe this
816 applies to the Cygwin port of SSH.
817
818 This method supports the @samp{-p} hack.
819
820
821 @item @option{pscp} --- @command{plink} and @command{pscp}
822 @cindex method pscp
823 @cindex pscp method
824 @cindex pscp (with pscp method)
825 @cindex plink (with pscp method)
826 @cindex PuTTY (with pscp method)
827
828 This method is similar to @option{scp}, but it uses the
829 @command{plink} command to connect to the remote host, and it uses
830 @command{pscp} for transferring the files. These programs are part
831 of PuTTY, an SSH implementation for Windows.
832
833 CCC: Does @command{plink} support the @samp{-p} hack?
834
835
836 @item @option{fcp} --- @command{fsh} and @command{fcp}
837 @cindex method fcp
838 @cindex fcp method
839 @cindex fsh (with fcp method)
840 @cindex fcp (with fcp method)
841
842 This method is similar to @option{scp}, but it uses the @command{fsh}
843 command to connect to the remote host, and it uses @command{fcp} for
844 transferring the files. @command{fsh/fcp} are a front-end for
845 @command{ssh} which allow for reusing the same @command{ssh} session
846 for submitting several commands. This avoids the startup overhead of
847 @command{scp} (which has to establish a secure connection whenever it
848 is called). Note, however, that you can also use one of the inline
849 methods to achieve a similar effect.
850
851 This method uses the command @samp{fsh @var{host} -l @var{user}
852 /bin/sh -i} to establish the connection, it does not work to just say
853 @command{fsh @var{host} -l @var{user}}.
854
855 @cindex method fsh
856 @cindex fsh method
857 There is no inline method using @command{fsh} as the multiplexing
858 provided by the program is not very useful in our context. @tramp{}
859 opens just one connection to the remote host and then keeps it open,
860 anyway.
861
862
863 @ifset emacs
864 @item @option{ftp}
865 @cindex method ftp
866 @cindex ftp method
867
868 This is not a native @tramp{} method. Instead of, it forwards all
869 requests to @value{ftp-package-name}.
870 @end ifset
871
872
873 @item @option{smb} --- @command{smbclient}
874 @cindex method smb
875 @cindex smb method
876
877 This is another not natural @tramp{} method. It uses the
878 @command{smbclient} command on different Unices in order to connect to
879 an SMB server. An SMB server might be a Samba (or CIFS) server on
880 another UNIX host or, more interesting, a host running MS Windows. So
881 far, it is tested towards MS Windows NT, MS Windows 2000, and MS
882 Windows XP.
883
884 The first directory in the localname must be a share name on the remote
885 host. Remember, that the @code{$} character in which default shares
886 usually end, must be written @code{$$} due to environment variable
887 substitution in file names. If no share name is given (i.e. remote
888 directory @code{/}), all available shares are listed.
889
890 Since authorization is done on share level, you will be prompted
891 always for a password if you access another share on the same host.
892 Due to security reasons, the password is not cached.
893
894 MS Windows uses for authorization both a user name and a domain name.
895 Because of this, the @tramp{} syntax has been extended: you can
896 specify a user name which looks like @code{user%domain} (the real user
897 name, then a percent sign, then the domain name). So, to connect to
898 the machine @code{melancholia} as user @code{daniel} of the domain
899 @code{BIZARRE}, and edit @file{.emacs} in the home directory (share
900 @code{daniel$}) I would specify the filename
901 @file{@value{tramp-prefix}smb@value{tramp-postfix-single-hop}daniel%BIZARRE@@melancholia@value{tramp-postfix}/daniel$$/.emacs}.
902
903 The domain name as well as the user name are optional. If no user
904 name is specified at all, the anonymous user (without password
905 prompting) is assumed. This is different from all other @tramp{}
906 methods, where in such a case the local user name is taken.
907
908 The @option{smb} method supports the @samp{-p} hack.
909
910 @strong{Please note:} If Emacs runs locally under MS Windows, this
911 method isn't available. Instead of, you can use UNC file names like
912 @file{//melancholia/daniel$$/.emacs}. The only disadvantage is that
913 there's no possibility to specify another user name.
914
915 @end table
916
917 @node Multi-hop Methods
918 @section Connecting to a remote host using multiple hops
919 @cindex multi-hop methods
920 @cindex methods, multi-hop
921
922 Sometimes, the methods described before are not sufficient. Sometimes,
923 it is not possible to connect to a remote host using a simple command.
924 For example, if you are in a secured network, you might have to log in
925 to a `bastion host' first before you can connect to the outside world.
926 Of course, the target host may also require a bastion host. The format
927 of multi-hop filenames is slightly different than the format of normal
928 @tramp{} methods.
929
930 @cindex method multi
931 @cindex multi method
932 A multi-hop file name specifies a method, a number of hops, and a
933 localname (path name on the remote system). The method name is always
934 @option{multi}.
935
936 Each hop consists of a @dfn{hop method} specification, a user name and
937 a host name. The hop method can be an inline method only. The
938 following hop methods are (currently) available:
939
940 @table @option
941 @item telnet
942 @cindex hop method telnet
943 @cindex telnet hop method
944
945 Uses the well-known @command{telnet} program to connect to the host.
946 Whereas user name and host name are supplied in the file name, the
947 user is queried for the password.
948
949 @item rsh
950 @cindex hop method rsh
951 @cindex rsh hop method
952
953 This uses @command{rsh} to connect to the host. You do not need to
954 enter a password unless @command{rsh} explicitly asks for it.
955
956 The variant @option{remsh} uses the @command{remsh} command. It
957 should be applied on machines where @command{remsh} is used instead of
958 @command{rsh}.
959
960 @item ssh
961 @cindex hop method ssh
962 @cindex ssh hop method
963
964 This uses @command{ssh} to connect to the host. You might have to enter
965 a password or a pass phrase.
966
967 @item su
968 @cindex hop method su
969 @cindex su hop method
970
971 This method does not actually contact a different host, but it allows
972 you to become a different user on the host you're currently on. This
973 might be useful if you want to edit files as root, but the remote host
974 does not allow remote root logins. In this case you can use
975 @option{telnet}, @option{rsh} or @option{ssh} to connect to the
976 remote host as a non-root user, then use an @option{su} hop to become
977 root. But @option{su} need not be the last hop in a sequence, you could
978 also use it somewhere in the middle, if the need arises.
979
980 Even though you @emph{must} specify both user and host with an
981 @option{su} hop, the host name is ignored and only the user name is
982 used.
983
984 @item sudo
985 @cindex hop method sudo
986 @cindex sudo hop method
987
988 This is similar to the @option{su} hop, except that it uses
989 @command{sudo} rather than @command{su} to become a different user.
990
991 @end table
992
993 Some people might wish to use port forwarding with @command{ssh} or
994 maybe they have to use a nonstandard port. This can be accomplished
995 by putting a stanza in @file{~/.ssh/config} for the account which
996 specifies a different port number for a certain host name. But it can
997 also be accomplished within @tramp{}, by adding a multi-hop method.
998 For example:
999
1000 @lisp
1001 (add-to-list
1002 'tramp-multi-connection-function-alist
1003 '("sshf" tramp-multi-connect-rlogin "ssh %h -l %u -p 4400%n"))
1004 @end lisp
1005
1006 Now you can use an @code{sshf} hop which connects to port 4400 instead of
1007 the standard port.
1008
1009
1010 @node Default Method
1011 @section Selecting a default method
1012 @cindex default method
1013
1014 @vindex tramp-default-method
1015 When you select an appropriate transfer method for your typical usage
1016 you should set the variable @var{tramp-default-method} to reflect that
1017 choice. This variable controls which method will be used when a method
1018 is not specified in the @tramp{} file name. For example:
1019
1020 @lisp
1021 (setq tramp-default-method "scp")
1022 @end lisp
1023
1024 @vindex tramp-default-method-alist
1025 You can also specify different methods for certain user/host
1026 combinations, via the variable @var{tramp-default-method-alist}. For
1027 example, the following two lines specify to use the @option{ssh}
1028 method for all user names matching @samp{john} and the @option{rsync}
1029 method for all host names matching @samp{lily}. The third line
1030 specifies to use the @option{su} method for the user @samp{root} on
1031 the machine @samp{localhost}.
1032
1033 @lisp
1034 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1035 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1036 (add-to-list 'tramp-default-method-alist
1037 '("\\`localhost\\'" "\\`root\\'" "su"))
1038 @end lisp
1039
1040 @noindent
1041 See the documentation for the variable
1042 @var{tramp-default-method-alist} for more details.
1043
1044 External transfer methods are normally preferable to inline transfer
1045 methods, giving better performance. They may not be useful if you use
1046 many remote machines where you cannot log in without a password.
1047
1048 @xref{Inline methods}.
1049 @xref{External transfer methods}.
1050 @xref{Multi-hop Methods}.
1051
1052 Another consideration with the selection of transfer methods is the
1053 environment you will use them in and, especially when used over the
1054 Internet, the security implications of your preferred method.
1055
1056 The @command{rsh} and @command{telnet} methods send your password as
1057 plain text as you log in to the remote machine, as well as transferring
1058 the files in such a way that the content can easily be read from other
1059 machines.
1060
1061 If you need to connect to remote systems that are accessible from the
1062 Internet, you should give serious thought to using @command{ssh} based
1063 methods to connect. These provide a much higher level of security,
1064 making it a non-trivial exercise for someone to obtain your password or
1065 read the content of the files you are editing.
1066
1067 @node Customizing Methods
1068 @section Using Non-Standard Methods
1069 @cindex customizing methods
1070 @cindex using non-standard methods
1071 @cindex create your own methods
1072
1073 There is a variable @code{tramp-methods} which you can change if the
1074 predefined methods don't seem right.
1075
1076 For the time being, I'll refer you to the Lisp documentation of that
1077 variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
1078
1079
1080 @node Customizing Completion
1081 @section Selecting config files for user/host name completion
1082 @cindex customizing completion
1083 @cindex selecting config files
1084 @vindex tramp-completion-function-alist
1085
1086 The variable @code{tramp-completion-function-alist} is intended to
1087 customize which files are taken into account for user and host name
1088 completion (@pxref{Filename completion}). For every method, it keeps
1089 a set of configuration files, accompanied by a Lisp function able to
1090 parse that file. Entries in @code{tramp-completion-function-alist}
1091 have the form (@var{method} @var{pair1} @var{pair2} ...).
1092
1093 Each @var{pair} is composed of (@var{function} @var{file}).
1094 @var{function} is responsible to extract user names and host names
1095 from @var{file} for completion. There are two functions which access
1096 this variable:
1097
1098 @defun tramp-get-completion-function method
1099 This function returns the list of completion functions for @var{method}.
1100
1101 Example:
1102 @example
1103 (tramp-get-completion-function "rsh")
1104
1105 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1106 (tramp-parse-rhosts "~/.rhosts"))
1107 @end example
1108 @end defun
1109
1110 @defun tramp-set-completion-function method function-list
1111 This function sets @var{function-list} as list of completion functions
1112 for @var{method}.
1113
1114 Example:
1115 @example
1116 (tramp-set-completion-function "ssh"
1117 '((tramp-parse-sconfig "/etc/ssh_config")
1118 (tramp-parse-sconfig "~/.ssh/config")))
1119
1120 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1121 (tramp-parse-sconfig "~/.ssh/config"))
1122 @end example
1123 @end defun
1124
1125 The following predefined functions parsing configuration files exist:
1126
1127 @table @asis
1128 @item @code{tramp-parse-rhosts}
1129 @findex tramp-parse-rhosts
1130
1131 This function parses files which are syntactical equivalent to
1132 @file{~/.rhosts}. It returns both host names and user names, if
1133 specified.
1134
1135 @item @code{tramp-parse-shosts}
1136 @findex tramp-parse-shosts
1137
1138 This function parses files which are syntactical equivalent to
1139 @file{~/.ssh/known_hosts}. Since there are no user names specified
1140 in such files, it can return host names only.
1141
1142 @item @code{tramp-parse-sconfig}
1143 @findex tramp-parse-shosts
1144
1145 This function returns the host nicknames defined by @code{Host} entries
1146 in @file{~/.ssh/config} style files.
1147
1148 @item @code{tramp-parse-hosts}
1149 @findex tramp-parse-hosts
1150
1151 A function dedicated to @file{/etc/hosts} style files. It returns
1152 host names only.
1153
1154 @item @code{tramp-parse-passwd}
1155 @findex tramp-parse-passwd
1156
1157 A function which parses @file{/etc/passwd} like files. Obviously, it
1158 can return user names only.
1159
1160 @item @code{tramp-parse-netrc}
1161 @findex tramp-parse-netrc
1162
1163 Finally, a function which parses @file{~/.netrc} like files.
1164 @end table
1165
1166 If you want to keep your own data in a file, with your own structure,
1167 you might provide such a function as well. This function must meet
1168 the following conventions:
1169
1170 @defun my-tramp-parse file
1171 @var{file} must be either a file name on your host, or @code{nil}. The
1172 function must return a list of (@var{user} @var{host}), which are
1173 taken as candidates for user and host name completion.
1174
1175 Example:
1176 @example
1177 (my-tramp-parse "~/.my-tramp-hosts")
1178
1179 @result{} ((nil "toto") ("daniel" "melancholia"))
1180 @end example
1181 @end defun
1182
1183
1184 @node Remote Programs
1185 @section How @tramp{} finds and uses programs on the remote machine.
1186
1187 @tramp{} depends on a number of programs on the remote host in order to
1188 function, including @command{ls}, @command{test}, @command{find} and
1189 @command{cat}.
1190
1191 In addition to these required tools, there are various tools that may be
1192 required based on the connection method. See @ref{Inline methods} and
1193 @ref{External transfer methods} for details on these.
1194
1195 Certain other tools, such as @command{perl} (or @command{perl5}) and
1196 @command{grep} will be used if they can be found. When they are
1197 available, they are used to improve the performance and accuracy of
1198 remote file access.
1199
1200 @vindex tramp-remote-path
1201 When @tramp{} connects to the remote machine, it searches for the
1202 programs that it can use. The variable @var{tramp-remote-path} controls
1203 the directories searched on the remote machine.
1204
1205 By default, this is set to a reasonable set of defaults for most
1206 machines. It is possible, however, that your local (or remote ;) system
1207 administrator has put the tools you want in some obscure local
1208 directory.
1209
1210 In this case, you can still use them with @tramp{}. You simply need to
1211 add code to your @file{.emacs} to add the directory to the remote path.
1212 This will then be searched by @tramp{} when you connect and the software
1213 found.
1214
1215 To add a directory to the remote search path, you could use code such
1216 as:
1217
1218 @lisp
1219 @i{;; We load @tramp{} to define the variable.}
1220 (require 'tramp)
1221 @i{;; We have @command{perl} in "/usr/local/perl/bin"}
1222 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1223 @end lisp
1224
1225
1226 @node Remote shell setup
1227 @comment node-name, next, previous, up
1228 @section Remote shell setup hints
1229 @cindex remote shell setup
1230 @cindex @file{.profile} file
1231 @cindex @file{.login} file
1232 @cindex shell init files
1233
1234 As explained in the @ref{Overview} section, @tramp{} connects to the
1235 remote host and talks to the shell it finds there. Of course, when you
1236 log in, the shell executes its init files. Suppose your init file
1237 requires you to enter the birth date of your mother; clearly @tramp{}
1238 does not know this and hence fails to log you in to that host.
1239
1240 There are different possible strategies for pursuing this problem. One
1241 strategy is to enable @tramp{} to deal with all possible situations.
1242 This is a losing battle, since it is not possible to deal with
1243 @emph{all} situations. The other strategy is to require you to set up
1244 the remote host such that it behaves like @tramp{} expect. This might
1245 be inconvenient because you have to invest a lot of effort into shell
1246 setup before you can begin to use @tramp{}.
1247
1248 The package, therefore, pursues a combined approach. It tries to figure
1249 out some of the more common setups, and only requires you to avoid
1250 really exotic stuff. For example, it looks through a list of
1251 directories to find some programs on the remote host. And also, it
1252 knows that it is not obvious how to check whether a file exists, and
1253 therefore it tries different possibilities. (On some hosts and shells,
1254 the command @code{test -e} does the trick, on some hosts the shell
1255 builtin doesn't work but the program @code{/usr/bin/test -e} or
1256 @code{/bin/test -e} works. And on still other hosts, @code{ls -d} is
1257 the right way to do this.)
1258
1259 Below you find a discussion of a few things that @tramp{} does not deal
1260 with, and that you therefore have to set up correctly.
1261
1262 @table @asis
1263 @item @var{shell-prompt-pattern}
1264 @vindex shell-prompt-pattern
1265
1266 After logging in to the remote host, @tramp{} has to wait for the remote
1267 shell startup to finish before it can send commands to the remote
1268 shell. The strategy here is to wait for the shell prompt. In order to
1269 recognize the shell prompt, the variable @code{shell-prompt-pattern} has
1270 to be set correctly to recognize the shell prompt on the remote host.
1271
1272 Note that @tramp{} requires the match for @code{shell-prompt-pattern}
1273 to be at the end of the buffer. Many people have something like the
1274 following as the value for the variable: @code{"^[^>$][>$] *"}. Now
1275 suppose your shell prompt is @code{a <b> c $ }. In this case,
1276 @tramp{} recognizes the @code{>} character as the end of the prompt,
1277 but it is not at the end of the buffer.
1278
1279 @item @var{tramp-shell-prompt-pattern}
1280 @vindex tramp-shell-prompt-pattern
1281
1282 This regular expression is used by @tramp{} in the same way as
1283 @code{shell-prompt-pattern}, to match prompts from the remote shell.
1284 This second variable exists because the prompt from the remote shell
1285 might be different from the prompt from a local shell --- after all,
1286 the whole point of @tramp{} is to log in to remote hosts as a
1287 different user. The default value of
1288 @code{tramp-shell-prompt-pattern} is the same as the default value of
1289 @code{shell-prompt-pattern}, which is reported to work well in many
1290 circumstances.
1291
1292 @item @code{tset} and other questions
1293 @cindex Unix command tset
1294 @cindex tset Unix command
1295
1296 Some people invoke the @code{tset} program from their shell startup
1297 scripts which asks the user about the terminal type of the shell.
1298 Maybe some shells ask other questions when they are started. @tramp{}
1299 does not know how to answer these questions. There are two approaches
1300 for dealing with this problem. One approach is to take care that the
1301 shell does not ask any questions when invoked from @tramp{}. You can
1302 do this by checking the @code{TERM} environment variable, it will be
1303 set to @code{dumb} when connecting.
1304
1305 @vindex tramp-terminal-type
1306 The variable @code{tramp-terminal-type} can be used to change this value
1307 to @code{dumb}.
1308
1309 The other approach is to teach @tramp{} about these questions. See
1310 the variables @code{tramp-actions-before-shell} and
1311 @code{tramp-multi-actions} (for multi-hop connections).
1312
1313 @item Non-Bourne commands in @file{.profile}
1314
1315 After logging in to the remote host, @tramp{} issues the command
1316 @code{exec /bin/sh}. (Actually, the command is slightly different.)
1317 When @code{/bin/sh} is executed, it reads some init files, such as
1318 @file{~/.shrc} or @file{~/.profile}.
1319
1320 Now, some people have a login shell which is not @code{/bin/sh} but a
1321 Bourne-ish shell such as bash or ksh. Some of these people might put
1322 their shell setup into the files @code{~/.shrc} or @code{~/.profile}.
1323 This way, it is possible for non-Bourne constructs to end up in those
1324 files. Then, @code{exec /bin/sh} might cause the Bourne shell to barf
1325 on those constructs.
1326
1327 As an example, imagine somebody putting @code{export FOO=bar} into the
1328 file @file{~/.profile}. The standard Bourne shell does not understand
1329 this syntax and will emit a syntax error when it reaches this line.
1330
1331 Another example is the tilde (@code{~}) character, say when adding
1332 @file{~/bin} to @code{$PATH}. Many Bourne shells will not expand this
1333 character, and since there is usually no directory whose name consists
1334 of the single character tilde, strange things will happen.
1335
1336 What can you do about this?
1337
1338 Well, one possibility is to make sure that everything in @file{~/.shrc}
1339 and @file{~/.profile} on all remote hosts is Bourne-compatible. In the
1340 above example, instead of @code{export FOO=bar}, you might use
1341 @code{FOO=bar; export FOO} instead.
1342
1343 The other possibility is to put your non-Bourne shell setup into some
1344 other files. For example, bash reads the file @file{~/.bash_profile}
1345 instead of @file{~/.profile}, if the former exists. So bash
1346 aficionados just rename their @file{~/.profile} to
1347 @file{~/.bash_profile} on all remote hosts, and Bob's your uncle.
1348
1349 The @tramp{} developers would like to circumvent this problem, so if you
1350 have an idea about it, please tell us. However, we are afraid it is not
1351 that simple: before saying @code{exec /bin/sh}, @tramp{} does not know
1352 which kind of shell it might be talking to. It could be a Bourne-ish
1353 shell like ksh or bash, or it could be a csh derivative like tcsh, or
1354 it could be zsh, or even rc. If the shell is Bourne-ish already, then
1355 it might be prudent to omit the @code{exec /bin/sh} step. But how to
1356 find out if the shell is Bourne-ish?
1357
1358 @end table
1359
1360
1361 @node Auto-save and Backup
1362 @section Auto-save and Backup configuration
1363 @cindex auto-save
1364 @cindex backup
1365 @vindex backup-directory-alist
1366
1367 Explaining auto-save is still to do.
1368
1369 Normally, Emacs writes backup files to the same directory as the
1370 original files, but this behavior can be changed via the variable
1371 @code{backup-directory-alist}. In connection with @tramp{}, this can
1372 have unexpected side effects. Suppose that you specify that all backups
1373 should go to the directory @file{~/.emacs.d/backups/}, and then you edit
1374 the file @file{/su:root@@localhost:/etc/secretfile}. The effect is that
1375 the backup file will be owned by you and not by root, thus possibly
1376 enabling others to see it even if they were not intended to see it.
1377
1378 When @code{backup-directory-alist} is nil (the default), such problems
1379 do not occur.
1380
1381 If you wish to customize the variable, the workaround is to include
1382 special settings for Tramp files. For example, the following statement
1383 effectively `turns off' the effect of @code{backup-directory-alist} for
1384 @tramp{} files:
1385
1386 @lisp
1387 (require 'tramp)
1388 (add-to-list 'backup-directory-alist
1389 (cons tramp-file-name-regexp nil))
1390 @end lisp
1391
1392
1393 @node Windows setup hints
1394 @section Issues with Cygwin ssh
1395 @cindex Cygwin, issues
1396
1397 This section needs a lot of work! Please help.
1398
1399 @cindex method sshx with Cygwin
1400 @cindex sshx method with Cygwin
1401 If you use the Cygwin installation of ssh (you have to explicitly select
1402 it in the installer), then it should work out of the box to just select
1403 @code{sshx} as the connection method. You can find information about
1404 setting up Cygwin in their FAQ at @uref{http://cygwin.com/faq/}.
1405
1406 @cindex method scpx with Cygwin
1407 @cindex scpx method with Cygwin
1408 If you wish to use the @code{scpx} connection method, then you might
1409 have the problem that Emacs calls @code{scp} with a Windows filename
1410 such as @code{c:/foo}. The Cygwin version of @code{scp} does not know
1411 about Windows filenames and interprets this as a remote filename on the
1412 host @code{c}.
1413
1414 One possible workaround is to write a wrapper script for @code{scp}
1415 which converts the Windows filename to a Cygwinized filename.
1416
1417 I guess that another workaround is to run Emacs under Cygwin, or to run
1418 a Cygwinized Emacs.
1419
1420 @cindex Cygwin and ssh-agent
1421 @cindex SSH_AUTH_SOCK and Emacs on Windows
1422 If you want to use either @code{ssh} based method on Windows, then you
1423 might encounter problems with @code{ssh-agent}. Using this program,
1424 you can avoid typing the pass-phrase every time you log in (and the
1425 @code{scpx} method more or less requires you to use @code{ssh-agent}
1426 because it does not allow you to type a password or pass-phrase).
1427 However, if you start Emacs from a desktop shortcut, then the
1428 environment variable @code{SSH_AUTH_SOCK} is not set and so Emacs and
1429 thus @tramp{} and thus @code{ssh} and @code{scp} started from @tramp{}
1430 cannot communicate with @code{ssh-agent}. It works better to start
1431 Emacs from the shell.
1432
1433 If anyone knows how to start @code{ssh-agent} under Windows in such a
1434 way that desktop shortcuts can profit, please holler. I don't really
1435 know anything at all about Windows@dots{}
1436
1437
1438 @node Usage
1439 @chapter Using @tramp
1440 @cindex using @tramp
1441
1442 Once you have installed @tramp{} it will operate fairly transparently. You
1443 will be able to access files on any remote machine that you can log in
1444 to as though they were local.
1445
1446 Files are specified to @tramp{} using a formalized syntax specifying the
1447 details of the system to connect to. This is similar to the syntax used
1448 by the @value{ftp-package-name} package.
1449
1450 @cindex type-ahead
1451 Something that might happen which surprises you is that Emacs
1452 remembers all your keystrokes, so if you see a password prompt from
1453 Emacs, say, and hit @kbd{@key{RET}} twice instead of once, then the
1454 second keystroke will be processed by Emacs after @tramp{} has done
1455 its thing. Why, this type-ahead is normal behavior, you say. Right
1456 you are, but be aware that opening a remote file might take quite a
1457 while, maybe half a minute when a connection needs to be opened.
1458 Maybe after half a minute you have already forgotten that you hit that
1459 key!
1460
1461 @menu
1462 * Filename Syntax:: @tramp{} filename conventions.
1463 * Multi-hop filename syntax:: Multi-hop filename conventions.
1464 * Filename completion:: Filename completion.
1465 * Dired:: Dired.
1466 @end menu
1467
1468
1469 @node Filename Syntax
1470 @section @tramp{} filename conventions
1471 @cindex filename syntax
1472 @cindex filename examples
1473
1474 To access the file @var{localname} on the remote machine @var{machine} you
1475 would specify the filename
1476 @file{@value{tramp-prefix}@var{machine}@value{tramp-postfix}@var{localname}}.
1477 This will connect to @var{machine} and transfer the file using the
1478 default method. @xref{Default Method}.
1479
1480 Some examples of @tramp{} filenames are shown below.
1481
1482 @table @file
1483 @item @value{tramp-prefix}melancholia@value{tramp-postfix}.emacs
1484 Edit the file @file{.emacs} in your home directory on the machine
1485 @code{melancholia}.
1486
1487 @item @value{tramp-prefix}melancholia.danann.net@value{tramp-postfix}.emacs
1488 This edits the same file, using the fully qualified domain name of
1489 the machine.
1490
1491 @item @value{tramp-prefix}melancholia@value{tramp-postfix}~/.emacs
1492 This also edits the same file --- the @file{~} is expanded to your
1493 home directory on the remote machine, just like it is locally.
1494
1495 @item @value{tramp-prefix}melancholia@value{tramp-postfix}~daniel/.emacs
1496 This edits the file @file{.emacs} in the home directory of the user
1497 @code{daniel} on the machine @code{melancholia}. The @file{~<user>}
1498 construct is expanded to the home directory of that user on the remote
1499 machine.
1500
1501 @item @value{tramp-prefix}melancholia@value{tramp-postfix}/etc/squid.conf
1502 This edits the file @file{/etc/squid.conf} on the machine
1503 @code{melancholia}.
1504
1505 @end table
1506
1507 Unless you specify a different name to use, @tramp{} will use the
1508 current local user name as the remote user name to log in with. If you
1509 need to log in as a different user, you can specify the user name as
1510 part of the filename.
1511
1512 To log in to the remote machine as a specific user, you use the syntax
1513 @file{@value{tramp-prefix}@var{user}@@@var{machine}@value{tramp-postfix}/@var{path/to.file}}.
1514 That means that connecting to @code{melancholia} as @code{daniel} and
1515 editing @file{.emacs} in your home directory you would specify
1516 @file{@value{tramp-prefix}daniel@@melancholia@value{tramp-postfix}.emacs}.
1517
1518 It is also possible to specify other file transfer methods
1519 (@pxref{Default Method}) as part of the filename.
1520 @ifset emacs
1521 This is done by putting the method before the user and host name, as
1522 in
1523 @file{@value{tramp-prefix}@var{method}@value{tramp-postfix-single-hop}}
1524 (Note the trailing colon).
1525 @end ifset
1526 @ifset xemacs
1527 This is done by replacing the initial
1528 @file{@value{tramp-prefix}} with
1529 @file{@value{tramp-prefix}<method>@value{tramp-postfix-single-hop}}.
1530 (Note the trailing slash!).
1531 @end ifset
1532 The user, machine and file specification remain the same.
1533
1534 So, to connect to the machine @code{melancholia} as @code{daniel},
1535 using the @option{su} method to transfer files, and edit @file{.emacs}
1536 in my home directory I would specify the filename
1537 @file{@value{tramp-prefix}su@value{tramp-postfix-single-hop}daniel@@melancholia@value{tramp-postfix}.emacs}.
1538
1539
1540 @node Multi-hop filename syntax
1541 @section Multi-hop filename conventions
1542 @cindex filename syntax for multi-hop files
1543 @cindex multi-hop filename syntax
1544
1545 The syntax of multi-hop file names is necessarily slightly different
1546 than the syntax of other @tramp{} file names. Here's an example
1547 multi-hop file name, first in Emacs syntax and then in XEmacs syntax:
1548
1549 @example
1550 @value{tramp-prefix}multi@value{tramp-postfix-single-hop}rsh@value{tramp-postfix-multi-hop}out@@gate@value{tramp-postfix-single-hop}telnet@value{tramp-postfix-multi-hop}kai@@real.host@value{tramp-postfix}/path/to.file
1551 @end example
1552
1553 This is quite a mouthful. So let's go through it step by step. The
1554 file name consists of three parts.
1555 @ifset emacs
1556 The parts are separated by colons
1557 @end ifset
1558 @ifset xemacs
1559 The parts are separated by slashes and square brackets.
1560 @end ifset
1561 The first part is @file{@value{tramp-prefix}multi}, the method
1562 specification. The second part is
1563 @file{rsh@value{tramp-postfix-multi-hop}out@@gate@value{tramp-postfix-single-hop}telnet@value{tramp-postfix-multi-hop}kai@@real.host}
1564 and specifies the hops. The final part is @file{/path/to.file} and
1565 specifies the file name on the remote host.
1566
1567 The first part and the final part should be clear. See @ref{Multi-hop
1568 Methods}, for a list of alternatives for the method specification.
1569
1570 The second part can be subdivided again into components, so-called
1571 hops. In the above file name, there are two hops,
1572 @file{rsh@value{tramp-postfix-multi-hop}out@@gate} and
1573 @file{telnet@value{tramp-postfix-multi-hop}kai@@real.host}.
1574
1575 Each hop can @emph{again} be subdivided into (three) components, the
1576 @dfn{hop method}, the @dfn{user name} and the @dfn{host name}. The
1577 meaning of the second and third component should be clear, and the hop
1578 method says what program to use to perform that hop.
1579
1580 The first hop, @file{rsh@value{tramp-postfix-multi-hop}out@@gate},
1581 says to use @command{rsh} to log in as user @code{out} to the host
1582 @code{gate}. Starting at that host, the second hop,
1583 @file{telnet@value{tramp-postfix-multi-hop}kai@@real.host}, says to
1584 use @command{telnet} to log in as user @code{kai} to host
1585 @code{real.host}.
1586
1587 @xref{Multi-hop Methods}, for a list of possible hop method values.
1588 The variable @code{tramp-multi-connection-function-alist} contains the
1589 list of possible hop methods and information on how to execute them,
1590 should you want to add your own.
1591
1592
1593 @node Filename completion
1594 @section Filename completion
1595 @cindex filename completion
1596
1597 Filename completion works with @tramp{} for both completing methods,
1598 user names and machine names (except multi hop methods) as well as for
1599 files on remote machines.
1600
1601 If you, for example, type @kbd{C-x C-f @value{tramp-prefix}t
1602 @key{TAB}}, @tramp{} might give you as result the choice for
1603
1604 @example
1605 @ifset emacs
1606 @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop} tmp/
1607 @value{tramp-prefix-single-hop}toto@value{tramp-postfix}
1608 @end ifset
1609 @ifset xemacs
1610 @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop} @value{tramp-prefix-single-hop}toto@value{tramp-postfix}
1611 @end ifset
1612 @end example
1613
1614 @samp{@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}}
1615 is a possible completion for the respective method,
1616 @ifset emacs
1617 @samp{tmp/} stands for the directory @file{/tmp} on your local
1618 machine,
1619 @end ifset
1620 and @samp{@value{tramp-prefix-single-hop}toto@value{tramp-postfix}}
1621 might be a host @tramp has detected in your @file{~/.ssh/known_hosts}
1622 file (given you're using default method @option{ssh}).
1623
1624 If you go on to type @kbd{e @key{TAB}}, the minibuffer is completed to
1625 @samp{@value{tramp-prefix}telnet@value{tramp-postfix-single-hop}}.
1626 Next @kbd{@key{TAB}} brings you all machine names @tramp{} detects in
1627 your @file{/etc/hosts} file, let's say
1628
1629 @example
1630 @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}127.0.0.1@value{tramp-postfix} @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}192.168.0.1@value{tramp-postfix}
1631 @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}localhost@value{tramp-postfix} @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}melancholia.danann.net@value{tramp-postfix}
1632 @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}melancholia@value{tramp-postfix}
1633 @end example
1634
1635 Now you can choose the desired machine, and you can continue to
1636 complete file names on that machine.
1637
1638 As filename completion needs to fetch the listing of files from the
1639 remote machine, this feature is sometimes fairly slow. As @tramp{}
1640 does not yet cache the results of directory listing, there is no gain
1641 in performance the second time you complete filenames.
1642
1643 If the configuration files (@pxref{Customizing Completion}), which
1644 @tramp{} uses for analysis of completion, offer user names, those user
1645 names will be taken into account as well.
1646
1647
1648 @node Dired
1649 @section Dired
1650 @cindex dired
1651
1652 @tramp{} works transparently with dired, enabling you to use this powerful
1653 file management tool to manage files on any machine you have access to
1654 over the Internet.
1655
1656 If you need to browse a directory tree, Dired is a better choice, at
1657 present, than filename completion. Dired has its own cache mechanism
1658 and will only fetch the directory listing once.
1659
1660
1661 @node Bug Reports
1662 @chapter Reporting Bugs and Problems
1663 @cindex bug reports
1664
1665 Bugs and problems with @tramp{} are actively worked on by the development
1666 team. Feature requests and suggestions are also more than welcome.
1667
1668 The @tramp{} mailing list is a great place to get information on working
1669 with @tramp{}, solving problems and general discussion and advice on topics
1670 relating to the package.
1671
1672 The mailing list is at @email{tramp-devel@@mail.freesoftware.fsf.org}.
1673 Messages sent to this address go to all the subscribers. This is
1674 @emph{not} the address to send subscription requests to.
1675
1676 For help on subscribing to the list, send mail to the administrative
1677 address, @email{tramp-devel-request@@mail.freesoftware.fsf.org}, with the
1678 subject @samp{help}.
1679
1680 To report a bug in @tramp{}, you should execute @kbd{M-x tramp-bug}. This
1681 will automatically generate a buffer with the details of your system and
1682 @tramp{} version.
1683
1684 When submitting a bug report, please try to describe in excruciating
1685 detail the steps required to reproduce the problem, the setup of the
1686 remote machine and any special conditions that exist.
1687
1688 If you can identify a minimal test case that reproduces the problem,
1689 include that with your bug report. This will make it much easier for the
1690 development team to analyze and correct the problem.
1691
1692 @node Frequently Asked Questions
1693 @chapter Frequently Asked Questions
1694 @cindex frequently asked questions
1695 @cindex FAQ
1696
1697 @itemize @bullet
1698 @item
1699 Where can I get the latest @tramp{}?
1700
1701 @tramp{} is available under the URL below.
1702
1703 @noindent
1704 @uref{http://savannah.nongnu.org/download/tramp/}
1705
1706 @noindent
1707 There is also a Savannah project page.
1708
1709 @noindent
1710 @uref{https://savannah.gnu.org/projects/tramp/}
1711
1712 @item
1713 Which systems does it work on?
1714
1715 The package has been used successfully on Emacs 20 and Emacs 21, as well
1716 as XEmacs 21. XEmacs 20 is more problematic, see the notes in
1717 @file{tramp.el}. I don't think anybody has really tried it on Emacs 19.
1718
1719 The package was intended to work on Unix, and it really expects a
1720 Unix-like system on the remote end, but some people seemed to have some
1721 success getting it to work on NT Emacs.
1722
1723 There is some informations on @tramp{} on NT at the following URL;
1724 many thanks to Joe Stoy for providing the information:
1725 @uref{ftp://ftp.comlab.ox.ac.uk/tmp/Joe.Stoy/}
1726
1727 The above mostly contains patches to old ssh versions; Tom Roche has a
1728 Web page with instructions:
1729 @uref{http://www4.ncsu.edu/~tlroche/plinkTramp.html}
1730
1731 ??? Is the XEmacs info correct?
1732
1733 ??? Can somebody provide some information for getting it to work on NT
1734 Emacs? I think there was some issue with @command{ssh}?
1735
1736
1737 @item
1738 I can't stop @value{ftp-package-name} starting with @value{emacs-name}
1739
1740 @ifset emacs
1741 @value{ftp-package-name} is loaded from @tramp{} automatically if you
1742 require a file by the ftp method. Unfortunately, there are some Lisp
1743 packages which make @value{ftp-package-name} file name handlers active.
1744 You can see it applying @kbd{C-h v file-name-handler-alist}:
1745
1746 @example
1747 file-name-handler-alist's value is
1748 (("^/[^/:]*\\'" . ange-ftp-completion-hook-function)
1749 ("^/[^/:]*[^/:.]:" . ange-ftp-hook-function)
1750 ("^/[^/]*$" . tramp-completion-file-name-handler)
1751 ("\\`/[^/:]+:" . tramp-file-name-handler)
1752 ("\\`/:" . file-name-non-special))
1753 @end example
1754
1755 Please try to find out which package is responsible for loading
1756 @value{ftp-package-name}, and raise a bug report.
1757
1758 A workaround is to require @value{ftp-package-name} before @tramp{} in
1759 your @file{~/.emacs}, because @tramp{} cleans up the entries in
1760 @code{file-name-handler-alist}:
1761
1762 @lisp
1763 ;; @value{ftp-package-name} temporarily required
1764 (require 'ange-ftp)
1765 ;; @tramp{} cleans up @code{file-name-handler-alist}
1766 (require 'tramp)
1767 @end lisp
1768 @end ifset
1769
1770 @ifset xemacs
1771 Not all the older versions of @tramp{} supported @value{emacs-name}
1772 correctly. The first thing to do is to make sure that you have the
1773 latest version of @tramp{} installed.
1774
1775 If you do, please try and find out exactly the conditions required for
1776 the @value{ftp-package-name} handlers to fire. If you can, putting a
1777 breakpoint on @code{efs-ftp-path} and sending in the stack trace along
1778 with your bug report would make it easier for the developers to work out
1779 what is going wrong.
1780 @end ifset
1781
1782
1783 @item
1784 File name completion does not work with @tramp{}
1785
1786 When you log in to the remote machine, do you see the output of
1787 @command{ls} in color? If so, this may be the cause of your problems.
1788
1789 @command{ls} outputs @acronym{ANSI} escape sequences that your terminal
1790 emulator interprets to set the colors. These escape sequences will
1791 confuse @tramp{} however.
1792
1793 In your @file{.bashrc}, @file{.profile} or equivalent on the remote
1794 machine you probably have an alias configured that adds the option
1795 @option{--color=yes} or @option{--color=auto}.
1796
1797 You should remove that alias and ensure that a new login @emph{does not}
1798 display the output of @command{ls} in color. If you still cannot use
1799 filename completion, report a bug to the @tramp{} developers.
1800
1801
1802 @item
1803 File name completion does not work in large directories
1804
1805 @tramp{} uses globbing for some operations. (Globbing means to use the
1806 shell to expand wildcards such as `*.c'.) This might create long
1807 command lines, especially in directories with many files. Some shells
1808 choke on long command lines, or don't cope well with the globbing
1809 itself.
1810
1811 If you have a large directory on the remote end, you may wish to execute
1812 a command like @samp{ls -d * ..?* > /dev/null} and see if it hangs.
1813 Note that you must first start the right shell, which might be
1814 @command{/bin/sh}, @command{ksh} or @command{bash}, depending on which
1815 of those supports tilde expansion.
1816
1817
1818 @item
1819 What kinds of systems does @tramp{} work on
1820
1821 @tramp{} really expects the remote system to be a Unix-like system. The
1822 local system should preferably be Unix-like, as well, but @tramp{} might
1823 work on NT with some tweaking.
1824
1825
1826 @item
1827 How can I get notified when @tramp{} file transfers are complete?
1828
1829 The following snippet can be put in your @file{~/.emacs} file. It makes
1830 Emacs beep after reading from or writing to the remote host.
1831
1832 @lisp
1833 (defadvice tramp-handle-write-region
1834 (after tramp-write-beep-advice activate)
1835 " make tramp beep after writing a file."
1836 (interactive)
1837 (beep))
1838 (defadvice tramp-handle-do-copy-or-rename-file
1839 (after tramp-copy-beep-advice activate)
1840 " make tramp beep after copying a file."
1841 (interactive)
1842 (beep))
1843 (defadvice tramp-handle-insert-file-contents
1844 (after tramp-copy-beep-advice activate)
1845 " make tramp beep after copying a file."
1846 (interactive)
1847 (beep))
1848 @end lisp
1849
1850
1851 @item
1852 There's this @file{~/.sh_history} file on the remote host which keeps
1853 growing and growing. What's that?
1854
1855 Sometimes, @tramp{} starts @code{ksh} on the remote host for tilde
1856 expansion. Maybe @code{ksh} saves the history by default. @tramp{}
1857 tries to turn off saving the history, but maybe you have to help. For
1858 example, you could put this in your @file{.kshrc}:
1859
1860 @example
1861 if [ -f $HOME/.sh_history ] ; then
1862 /bin/rm $HOME/.sh_history
1863 fi
1864 if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
1865 unset HISTFILE
1866 fi
1867 if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
1868 unset HISTSIZE
1869 fi
1870 @end example
1871
1872
1873 @item @tramp{} doesn't transfer strings with more than 500 characters
1874 correctly
1875
1876 On some few systems, the implementation of @code{process-send-string}
1877 seems to be broken for longer strings. This case, you should
1878 customize the variable @code{tramp-chunksize} to 500. For a
1879 description how to determine whether this is necessary see the
1880 documentation of @code{tramp-chunksize}.
1881
1882 @end itemize
1883
1884
1885 @c For the developer
1886 @node Version Control
1887 @chapter The inner workings of remote version control
1888 @cindex Version Control
1889
1890 Unlike @value{ftp-package-name}, @tramp{} has full shell access to the
1891 remote machine. This makes it possible to provide version control for
1892 files accessed under @tramp{}.
1893
1894 The actual version control binaries must be installed on the remote
1895 machine, accessible in the directories specified in
1896 @var{tramp-remote-path}.
1897
1898 This transparent integration with the version control systems is one of
1899 the most valuable features provided by @tramp{}, but it is far from perfect.
1900 Work is ongoing to improve the transparency of the system.
1901
1902 @menu
1903 * Version Controlled Files:: Determining if a file is under version control.
1904 * Remote Commands:: Executing the version control commands on the remote machine.
1905 * Changed workfiles:: Detecting if the working file has changed.
1906 * Checking out files:: Bringing the workfile out of the repository.
1907 * Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
1908 @end menu
1909
1910
1911 @node Version Controlled Files
1912 @section Determining if a file is under version control
1913
1914 The VC package uses the existence of on-disk revision control master
1915 files to determine if a given file is under revision control. These file
1916 tests happen on the remote machine through the standard @tramp{} mechanisms.
1917
1918
1919 @node Remote Commands
1920 @section Executing the version control commands on the remote machine
1921
1922 There are no hooks provided by VC to allow intercepting of the version
1923 control command execution. The calls occur through the
1924 @code{call-process} mechanism, a function that is somewhat more
1925 efficient than the @code{shell-command} function but that does not
1926 provide hooks for remote execution of commands.
1927
1928 To work around this, the functions @code{vc-do-command} and
1929 @code{vc-simple-command} have been advised to intercept requests for
1930 operations on files accessed via @tramp{}.
1931
1932 In the case of a remote file, the @code{shell-command} interface is
1933 used, with some wrapper code, to provide the same functionality on the
1934 remote machine as would be seen on the local machine.
1935
1936
1937 @node Changed workfiles
1938 @section Detecting if the working file has changed
1939
1940 As there is currently no way to get access to the mtime of a file on a
1941 remote machine in a portable way, the @code{vc-workfile-unchanged-p}
1942 function is advised to call an @tramp{} specific function for remote files.
1943
1944 The @code{tramp-vc-workfile-unchanged-p} function uses the functioning VC
1945 diff functionality to determine if any changes have occurred between the
1946 workfile and the version control master.
1947
1948 This requires that a shell command be executed remotely, a process that
1949 is notably heavier-weight than the mtime comparison used for local
1950 files. Unfortunately, unless a portable solution to the issue is found,
1951 this will remain the cost of remote version control.
1952
1953
1954 @node Checking out files
1955 @section Bringing the workfile out of the repository
1956
1957 VC will, by default, check for remote files and refuse to act on them
1958 when checking out files from the repository. To work around this
1959 problem, the function @code{vc-checkout} knows about @tramp{} files and
1960 allows version control to occur.
1961
1962
1963 @node Miscellaneous Version Control
1964 @section Things related to Version Control that don't fit elsewhere
1965
1966 Minor implementation details, &c.
1967
1968 @menu
1969 * Remote File Ownership:: How VC determines who owns a workfile.
1970 * Back-end Versions:: How VC determines what release your RCS is.
1971 @end menu
1972
1973
1974 @node Remote File Ownership
1975 @subsection How VC determines who owns a workfile
1976
1977 Emacs provides the @code{user-full-name} function to return the login name
1978 of the current user as well as mapping from arbitrary user id values
1979 back to login names. The VC code uses this functionality to map from the
1980 uid of the owner of a workfile to the login name in some circumstances.
1981
1982 This will not, for obvious reasons, work if the remote system has a
1983 different set of logins. As such, it is necessary to delegate to the
1984 remote machine the job of determining the login name associated with a
1985 uid.
1986
1987 Unfortunately, with the profusion of distributed management systems such
1988 as @code{NIS}, @code{NIS+} and @code{NetInfo}, there is no simple,
1989 reliable and portable method for performing this mapping.
1990
1991 Thankfully, the only place in the VC code that depends on the mapping of
1992 a uid to a login name is the @code{vc-file-owner} function. This returns
1993 the login of the owner of the file as a string.
1994
1995 This function has been advised to use the output of @command{ls} on the
1996 remote machine to determine the login name, delegating the problem of
1997 mapping the uid to the login to the remote system which should know more
1998 about it than I do.
1999
2000
2001 @node Back-end Versions
2002 @subsection How VC determines what release your RCS is
2003
2004 VC needs to know what release your revision control binaries you are
2005 running as not all features VC supports are available with older
2006 versions of @command{rcs(1)}, @command{cvs(1)} or @command{sccs(1)}.
2007
2008 The default implementation of VC determines this value the first time it
2009 is needed and then stores the value globally to avoid the overhead of
2010 executing a process and parsing its output each time the information is
2011 needed.
2012
2013 Unfortunately, life is not quite so easy when remote version control
2014 comes into the picture. Each remote machine may have a different version
2015 of the version control tools and, while this is painful, we need to
2016 ensure that unavailable features are not used remotely.
2017
2018 To resolve this issue, @tramp{} currently takes the sledgehammer
2019 approach of making the release values of the revision control tools
2020 local to each @tramp{} buffer, forcing VC to determine these values
2021 again each time a new file is visited.
2022
2023 This has, quite obviously, some performance implications. Thankfully,
2024 most of the common operations performed by VC do not actually require
2025 that the remote version be known. This makes the problem far less
2026 apparent.
2027
2028 Eventually these values will be captured by @tramp{} on a system by
2029 system basis and the results cached to improve performance.
2030
2031
2032 @node Files directories and localnames
2033 @chapter How file names, directories and localnames are mangled and managed.
2034
2035 @menu
2036 * Localname deconstruction:: Breaking a localname into its components.
2037 @end menu
2038
2039
2040 @node Localname deconstruction
2041 @section Breaking a localname into its components.
2042
2043 @tramp{} file names are somewhat different, obviously, to ordinary file
2044 names. As such, the lisp functions @code{file-name-directory} and
2045 @code{file-name-nondirectory} are overridden within the @tramp{}
2046 package.
2047
2048 Their replacements are reasonably simplistic in their approach. They
2049 dissect the filename, call the original handler on the localname and
2050 then rebuild the @tramp{} file name with the result.
2051
2052 This allows the platform specific hacks in the original handlers to take
2053 effect while preserving the @tramp{} file name information.
2054
2055
2056 @node Issues
2057 @chapter Debatable Issues and What Was Decided
2058
2059 @itemize @bullet
2060 @item The uuencode method does not always work.
2061
2062 Due to the design of @tramp{}, the encoding and decoding programs need to
2063 read from stdin and write to stdout. On some systems, @code{uudecode -o
2064 -} will read stdin and write the decoded file to stdout, on other
2065 systems @code{uudecode -p} does the same thing. But some systems have
2066 uudecode implementations which cannot do this at all---it is not
2067 possible to call these uudecode implementations with suitable parameters
2068 so that they write to stdout.
2069
2070 Of course, this could be circumvented: the @code{begin foo 644} line
2071 could be rewritten to put in some temporary file name, then
2072 @code{uudecode} could be called, then the temp file could be printed and
2073 deleted.
2074
2075 But I have decided that this is too fragile to reliably work, so on some
2076 systems you'll have to do without the uuencode methods.
2077
2078 @item @tramp{} does not work on XEmacs 20.
2079
2080 This is because it requires the macro @code{with-timeout} which does not
2081 appear to exist in XEmacs 20. I'm somewhat reluctant to add an
2082 emulation macro to @tramp{}, but if somebody who uses XEmacs 20 steps
2083 forward and wishes to implement and test it, please contact me or the
2084 mailing list.
2085
2086 @item The @tramp{} filename syntax differs between Emacs and XEmacs.
2087
2088 The Emacs maintainers wish to use a unified filename syntax for
2089 Ange-FTP and @tramp{} so that users don't have to learn a new
2090 syntax. It is sufficient to learn some extensions to the old syntax.
2091
2092 For the XEmacs maintainers, the problems caused from using a unified
2093 filename syntax are greater than the gains. The XEmacs package system
2094 uses EFS for downloading new packages. So, obviously, EFS has to be
2095 installed from the start. If the filenames were unified, @tramp{}
2096 would have to be installed from the start, too.
2097
2098 @end itemize
2099
2100 @node Concept Index
2101 @comment node-name, next, previous, up
2102 @unnumbered Concept Index
2103 @printindex cp
2104 @contents
2105 @c End of tramp.texi - the TRAMP User Manual
2106 @bye
2107
2108 @c TODO
2109 @c
2110 @c * Say something about the .login and .profile files of the remote
2111 @c shells.
2112 @c * Explain how tramp.el works in principle: open a shell on a remote
2113 @c host and then send commands to it.
2114 @c * Mention that bookmarks are a cool feature to go along with Tramp.
2115 @c * Make terminology "inline" vs "out-of-band" consistent.
2116 @c It seems that "external" is also used instead of "out-of-band".
2117
2118 @c * M. Albinus
2119 @c ** Use `filename' resp. `file name' consistently.
2120 @c ** Use `host' resp. `machine' consistently.
2121 @c ** Consistent small or capitalized words especially in menues.