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