(select-safe-coding-system): Try to
[emacs.git] / man / tramp.texi
blob756b467157c6f0cc21ec56176be1c8cd8e7588af
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
8 @c This is *so* much nicer :)
9 @footnotestyle end
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.
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.
18 @include trampver.texi
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
27 @copying
28 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free
29 Software Foundation, Inc.
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.1 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.
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.''
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
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
58 @tex
60 @titlepage
61 @title @value{tramp} version @value{trampver} User Manual
63 @author by Daniel Pittman
64 @author based on documentation by Kai Gro@ss{}johann
66 @page
67 @insertcopying
69 @end titlepage
70 @page
72 @end tex
74 @ifnottex
75 @node Top, Overview, (dir), (dir)
76 @top @value{tramp} version @value{trampver} User Manual
78 This file documents @value{tramp} version @value{trampver}, a remote file
79 editing package for @value{emacsname}.
81 @value{tramp} stands for `Transparent Remote (file) Access, Multiple
82 Protocol'.  This package provides remote file editing, similar to
83 @value{ftppackagename}.
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}.
90 You can find the latest version of this document on the web at
91 @uref{http://www.gnu.org/software/tramp/}.
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
107 @ifhtml
108 @ifset jamanual
109 This manual is also available as a @uref{@value{japanesemanual},
110 Japanese translation}.
111 @end ifset
113 The latest release of @value{tramp} is available for
114 @uref{http://ftp.gnu.org/gnu/tramp/, download}, or you may see
115 @ref{Obtaining Tramp} for more details, including the CVS server
116 details.
118 @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
119 Savannah Project Page}.
120 @end ifhtml
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
136 @insertcopying
138 @end ifnottex
140 @menu
141 * Overview::                    What @value{tramp} can and cannot do.
143 For the end user:
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.
156 For the developer:
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.
162 @detailmenu
163  --- The Detailed Node Listing ---
165 @ifset installchapter
166 Installing @value{tramp} with your @value{emacsname}
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.
172 @end ifset
174 Configuring @value{tramp} for use
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.
189 Using @value{tramp}
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.
197 The inner workings of remote version control
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.
205 Things related to Version Control that don't fit elsewhere
207 * Remote File Ownership::       How VC determines who owns a workfile.
208 * Back-end Versions::           How VC determines what release your RCS is.
210 How file names, directories and localnames are mangled and managed
212 * Localname deconstruction::    Breaking a localname into its components.
214 @end detailmenu
215 @end menu
217 @node Overview
218 @chapter An overview of @value{tramp}
219 @cindex overview
221 After the installation of @value{tramp} into your @value{emacsname}, you
222 will be able to access files on remote machines as though they were
223 local.  Access to the remote file system for editing files, version
224 control, and @command{dired} are transparently enabled.
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.
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.
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.
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.
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}.
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.
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.
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.
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}.
269 @subsubheading Behind the scenes
270 @cindex behind the scenes
271 @cindex details of operation
272 @cindex how it works
274 This section tries to explain what goes on behind the scenes when you
275 access a remote file through @value{tramp}.
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:
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.
291 @item
292 The remote host may prompt for a login name (for @command{telnet}).  The
293 login name is given in the file name, so @value{tramp} sends the login name and
294 a newline.
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.
302 You enter the password or pass phrase.  @value{tramp} sends it to the remote
303 host, followed by a newline.
305 @item
306 @value{tramp} now waits for the shell prompt or for a message that the login
307 failed.
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.
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.
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{}}
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.
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.
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.
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.
345 See above for an explanation of how @value{tramp} transfers the file contents.
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.
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.
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.
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.
369 @end itemize
371 I hope this has provided you with a basic overview of what happens
372 behind the scenes when you open a file with @value{tramp}.
375 @c For the end user
376 @node Obtaining Tramp
377 @chapter Obtaining Tramp.
378 @cindex obtaining Tramp
380 @value{tramp} is freely available on the Internet and the latest
381 release may be downloaded from
382 @uref{http://ftp.gnu.org/gnu/tramp/}. This release includes the full
383 documentation and code for @value{tramp}, suitable for installation.
384 But GNU Emacs (22 or later) includes @value{tramp} already, and there
385 is a @value{tramp} package for XEmacs, as well.  So maybe it is easier
386 to just use those.  But if you want the bleeding edge, read
387 on@dots{...}
389 For the especially brave, @value{tramp} is available from CVS.  The CVS
390 version is the latest version of the code and may contain incomplete
391 features or new issues. Use these versions at your own risk.
393 Instructions for obtaining the latest development version of @value{tramp}
394 from CVS can be found by going to the Savannah project page at the
395 following URL and then clicking on the CVS link in the navigation bar
396 at the top.
398 @noindent
399 @uref{http://savannah.gnu.org/projects/tramp/}
401 @noindent
402 Or follow the example session below:
404 @example
405 ] @strong{cd ~/@value{emacsdir}}
406 ] @strong{export CVS_RSH="ssh"}
407 ] @strong{cvs -z3 -d:ext:anoncvs@@savannah.gnu.org:/cvsroot/tramp co tramp}
408 @end example
410 @noindent
411 You should now have a directory @file{~/@value{emacsdir}/tramp}
412 containing the latest version of @value{tramp}. You can fetch the latest
413 updates from the repository by issuing the command:
415 @example
416 ] @strong{cd ~/@value{emacsdir}/tramp}
417 ] @strong{export CVS_RSH="ssh"}
418 ] @strong{cvs update -d}
419 @end example
421 @noindent
422 Once you've got updated files from the CVS repository, you need to run
423 @command{autoconf} in order to get an up-to-date @file{configure}
424 script:
426 @example
427 ] @strong{cd ~/@value{emacsdir}/tramp}
428 ] @strong{autoconf}
429 @end example
432 @node History
433 @chapter History of @value{tramp}
434 @cindex history
435 @cindex development history
437 Development was started end of November 1998.  The package was called
438 @file{rssh.el}, back then.  It only provided one method to access a
439 file, using @command{ssh} to log in to a remote host and using
440 @command{scp} to transfer the file contents.  After a while, the name
441 was changed to @file{rcp.el}, and now it's @value{tramp}.  Along the way,
442 many more methods for getting a remote shell and for transferring the
443 file contents were added.  Support for VC was added.
445 The most recent addition of major features were the multi-hop methods
446 added in April 2000 and the unification of @value{tramp} and Ange-FTP
447 filenames in July 2002.
449 @c Installation chapter is necessary only in case of standalone
450 @c installation.  Text taken from trampinst.texi.
451 @ifset installchapter
452 @include trampinst.texi
453 @end ifset
455 @node Configuration
456 @chapter Configuring @value{tramp} for use
457 @cindex configuration
459 @cindex default configuration
460 @value{tramp} is (normally) fully functional when it is initially installed.
461 It is initially configured to use the @command{ssh} program to connect
462 to the remote host and to use base64 or uu encoding to transfer the
463 files through that shell connection.  So in the easiest case, you just
464 type @kbd{C-x C-f} and then enter the filename
465 @file{@value{prefix}@var{user}@@@var{machine}@value{postfix}@var{/path/to.file}}.
467 On some hosts, there are problems with opening a connection.  These are
468 related to the behavior of the remote shell.  See @xref{Remote shell
469 setup}, for details on this.
471 If you do not wish to use these commands to connect to the remote
472 host, you should change the default connection and transfer method
473 that @value{tramp} uses.  There are several different methods that @value{tramp}
474 can use to connect to remote machines and transfer files
475 (@pxref{Connection types}).
477 If you don't know which method is right for you, see @xref{Default
478 Method}.
481 @menu
482 * Connection types::            Types of connections made to remote machines.
483 * Inline methods::              Inline methods.
484 * External transfer methods::   External transfer methods.
485 * Multi-hop Methods::           Connecting to a remote host using multiple hops.
486 * Default Method::              Selecting a default method.
487                                   Here we also try to help those who
488                                   don't have the foggiest which method
489                                   is right for them.
490 * Customizing Methods::         Using Non-Standard Methods.
491 * Customizing Completion::      Selecting config files for user/host name completion.
492 * Password caching::            Reusing passwords for several connections.
493 * Remote Programs::             How @value{tramp} finds and uses programs on the remote machine.
494 * Remote shell setup::          Remote shell setup hints.
495 * Windows setup hints::         Issues with Cygwin ssh.
496 * Auto-save and Backup::        Auto-save and Backup.
497 @end menu
500 @node Connection types
501 @section Types of connections made to remote machines.
502 @cindex connection types, overview
504 There are two basic types of transfer methods, each with its own
505 advantages and limitations.  Both types of connection make use of a
506 remote shell access program such as @command{rsh}, @command{ssh} or
507 @command{telnet} to connect to the remote machine.
509 This connection is used to perform many of the operations that @value{tramp}
510 requires to make the remote file system transparently accessible from
511 the local machine. It is only when visiting files that the methods
512 differ.
514 @cindex inline methods
515 @cindex external transfer methods
516 @cindex external methods
517 @cindex out-of-band methods
518 @cindex methods, inline
519 @cindex methods, external transfer
520 @cindex methods, out-of-band
521 Loading or saving a remote file requires that the content of the file
522 be transfered between the two machines. The content of the file can be
523 transfered over the same connection used to log in to the remote
524 machine or the file can be transfered through another connection using
525 a remote copy program such as @command{rcp}, @command{scp} or
526 @command{rsync}.  The former are called @dfn{inline methods}, the
527 latter are called @dfn{out-of-band methods} or @dfn{external transfer
528 methods} (@dfn{external methods} for short).
530 The performance of the external transfer methods is generally better
531 than that of the inline methods, at least for large files.  This is
532 caused by the need to encode and decode the data when transferring
533 inline.
535 The one exception to this rule are the @command{scp} based transfer
536 methods.  While these methods do see better performance when actually
537 transferring files, the overhead of the cryptographic negotiation at
538 startup may drown out the improvement in file transfer times.
540 External transfer methods should be configured such a way that they
541 don't require a password (with @command{ssh-agent}, or such alike).
542 If it isn't possible, you should consider @ref{Password caching},
543 otherwise you will be prompted for a password every copy action.
545 @cindex multi-hop methods
546 @cindex methods, multi-hop
547 A variant of the inline methods are the @dfn{multi-hop methods}.
548 These methods allow you to connect a remote host using a number `hops',
549 each of which connects to a different host.  This is useful if you are
550 in a secured network where you need to go through a bastion host to
551 connect to the outside world.
554 @node Inline methods
555 @section Inline methods
556 @cindex inline methods
557 @cindex methods, inline
559 The inline methods in @value{tramp} are quite powerful and can work in
560 situations where you cannot use an external transfer program to connect.
561 Inline methods are the only methods that work when connecting to the
562 remote machine via telnet.  (There are also strange inline methods which
563 allow you to transfer files between @emph{user identities} rather than
564 hosts, see below.)
566 These methods depend on the existence of a suitable encoding and
567 decoding command on remote machine.  Locally, @value{tramp} may be able to
568 use features of @value{emacsname} to decode and encode the files or
569 it may require access to external commands to perform that task.
571 @cindex uuencode
572 @cindex mimencode
573 @cindex base-64 encoding
574 @value{tramp} checks the availability and usability of commands like
575 @command{mimencode} (part of the @command{metamail} package) or
576 @command{uuencode} on the remote host.  The first reliable command
577 will be used.  The search path can be customized, see @ref{Remote
578 Programs}.
580 If both commands aren't available on the remote host, @value{tramp}
581 transfers a small piece of Perl code to the remote host, and tries to
582 apply it for encoding and decoding.
585 @table @asis
586 @item @option{rsh}
587 @cindex method rsh
588 @cindex rsh method
590 Connect to the remote host with @command{rsh}.  Due to the unsecure
591 connection it is recommended for very local host topology only.
593 On operating systems which provide the command @command{remsh} instead
594 of @command{rsh}, you can use the method @option{remsh}.  This is true
595 for HP-UX or Cray UNICOS, for example.
598 @item @option{ssh}
599 @cindex method ssh
600 @cindex ssh method
602 Connect to the remote host with @command{ssh}.  This is identical to
603 the previous option except that the @command{ssh} package is used,
604 making the connection more secure.
606 There are also two variants, @option{ssh1} and @option{ssh2}, that
607 call @samp{ssh -1} and @samp{ssh -2}, respectively.  This way, you can
608 explicitly select whether you want to use the SSH protocol version 1
609 or 2 to connect to the remote host.  (You can also specify in
610 @file{~/.ssh/config}, the SSH configuration file, which protocol
611 should be used, and use the regular @option{ssh} method.)
613 Two other variants, @option{ssh1_old} and @option{ssh2_old}, use the
614 @command{ssh1} and @command{ssh2} commands explicitly.  If you don't
615 know what these are, you do not need these options.
617 All the methods based on @command{ssh} have an additional kludgy
618 feature: you can specify a host name which looks like @file{host#42}
619 (the real host name, then a hash sign, then a port number).  This
620 means to connect to the given host but to also pass @code{-p 42} as
621 arguments to the @command{ssh} command.
624 @item @option{telnet}
625 @cindex method telnet
626 @cindex telnet method
628 Connect to the remote host with @command{telnet}.  This is as unsecure
629 as the @option{rsh} method.
632 @item @option{su}
633 @cindex method su
634 @cindex su method
636 This method does not connect to a remote host at all, rather it uses
637 the @command{su} program to allow you to edit files as another user.
640 @item @option{sudo}
641 @cindex method sudo
642 @cindex sudo method
644 This is similar to the @option{su} method, but it uses @command{sudo}
645 rather than @command{su} to become a different user.
647 Note that @command{sudo} must be configured to allow you to start a
648 shell as the user.  It would be nice if it was sufficient if
649 @command{ls} and @command{mimencode} were allowed, but that is not
650 easy to implement, so I haven't got around to it, yet.
653 @item @option{sshx}
654 @cindex method sshx
655 @cindex sshx method
656 @cindex Cygwin (with sshx method)
658 As you would expect, this is similar to @option{ssh}, only a little
659 different.  Whereas @option{ssh} opens a normal interactive shell on
660 the remote host, this option uses @samp{ssh -t -t @var{host} -l
661 @var{user} /bin/sh} to open a connection.  This is useful for users
662 where the normal login shell is set up to ask them a number of
663 questions when logging in.  This procedure avoids these questions, and
664 just gives @value{tramp} a more-or-less `standard' login shell to work
665 with.
667 Note that this procedure does not eliminate questions asked by
668 @command{ssh} itself.  For example, @command{ssh} might ask ``Are you
669 sure you want to continue connecting?'' if the host key of the remote
670 host is not known.  @value{tramp} does not know how to deal with such a
671 question (yet), therefore you will need to make sure that you can log
672 in without such questions.
674 This is also useful for Windows users where @command{ssh}, when
675 invoked from an @value{emacsname} buffer, tells them that it is not
676 allocating a pseudo tty.  When this happens, the login shell is wont
677 to not print any shell prompt, which confuses @value{tramp} mightily.  For
678 reasons unknown, some Windows ports for @command{ssh} (maybe the
679 Cygwin one) require the doubled @samp{-t} option.
681 This supports the @samp{-p} kludge.
684 @item @option{krlogin}
685 @cindex method krlogin
686 @cindex km krlogin
687 @cindex Kerberos (with krlogin method)
689 This method is also similar to @option{ssh}.  It only uses the
690 @command{krlogin -x} command to log in to the remote host.
693 @item @option{plink}
694 @cindex method plink
695 @cindex plink method
697 This method is mostly interesting for Windows users using the PuTTY
698 implementation of SSH.  It uses @samp{plink -ssh} to log in to the
699 remote host.
701 Additionally, the method @option{plink1} is provided, which calls
702 @samp{plink -1 -ssh} in order to use SSH protocol version 1
703 explicitely.
705 CCC: Do we have to connect to the remote host once from the command
706 line to accept the SSH key?  Maybe this can be made automatic?
708 CCC: Does @command{plink} support the @samp{-p} option?  @value{tramp} will
709 support that, anyway.
711 @end table
715 @node External transfer methods
716 @section External transfer methods
717 @cindex methods, external transfer
718 @cindex methods, out-of-band
719 @cindex external transfer methods
720 @cindex out-of-band methods
722 The external transfer methods operate through multiple channels, using
723 the remote shell connection for many actions while delegating file
724 transfers to an external transfer utility.
726 This saves the overhead of encoding and decoding that multiplexing the
727 transfer through the one connection has with the inline methods.
729 If you want to use an external transfer method you should be able to
730 execute the transfer utility to copy files to and from the remote
731 machine without any interaction.
733 @cindex ssh-agent
734 This means that you will need to use @command{ssh-agent} if you use the
735 @command{scp} program for transfers, or maybe your version of
736 @command{scp} accepts a password on the command line.@footnote{PuTTY's
737 @command{pscp} allows you to specify the password on the command line.}
738 If you use @command{rsync} via @command{ssh} then the same rule must
739 apply to that connection.
741 If you cannot get an external method to run without asking for a
742 password you should consider @ref{Password caching}.
745 @table @asis
746 @item @option{rcp}  ---  @command{rsh} and @command{rcp}
747 @cindex method rcp
748 @cindex rcp method
749 @cindex rcp (with rcp method)
750 @cindex rsh (with rcp method)
752 This method uses the @command{rsh} and @command{rcp} commands to connect
753 to the remote machine and transfer files.  This is probably the fastest
754 connection method available.
756 The alternative method @option{remcp} uses the @command{remsh} and
757 @command{rcp} commands.  It should be applied on machines where
758 @command{remsh} is used instead of @command{rsh}.
761 @item @option{scp}  ---  @command{ssh} and @command{scp}
762 @cindex method scp
763 @cindex scp method
764 @cindex scp (with scp method)
765 @cindex ssh (with scp method)
767 Using @command{ssh} to connect to the remote host and @command{scp} to
768 transfer files between the machines is the best method for securely
769 connecting to a remote machine and accessing files.
771 The performance of this option is also quite good. It may be slower than
772 the inline methods when you often open and close small files however.
773 The cost of the cryptographic handshake at the start of an @command{scp}
774 session can begin to absorb the advantage that the lack of encoding and
775 decoding presents.
777 There are also two variants, @option{scp1} and @option{scp2}, that
778 call @samp{ssh -1} and @samp{ssh -2}, respectively.  This way, you can
779 explicitly select whether you want to use the SSH protocol version 1
780 or 2 to connect to the remote host.  (You can also specify in
781 @file{~/.ssh/config}, the SSH configuration file, which protocol
782 should be used, and use the regular @option{scp} method.)
784 Two other variants, @option{scp1_old} and @option{scp2_old}, use the
785 @command{ssh1} and @command{ssh2} commands explicitly.  If you don't
786 know what these are, you do not need these options.
788 All the @command{ssh} based methods support the kludgy @samp{-p}
789 feature where you can specify a port number to connect to in the host
790 name.  For example, the host name @file{host#42} tells @value{tramp} to
791 specify @samp{-p 42} in the argument list for @command{ssh}.
794 @item @option{rsync}  ---  @command{ssh} and @command{rsync}
795 @cindex method rsync
796 @cindex rsync method
797 @cindex rsync (with rsync method)
798 @cindex ssh (with rsync method)
800 Using the @command{ssh} command to connect securely to the remote
801 machine and the @command{rsync} command to transfer files is almost
802 identical to the @option{scp} method.
804 While @command{rsync} performs much better than @command{scp} when
805 transferring files that exist on both hosts, this advantage is lost if
806 the file exists only on one side of the connection.
808 The @command{rsync} based method may be considerably faster than the
809 @command{rcp} based methods when writing to the remote system. Reading
810 files to the local machine is no faster than with a direct copy.
812 This method supports the @samp{-p} hack.
815 @item @option{scpx} --- @command{ssh} and @command{scp}
816 @cindex method scpx
817 @cindex scpx method
818 @cindex scp (with scpx method)
819 @cindex ssh (with scpx method)
820 @cindex Cygwin (with scpx method)
822 As you would expect, this is similar to @option{scp}, only a little
823 different.  Whereas @option{scp} opens a normal interactive shell on
824 the remote host, this option uses @samp{ssh -t -t @var{host} -l
825 @var{user} /bin/sh} to open a connection.  This is useful for users
826 where the normal login shell is set up to ask them a number of
827 questions when logging in.  This procedure avoids these questions, and
828 just gives @value{tramp} a more-or-less `standard' login shell to work
829 with.
831 This is also useful for Windows users where @command{ssh}, when
832 invoked from an @value{emacsname} buffer, tells them that it is not
833 allocating a pseudo tty.  When this happens, the login shell is wont
834 to not print any shell prompt, which confuses @value{tramp} mightily.
835 Maybe this applies to the Cygwin port of SSH.
837 This method supports the @samp{-p} hack.
840 @item @option{pscp} --- @command{plink} and @command{pscp}
841 @cindex method pscp
842 @cindex pscp method
843 @cindex pscp (with pscp method)
844 @cindex plink (with pscp method)
845 @cindex PuTTY (with pscp method)
847 This method is similar to @option{scp}, but it uses the
848 @command{plink} command to connect to the remote host, and it uses
849 @command{pscp} for transferring the files.  These programs are part
850 of PuTTY, an SSH implementation for Windows.
852 CCC: Does @command{plink} support the @samp{-p} hack?
855 @item @option{fcp} --- @command{fsh} and @command{fcp}
856 @cindex method fcp
857 @cindex fcp method
858 @cindex fsh (with fcp method)
859 @cindex fcp (with fcp method)
861 This method is similar to @option{scp}, but it uses the @command{fsh}
862 command to connect to the remote host, and it uses @command{fcp} for
863 transferring the files.  @command{fsh/fcp} are a front-end for
864 @command{ssh} which allow for reusing the same @command{ssh} session
865 for submitting several commands.  This avoids the startup overhead of
866 @command{scp} (which has to establish a secure connection whenever it
867 is called).  Note, however, that you can also use one of the inline
868 methods to achieve a similar effect.
870 This method uses the command @samp{fsh @var{host} -l @var{user}
871 /bin/sh -i} to establish the connection, it does not work to just say
872 @command{fsh @var{host} -l @var{user}}.
874 @cindex method fsh
875 @cindex fsh method
877 There is no inline method using @command{fsh} as the multiplexing
878 provided by the program is not very useful in our context.  @value{tramp}
879 opens just one connection to the remote host and then keeps it open,
880 anyway.
883 @item @option{ftp}
884 @cindex method ftp
885 @cindex ftp method
887 This is not a native @value{tramp} method. Instead of, it forwards all
888 requests to @value{ftppackagename}.
889 @ifset xemacs
890 This works only for unified filenames, see @ref{Issues}.
891 @end ifset
894 @item @option{smb} --- @command{smbclient}
895 @cindex method smb
896 @cindex smb method
898 This is another not natural @value{tramp} method.  It uses the
899 @command{smbclient} command on different Unices in order to connect to
900 an SMB server.  An SMB server might be a Samba (or CIFS) server on
901 another UNIX host or, more interesting, a host running MS Windows.  So
902 far, it is tested towards MS Windows NT, MS Windows 2000, and MS
903 Windows XP.
905 The first directory in the localname must be a share name on the remote
906 host.  Remember, that the @code{$} character in which default shares
907 usually end, must be written @code{$$} due to environment variable
908 substitution in file names.  If no share name is given (i.e. remote
909 directory @code{/}), all available shares are listed.
911 Since authorization is done on share level, you will be prompted
912 always for a password if you access another share on the same host.
913 This can be suppressed by @ref{Password caching}.
915 MS Windows uses for authorization both a user name and a domain name.
916 Because of this, the @value{tramp} syntax has been extended: you can
917 specify a user name which looks like @code{user%domain} (the real user
918 name, then a percent sign, then the domain name).  So, to connect to
919 the machine @code{melancholia} as user @code{daniel} of the domain
920 @code{BIZARRE}, and edit @file{.emacs} in the home directory (share
921 @code{daniel$}) I would specify the filename
922 @file{@value{prefix}smb@value{postfixsinglehop}daniel%BIZARRE@@melancholia@value{postfix}/daniel$$/.emacs}.
924 The domain name as well as the user name are optional.  If no user
925 name is specified at all, the anonymous user (without password
926 prompting) is assumed.  This is different from all other @value{tramp}
927 methods, where in such a case the local user name is taken.
929 The @option{smb} method supports the @samp{-p} hack.
931 @strong{Please note:} If @value{emacsname} runs locally under MS
932 Windows, this method isn't available.  Instead of, you can use UNC
933 file names like @file{//melancholia/daniel$$/.emacs}.  The only
934 disadvantage is that there's no possibility to specify another user
935 name.
937 @end table
939 @node Multi-hop Methods
940 @section Connecting to a remote host using multiple hops
941 @cindex multi-hop methods
942 @cindex methods, multi-hop
944 Sometimes, the methods described before are not sufficient.  Sometimes,
945 it is not possible to connect to a remote host using a simple command.
946 For example, if you are in a secured network, you might have to log in
947 to a `bastion host' first before you can connect to the outside world.
948 Of course, the target host may also require a bastion host.  The format
949 of multi-hop filenames is slightly different than the format of normal
950 @value{tramp} methods.
952 @cindex method multi
953 @cindex multi method
954 A multi-hop file name specifies a method, a number of hops, and a
955 localname (path name on the remote system).  The method name is always
956 @option{multi}.
958 Each hop consists of a @dfn{hop method} specification, a user name and
959 a host name.  The hop method can be an inline method only.  The
960 following hop methods are (currently) available:
962 @table @option
963 @item telnet
964 @cindex hop method telnet
965 @cindex telnet hop method
967 Uses the well-known @command{telnet} program to connect to the host.
968 Whereas user name and host name are supplied in the file name, the
969 user is queried for the password.
971 @item rsh
972 @cindex hop method rsh
973 @cindex rsh hop method
975 This uses @command{rsh} to connect to the host.  You do not need to
976 enter a password unless @command{rsh} explicitly asks for it.
978 The variant @option{remsh} uses the @command{remsh} command.  It
979 should be applied on machines where @command{remsh} is used instead of
980 @command{rsh}.
982 @item ssh
983 @cindex hop method ssh
984 @cindex ssh hop method
986 This uses @command{ssh} to connect to the host.  You might have to enter
987 a password or a pass phrase.
989 @item su
990 @cindex hop method su
991 @cindex su hop method
993 This method does not actually contact a different host, but it allows
994 you to become a different user on the host you're currently on.  This
995 might be useful if you want to edit files as root, but the remote host
996 does not allow remote root logins.  In this case you can use
997 @option{telnet}, @option{rsh} or @option{ssh} to connect to the
998 remote host as a non-root user, then use an @option{su} hop to become
999 root.  But @option{su} need not be the last hop in a sequence, you could
1000 also use it somewhere in the middle, if the need arises.
1002 Even though you @emph{must} specify both user and host with an
1003 @option{su} hop, the host name is ignored and only the user name is
1004 used.
1006 @item sudo
1007 @cindex hop method sudo
1008 @cindex sudo hop method
1010 This is similar to the @option{su} hop, except that it uses
1011 @command{sudo} rather than @command{su} to become a different user.
1013 @end table
1015 Some people might wish to use port forwarding with @command{ssh} or
1016 maybe they have to use a nonstandard port.  This can be accomplished
1017 by putting a stanza in @file{~/.ssh/config} for the account which
1018 specifies a different port number for a certain host name.  But it can
1019 also be accomplished within @value{tramp}, by adding a multi-hop method.
1020 For example:
1022 @lisp
1023 (add-to-list
1024  'tramp-multi-connection-function-alist
1025  '("sshf" tramp-multi-connect-rlogin "ssh %h -l %u -p 4400%n"))
1026 @end lisp
1028 Now you can use an @code{sshf} hop which connects to port 4400 instead of
1029 the standard port.
1032 @node Default Method
1033 @section Selecting a default method
1034 @cindex default method
1036 @vindex tramp-default-method
1037 When you select an appropriate transfer method for your typical usage
1038 you should set the variable @code{tramp-default-method} to reflect that
1039 choice.  This variable controls which method will be used when a method
1040 is not specified in the @value{tramp} file name.  For example:
1042 @lisp
1043 (setq tramp-default-method "scp")
1044 @end lisp
1046 @vindex tramp-default-method-alist
1047 You can also specify different methods for certain user/host
1048 combinations, via the variable @code{tramp-default-method-alist}.  For
1049 example, the following two lines specify to use the @option{ssh}
1050 method for all user names matching @samp{john} and the @option{rsync}
1051 method for all host names matching @samp{lily}.  The third line
1052 specifies to use the @option{su} method for the user @samp{root} on
1053 the machine @samp{localhost}.
1055 @lisp
1056 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1057 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1058 (add-to-list 'tramp-default-method-alist
1059              '("\\`localhost\\'" "\\`root\\'" "su"))
1060 @end lisp
1062 @noindent
1063 See the documentation for the variable
1064 @code{tramp-default-method-alist} for more details.
1066 External transfer methods are normally preferable to inline transfer
1067 methods, giving better performance.
1069 @xref{Inline methods}.
1070 @xref{External transfer methods}.
1071 @xref{Multi-hop Methods}.
1073 Another consideration with the selection of transfer methods is the
1074 environment you will use them in and, especially when used over the
1075 Internet, the security implications of your preferred method.
1077 The @command{rsh} and @command{telnet} methods send your password as
1078 plain text as you log in to the remote machine, as well as transferring
1079 the files in such a way that the content can easily be read from other
1080 machines.
1082 If you need to connect to remote systems that are accessible from the
1083 Internet, you should give serious thought to using @command{ssh} based
1084 methods to connect. These provide a much higher level of security,
1085 making it a non-trivial exercise for someone to obtain your password or
1086 read the content of the files you are editing.
1089 @subsection Which method is the right one for me?
1090 @cindex choosing the right method
1092 Given all of the above, you are probably thinking that this is all fine
1093 and good, but it's not helping you to choose a method!  Right you are.
1094 As a developer, we don't want to boss our users around but give them
1095 maximum freedom instead.  However, the reality is that some users would
1096 like to have some guidance, so here I'll try to give you this guidance
1097 without bossing you around.  You tell me whether it works @dots{}
1099 My suggestion is to use an inline method.  For large files, out-of-band
1100 methods might be more efficient, but I guess that most people will want
1101 to edit mostly small files.
1103 I guess that these days, most people can access a remote machine by
1104 using @code{ssh}.  So I suggest that you use the @code{ssh} method.
1105 So, type @kbd{C-x C-f
1106 @value{prefix}ssh@value{postfixsinglehop}root@@otherhost@value{postfix}/etc/motd
1107 @key{RET}} to edit the @file{/etc/motd} file on the other host.
1109 If you can't use @code{ssh} to log in to the remote host, then select a
1110 method that uses a program that works.  For instance, Windows users
1111 might like the @code{plink} method which uses the PuTTY implementation
1112 of @code{ssh}.  Or you use Kerberos and thus like @code{krlogin}.
1114 For the special case of editing files on the local host as another
1115 user, see the @code{su} or @code{sudo} method.  It offers shortened
1116 syntax for the @samp{root} account, like
1117 @file{@value{prefix}su@value{postfixsinglehop}@value{postfix}/etc/motd}.
1119 People who edit large files may want to consider @code{scp} instead of
1120 @code{ssh}, or @code{pscp} instead of @code{plink}.  These out-of-band
1121 methods are faster than inline methods for large files.  Note, however,
1122 that out-of-band methods suffer from some limitations.  Please try
1123 first whether you really get a noticeable speed advantage from using an
1124 out-of-band method!  Maybe even for large files, inline methods are
1125 fast enough.
1128 @node Customizing Methods
1129 @section Using Non-Standard Methods
1130 @cindex customizing methods
1131 @cindex using non-standard methods
1132 @cindex create your own methods
1134 There is a variable @code{tramp-methods} which you can change if the
1135 predefined methods don't seem right.
1137 For the time being, I'll refer you to the Lisp documentation of that
1138 variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
1141 @node Customizing Completion
1142 @section Selecting config files for user/host name completion
1143 @cindex customizing completion
1144 @cindex selecting config files
1145 @vindex tramp-completion-function-alist
1147 The variable @code{tramp-completion-function-alist} is intended to
1148 customize which files are taken into account for user and host name
1149 completion (@pxref{Filename completion}).  For every method, it keeps
1150 a set of configuration files, accompanied by a Lisp function able to
1151 parse that file.  Entries in @code{tramp-completion-function-alist}
1152 have the form (@var{method} @var{pair1} @var{pair2} ...).
1154 Each @var{pair} is composed of (@var{function} @var{file}).
1155 @var{function} is responsible to extract user names and host names
1156 from @var{file} for completion.  There are two functions which access
1157 this variable:
1159 @defun tramp-get-completion-function method
1160 This function returns the list of completion functions for @var{method}.
1162 Example:
1163 @example
1164 (tramp-get-completion-function "rsh")
1166      @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1167          (tramp-parse-rhosts "~/.rhosts"))
1168 @end example
1169 @end defun
1171 @defun tramp-set-completion-function method function-list
1172 This function sets @var{function-list} as list of completion functions
1173 for @var{method}.
1175 Example:
1176 @example
1177 (tramp-set-completion-function "ssh"
1178  '((tramp-parse-sconfig "/etc/ssh_config")
1179    (tramp-parse-sconfig "~/.ssh/config")))
1181      @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1182          (tramp-parse-sconfig "~/.ssh/config"))
1183 @end example
1184 @end defun
1186 The following predefined functions parsing configuration files exist:
1188 @table @asis
1189 @item @code{tramp-parse-rhosts}
1190 @findex tramp-parse-rhosts
1192 This function parses files which are syntactical equivalent to
1193 @file{~/.rhosts}.  It returns both host names and user names, if
1194 specified.
1196 @item @code{tramp-parse-shosts}
1197 @findex tramp-parse-shosts
1199 This function parses files which are syntactical equivalent to
1200 @file{~/.ssh/known_hosts}.  Since there are no user names specified
1201 in such files, it can return host names only.
1203 @item @code{tramp-parse-sconfig}
1204 @findex tramp-parse-shosts
1206 This function returns the host nicknames defined by @code{Host} entries
1207 in @file{~/.ssh/config} style files.
1209 @item @code{tramp-parse-shostkeys}
1210 @findex tramp-parse-shostkeys
1212 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1213 @file{~/ssh2/hostkeys/*}.  Hosts are coded in file names
1214 @file{hostkey_@var{portnumber}_@var{host-name}.pub}.  User names
1215 are always @code{nil}.
1217 @item @code{tramp-parse-sknownhosts}
1218 @findex tramp-parse-shostkeys
1220 Another SSH2 style parsing of directories like
1221 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}.  This
1222 case, hosts names are coded in file names
1223 @file{@var{host-name}.@var{algorithm}.pub}.  User names are always @code{nil}.
1225 @item @code{tramp-parse-hosts}
1226 @findex tramp-parse-hosts
1228 A function dedicated to @file{/etc/hosts} style files.  It returns
1229 host names only.
1231 @item @code{tramp-parse-passwd}
1232 @findex tramp-parse-passwd
1234 A function which parses @file{/etc/passwd} like files.  Obviously, it
1235 can return user names only.
1237 @item @code{tramp-parse-netrc}
1238 @findex tramp-parse-netrc
1240 Finally, a function which parses @file{~/.netrc} like files.
1241 @end table
1243 If you want to keep your own data in a file, with your own structure,
1244 you might provide such a function as well.  This function must meet
1245 the following conventions:
1247 @defun my-tramp-parse file
1248 @var{file} must be either a file name on your host, or @code{nil}. The
1249 function must return a list of (@var{user} @var{host}), which are
1250 taken as candidates for user and host name completion.
1252 Example:
1253 @example
1254 (my-tramp-parse "~/.my-tramp-hosts")
1256      @result{} ((nil "toto") ("daniel" "melancholia"))
1257 @end example
1258 @end defun
1261 @node Password caching
1262 @section Reusing passwords for several connections.
1263 @cindex passwords
1265 Sometimes it is necessary to connect to the same remote host several
1266 times.  Reentering passwords again and again would be annoying, when
1267 the choosen method does not support access without password prompt
1268 throught own configuration.
1270 By default, @value{tramp} caches the passwords entered by you.  They will
1271 be reused next time if a connection needs them for the same user name
1272 and host name, independant of the connection method.
1274 @vindex password-cache-expiry
1275 Passwords are not saved permanently, that means the password caching
1276 is limited to the lifetime of your @value{emacsname} session.  You
1277 can influence the lifetime of password caching by customizing the
1278 variable @code{password-cache-expiry}.  The value is the number of
1279 seconds how long passwords are cached.  Setting it to @code{nil}
1280 disables the expiration.
1282 @findex tramp-clear-passwd
1283 A password is removed from the cache if a connection isn't established
1284 successfully.  You can remove a password from the cache also by
1285 executing @kbd{M-x tramp-clear-passwd} in a buffer containing a
1286 related remote file or directory.
1288 @vindex password-cache
1289 If you don't like this feature for security reasons, password caching
1290 can be disabled totally by customizing the variable
1291 @code{password-cache} (setting it to @code{nil}).
1293 Implementation Note: password caching is based on the package
1294 password.el in No Gnus.  For the time being, it is activated only when
1295 this package is seen in the @code{load-path} while loading @value{tramp}.
1296 @ifset installchapter
1297 If you don't use No Gnus, you can take password.el from the @value{tramp}
1298 @file{contrib} directory, see @ref{Installation parameters}.
1299 @end ifset
1300 It will be activated mandatory once No Gnus has found its way into
1301 @value{emacsname}.
1304 @node Remote Programs
1305 @section How @value{tramp} finds and uses programs on the remote machine.
1307 @value{tramp} depends on a number of programs on the remote host in order to
1308 function, including @command{ls}, @command{test}, @command{find} and
1309 @command{cat}.
1311 In addition to these required tools, there are various tools that may be
1312 required based on the connection method. See @ref{Inline methods} and
1313 @ref{External transfer methods} for details on these.
1315 Certain other tools, such as @command{perl} (or @command{perl5}) and
1316 @command{grep} will be used if they can be found. When they are
1317 available, they are used to improve the performance and accuracy of
1318 remote file access.
1320 @vindex tramp-remote-path
1321 When @value{tramp} connects to the remote machine, it searches for the
1322 programs that it can use. The variable @var{tramp-remote-path} controls
1323 the directories searched on the remote machine.
1325 By default, this is set to a reasonable set of defaults for most
1326 machines. It is possible, however, that your local (or remote ;) system
1327 administrator has put the tools you want in some obscure local
1328 directory.
1330 In this case, you can still use them with @value{tramp}. You simply need to
1331 add code to your @file{.emacs} to add the directory to the remote path.
1332 This will then be searched by @value{tramp} when you connect and the software
1333 found.
1335 To add a directory to the remote search path, you could use code such
1338 @lisp
1339 @i{;; We load @value{tramp} to define the variable.}
1340 (require 'tramp)
1341 @i{;; We have @command{perl} in "/usr/local/perl/bin"}
1342 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1343 @end lisp
1346 @node Remote shell setup
1347 @comment  node-name,  next,  previous,  up
1348 @section Remote shell setup hints
1349 @cindex remote shell setup
1350 @cindex @file{.profile} file
1351 @cindex @file{.login} file
1352 @cindex shell init files
1354 As explained in the @ref{Overview} section, @value{tramp} connects to the
1355 remote host and talks to the shell it finds there.  Of course, when you
1356 log in, the shell executes its init files.  Suppose your init file
1357 requires you to enter the birth date of your mother; clearly @value{tramp}
1358 does not know this and hence fails to log you in to that host.
1360 There are different possible strategies for pursuing this problem.  One
1361 strategy is to enable @value{tramp} to deal with all possible situations.
1362 This is a losing battle, since it is not possible to deal with
1363 @emph{all} situations.  The other strategy is to require you to set up
1364 the remote host such that it behaves like @value{tramp} expects.  This might
1365 be inconvenient because you have to invest a lot of effort into shell
1366 setup before you can begin to use @value{tramp}.
1368 The package, therefore, pursues a combined approach.  It tries to figure
1369 out some of the more common setups, and only requires you to avoid
1370 really exotic stuff.  For example, it looks through a list of
1371 directories to find some programs on the remote host.  And also, it
1372 knows that it is not obvious how to check whether a file exists, and
1373 therefore it tries different possibilities.  (On some hosts and shells,
1374 the command @code{test -e} does the trick, on some hosts the shell
1375 builtin doesn't work but the program @code{/usr/bin/test -e} or
1376 @code{/bin/test -e} works.  And on still other hosts, @code{ls -d} is
1377 the right way to do this.)
1379 Below you find a discussion of a few things that @value{tramp} does not deal
1380 with, and that you therefore have to set up correctly.
1382 @table @asis
1383 @item @var{shell-prompt-pattern}
1384 @vindex shell-prompt-pattern
1386 After logging in to the remote host, @value{tramp} has to wait for the remote
1387 shell startup to finish before it can send commands to the remote
1388 shell.  The strategy here is to wait for the shell prompt.  In order to
1389 recognize the shell prompt, the variable @code{shell-prompt-pattern} has
1390 to be set correctly to recognize the shell prompt on the remote host.
1392 Note that @value{tramp} requires the match for @code{shell-prompt-pattern}
1393 to be at the end of the buffer.  Many people have something like the
1394 following as the value for the variable: @code{"^[^>$][>$] *"}.  Now
1395 suppose your shell prompt is @code{a <b> c $ }.  In this case,
1396 @value{tramp} recognizes the @code{>} character as the end of the prompt,
1397 but it is not at the end of the buffer.
1399 @item @var{tramp-shell-prompt-pattern}
1400 @vindex tramp-shell-prompt-pattern
1402 This regular expression is used by @value{tramp} in the same way as
1403 @code{shell-prompt-pattern}, to match prompts from the remote shell.
1404 This second variable exists because the prompt from the remote shell
1405 might be different from the prompt from a local shell --- after all,
1406 the whole point of @value{tramp} is to log in to remote hosts as a
1407 different user.  The default value of
1408 @code{tramp-shell-prompt-pattern} is the same as the default value of
1409 @code{shell-prompt-pattern}, which is reported to work well in many
1410 circumstances.
1412 @item @code{tset} and other questions
1413 @cindex Unix command tset
1414 @cindex tset Unix command
1416 Some people invoke the @code{tset} program from their shell startup
1417 scripts which asks the user about the terminal type of the shell.
1418 Maybe some shells ask other questions when they are started.  @value{tramp}
1419 does not know how to answer these questions.  There are two approaches
1420 for dealing with this problem.  One approach is to take care that the
1421 shell does not ask any questions when invoked from @value{tramp}.  You can
1422 do this by checking the @code{TERM} environment variable, it will be
1423 set to @code{dumb} when connecting.
1425 @vindex tramp-terminal-type
1426 The variable @code{tramp-terminal-type} can be used to change this value
1427 to @code{dumb}.
1429 The other approach is to teach @value{tramp} about these questions.  See
1430 the variables @code{tramp-actions-before-shell} and
1431 @code{tramp-multi-actions} (for multi-hop connections).
1434 @item Environment variables named like users in @file{.profile}
1436 If you have a user named frumple and set the variable @code{FRUMPLE} in
1437 your shell environment, then this might cause trouble.  Maybe rename
1438 the variable to @code{FRUMPLE_DIR} or the like.
1440 This weird effect was actually reported by a @value{tramp} user!
1443 @item Non-Bourne commands in @file{.profile}
1445 After logging in to the remote host, @value{tramp} issues the command
1446 @code{exec /bin/sh}.  (Actually, the command is slightly different.)
1447 When @code{/bin/sh} is executed, it reads some init files, such as
1448 @file{~/.shrc} or @file{~/.profile}.
1450 Now, some people have a login shell which is not @code{/bin/sh} but a
1451 Bourne-ish shell such as bash or ksh.  Some of these people might put
1452 their shell setup into the files @code{~/.shrc} or @code{~/.profile}.
1453 This way, it is possible for non-Bourne constructs to end up in those
1454 files.  Then, @code{exec /bin/sh} might cause the Bourne shell to barf
1455 on those constructs.
1457 As an example, imagine somebody putting @code{export FOO=bar} into the
1458 file @file{~/.profile}.  The standard Bourne shell does not understand
1459 this syntax and will emit a syntax error when it reaches this line.
1461 Another example is the tilde (@code{~}) character, say when adding
1462 @file{~/bin} to @code{$PATH}.  Many Bourne shells will not expand this
1463 character, and since there is usually no directory whose name consists
1464 of the single character tilde, strange things will happen.
1466 What can you do about this?
1468 Well, one possibility is to make sure that everything in @file{~/.shrc}
1469 and @file{~/.profile} on all remote hosts is Bourne-compatible.  In the
1470 above example, instead of @code{export FOO=bar}, you might use
1471 @code{FOO=bar; export FOO} instead.
1473 The other possibility is to put your non-Bourne shell setup into some
1474 other files.  For example, bash reads the file @file{~/.bash_profile}
1475 instead of @file{~/.profile}, if the former exists.  So bash
1476 aficionados just rename their @file{~/.profile} to
1477 @file{~/.bash_profile} on all remote hosts, and Bob's your uncle.
1479 The @value{tramp} developers would like to circumvent this problem, so if you
1480 have an idea about it, please tell us.  However, we are afraid it is not
1481 that simple: before saying @code{exec /bin/sh}, @value{tramp} does not know
1482 which kind of shell it might be talking to.  It could be a Bourne-ish
1483 shell like ksh or bash, or it could be a csh derivative like tcsh, or
1484 it could be zsh, or even rc.  If the shell is Bourne-ish already, then
1485 it might be prudent to omit the @code{exec /bin/sh} step.  But how to
1486 find out if the shell is Bourne-ish?
1488 @end table
1491 @node Auto-save and Backup
1492 @section Auto-save and Backup configuration
1493 @cindex auto-save
1494 @cindex backup
1495 @ifset emacs
1496 @vindex backup-directory-alist
1497 @end ifset
1498 @ifset xemacs
1499 @vindex bkup-backup-directory-info
1500 @end ifset
1502 Normally, @value{emacsname} writes backup files to the same directory
1503 as the original files, but this behavior can be changed via the
1504 variable
1505 @ifset emacs
1506 @code{backup-directory-alist}.
1507 @end ifset
1508 @ifset xemacs
1509 @code{bkup-backup-directory-info}.
1510 @end ifset
1511 In connection with @value{tramp}, this can have unexpected side effects.
1512 Suppose that you specify that all backups should go to the directory
1513 @file{~/.emacs.d/backups/}, and then you edit the file
1514 @file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}/etc/secretfile}.
1515 The effect is that the backup file will be owned by you and not by
1516 root, thus possibly enabling others to see it even if they were not
1517 intended to see it.
1519 When
1520 @ifset emacs
1521 @code{backup-directory-alist}
1522 @end ifset
1523 @ifset xemacs
1524 @code{bkup-backup-directory-info}
1525 @end ifset
1526 is @code{nil} (the default), such problems do not occur.
1528 Therefore, it is usefull to set special values for @value{tramp}
1529 files.  For example, the following statement effectively `turns off'
1530 the effect of
1531 @ifset emacs
1532 @code{backup-directory-alist}
1533 @end ifset
1534 @ifset xemacs
1535 @code{bkup-backup-directory-info}
1536 @end ifset
1537 for @value{tramp} files:
1539 @ifset emacs
1540 @lisp
1541 (add-to-list 'backup-directory-alist
1542              (cons tramp-file-name-regexp nil))
1543 @end lisp
1544 @end ifset
1545 @ifset xemacs
1546 @lisp
1547 (require 'backup-dir)
1548 (add-to-list 'bkup-backup-directory-info
1549              (list tramp-file-name-regexp ""))
1550 @end lisp
1551 @end ifset
1553 Another possibility is to use the @value{tramp} variable
1554 @ifset emacs
1555 @code{tramp-backup-directory-alist}.
1556 @end ifset
1557 @ifset xemacs
1558 @code{tramp-bkup-backup-directory-info}.
1559 @end ifset
1560 This variable has the same meaning like
1561 @ifset emacs
1562 @code{backup-directory-alist}.
1563 @end ifset
1564 @ifset xemacs
1565 @code{bkup-backup-directory-info}.
1566 @end ifset
1567 If a @value{tramp} file is backed up, and DIRECTORY is an absolute
1568 local file name, DIRECTORY is prepended with the @value{tramp} file
1569 name prefix of the file to be backed up.
1571 @noindent
1572 Example:
1574 @ifset emacs
1575 @lisp
1576 (add-to-list 'backup-directory-alist
1577              (cons "." "~/.emacs.d/backups/"))
1578 (setq tramp-backup-directory-alist backup-directory-alist)
1579 @end lisp
1580 @end ifset
1581 @ifset xemacs
1582 @lisp
1583 (require 'backup-dir)
1584 (add-to-list 'bkup-backup-directory-info
1585              (list "." "~/.emacs.d/backups/" 'full-path))
1586 (setq tramp-bkup-backup-directory-info bkup-backup-directory-info)
1587 @end lisp
1588 @end ifset
1590 @noindent
1591 The backup file name of
1592 @file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}/etc/secretfile}
1593 would be
1594 @ifset emacs
1595 @file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}
1596 @end ifset
1597 @ifset xemacs
1598 @file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}~/.emacs.d/backups/![su!root@@localhost]!etc!secretfile~}
1599 @end ifset
1601 The same problem can happen with auto-saving files.
1602 @ifset emacs
1603 Since @value{emacsname} 21, the variable
1604 @code{auto-save-file-name-transforms} keeps information, on which
1605 directory an auto-saved file should go.  By default, it is initialized
1606 for @value{tramp} files to the local temporary directory.
1608 On some versions of @value{emacsname}, namely the version built for
1609 Debian GNU/Linux, the variable @code{auto-save-file-name-transforms}
1610 contains the directory where @value{emacsname} was built.  A
1611 workaround is to manually set the variable to a sane value.
1613 If auto-saved files should go into the same directory as the original
1614 files, @code{auto-save-file-name-transforms} should be set to @code{nil}.
1616 Another possibility is to set the variable
1617 @code{tramp-auto-save-directory} to a proper value.
1618 @end ifset
1619 @ifset xemacs
1620 For this purpose you can set the variable @code{auto-save-directory}
1621 to a proper value.
1622 @end ifset
1625 @node Windows setup hints
1626 @section Issues with Cygwin ssh
1627 @cindex Cygwin, issues
1629 This section needs a lot of work!  Please help.
1631 @cindex method sshx with Cygwin
1632 @cindex sshx method with Cygwin
1633 If you use the Cygwin installation of ssh (you have to explicitly select
1634 it in the installer), then it should work out of the box to just select
1635 @code{sshx} as the connection method.  You can find information about
1636 setting up Cygwin in their FAQ at @uref{http://cygwin.com/faq/}.
1638 @cindex method scpx with Cygwin
1639 @cindex scpx method with Cygwin
1640 If you wish to use the @code{scpx} connection method, then you might
1641 have the problem that @value{emacsname} calls @code{scp} with a
1642 Windows filename such as @code{c:/foo}.  The Cygwin version of
1643 @code{scp} does not know about Windows filenames and interprets this
1644 as a remote filename on the host @code{c}.
1646 One possible workaround is to write a wrapper script for @code{scp}
1647 which converts the Windows filename to a Cygwinized filename.
1649 I guess that another workaround is to run @value{emacsname} under
1650 Cygwin, or to run a Cygwinized @value{emacsname}.
1652 @cindex Cygwin and ssh-agent
1653 @cindex SSH_AUTH_SOCK and @value{emacsname} on Windows
1654 If you want to use either @code{ssh} based method on Windows, then you
1655 might encounter problems with @code{ssh-agent}.  Using this program,
1656 you can avoid typing the pass-phrase every time you log in.  However,
1657 if you start @value{emacsname} from a desktop shortcut, then the
1658 environment variable @code{SSH_AUTH_SOCK} is not set and so
1659 @value{emacsname} and thus @value{tramp} and thus @code{ssh} and
1660 @code{scp} started from @value{tramp} cannot communicate with
1661 @code{ssh-agent}.  It works better to start @value{emacsname} from
1662 the shell.
1664 If anyone knows how to start @code{ssh-agent} under Windows in such a
1665 way that desktop shortcuts can profit, please holler.  I don't really
1666 know anything at all about Windows@dots{}
1669 @node Usage
1670 @chapter Using @value{tramp}
1671 @cindex using @value{tramp}
1673 Once you have installed @value{tramp} it will operate fairly transparently. You
1674 will be able to access files on any remote machine that you can log in
1675 to as though they were local.
1677 Files are specified to @value{tramp} using a formalized syntax specifying the
1678 details of the system to connect to.  This is similar to the syntax used
1679 by the @value{ftppackagename} package.
1681 @cindex type-ahead
1682 Something that might happen which surprises you is that
1683 @value{emacsname} remembers all your keystrokes, so if you see a
1684 password prompt from @value{emacsname}, say, and hit @kbd{@key{RET}}
1685 twice instead of once, then the second keystroke will be processed by
1686 @value{emacsname} after @value{tramp} has done its thing.  Why, this
1687 type-ahead is normal behavior, you say.  Right you are, but be aware
1688 that opening a remote file might take quite a while, maybe half a
1689 minute when a connection needs to be opened.  Maybe after half a
1690 minute you have already forgotten that you hit that key!
1692 @menu
1693 * Filename Syntax::             @value{tramp} filename conventions.
1694 * Multi-hop filename syntax::   Multi-hop filename conventions.
1695 * Filename completion::         Filename completion.
1696 * Dired::                       Dired.
1697 * Compilation::                 Compile remote files.
1698 @end menu
1701 @node Filename Syntax
1702 @section @value{tramp} filename conventions
1703 @cindex filename syntax
1704 @cindex filename examples
1706 To access the file @var{localname} on the remote machine @var{machine} you
1707 would specify the filename
1708 @file{@value{prefix}@var{machine}@value{postfix}@var{localname}}.
1709 This will connect to @var{machine} and transfer the file using the
1710 default method.  @xref{Default Method}.
1712 Some examples of @value{tramp} filenames are shown below.
1714 @table @file
1715 @item @value{prefix}melancholia@value{postfix}.emacs
1716 Edit the file @file{.emacs} in your home directory on the machine
1717 @code{melancholia}.
1719 @item @value{prefix}melancholia.danann.net@value{postfix}.emacs
1720 This edits the same file, using the fully qualified domain name of
1721 the machine.
1723 @item @value{prefix}melancholia@value{postfix}~/.emacs
1724 This also edits the same file --- the @file{~} is expanded to your
1725 home directory on the remote machine, just like it is locally.
1727 @item @value{prefix}melancholia@value{postfix}~daniel/.emacs
1728 This edits the file @file{.emacs} in the home directory of the user
1729 @code{daniel} on the machine @code{melancholia}. The @file{~<user>}
1730 construct is expanded to the home directory of that user on the remote
1731 machine.
1733 @item @value{prefix}melancholia@value{postfix}/etc/squid.conf
1734 This edits the file @file{/etc/squid.conf} on the machine
1735 @code{melancholia}.
1737 @end table
1739 Unless you specify a different name to use, @value{tramp} will use the
1740 current local user name as the remote user name to log in with. If you
1741 need to log in as a different user, you can specify the user name as
1742 part of the filename.
1744 To log in to the remote machine as a specific user, you use the syntax
1745 @file{@value{prefix}@var{user}@@@var{machine}@value{postfix}/@var{path/to.file}}.
1746 That means that connecting to @code{melancholia} as @code{daniel} and
1747 editing @file{.emacs} in your home directory you would specify
1748 @file{@value{prefix}daniel@@melancholia@value{postfix}.emacs}.
1750 It is also possible to specify other file transfer methods
1751 (@pxref{Default Method}) as part of the filename.
1752 @ifset emacs
1753 This is done by putting the method before the user and host name, as
1755 @file{@value{prefix}@var{method}@value{postfixsinglehop}}
1756 (Note the trailing colon).
1757 @end ifset
1758 @ifset xemacs
1759 This is done by replacing the initial
1760 @file{@value{prefix}} with
1761 @file{@value{prefix}<method>@value{postfixsinglehop}}.
1762 (Note the trailing slash!).
1763 @end ifset
1764 The user, machine and file specification remain the same.
1766 So, to connect to the machine @code{melancholia} as @code{daniel},
1767 using the @option{ssh} method to transfer files, and edit @file{.emacs}
1768 in my home directory I would specify the filename
1769 @file{@value{prefix}ssh@value{postfixsinglehop}daniel@@melancholia@value{postfix}.emacs}.
1772 @node Multi-hop filename syntax
1773 @section Multi-hop filename conventions
1774 @cindex filename syntax for multi-hop files
1775 @cindex multi-hop filename syntax
1777 The syntax of multi-hop file names is necessarily slightly different
1778 than the syntax of other @value{tramp} file names.  Here's an example
1779 multi-hop file name:
1781 @example
1782 @value{prefix}multi@value{postfixsinglehop}rsh@value{postfixmultihop}out@@gate@value{postfixsinglehop}telnet@value{postfixmultihop}kai@@real.host@value{postfix}/path/to.file
1783 @end example
1785 This is quite a mouthful.  So let's go through it step by step.  The
1786 file name consists of three parts.
1787 @ifset emacs
1788 The parts are separated by colons
1789 @end ifset
1790 @ifset xemacs
1791 The parts are separated by slashes and square brackets.
1792 @end ifset
1793 The first part is @file{@value{prefix}multi}, the method
1794 specification.  The second part is
1795 @file{rsh@value{postfixmultihop}out@@gate@value{postfixsinglehop}telnet@value{postfixmultihop}kai@@real.host}
1796 and specifies the hops.  The final part is @file{/path/to.file} and
1797 specifies the file name on the remote host.
1799 The first part and the final part should be clear.  See @ref{Multi-hop
1800 Methods}, for a list of alternatives for the method specification.
1802 The second part can be subdivided again into components, so-called
1803 hops.  In the above file name, there are two hops,
1804 @file{rsh@value{postfixmultihop}out@@gate} and
1805 @file{telnet@value{postfixmultihop}kai@@real.host}.
1807 Each hop can @emph{again} be subdivided into (three) components, the
1808 @dfn{hop method}, the @dfn{user name} and the @dfn{host name}.  The
1809 meaning of the second and third component should be clear, and the hop
1810 method says what program to use to perform that hop.
1812 The first hop, @file{rsh@value{postfixmultihop}out@@gate},
1813 says to use @command{rsh} to log in as user @code{out} to the host
1814 @code{gate}.  Starting at that host, the second hop,
1815 @file{telnet@value{postfixmultihop}kai@@real.host}, says to
1816 use @command{telnet} to log in as user @code{kai} to host
1817 @code{real.host}.
1819 @xref{Multi-hop Methods}, for a list of possible hop method values.
1820 The variable @code{tramp-multi-connection-function-alist} contains the
1821 list of possible hop methods and information on how to execute them,
1822 should you want to add your own.
1825 @node Filename completion
1826 @section Filename completion
1827 @cindex filename completion
1829 Filename completion works with @value{tramp} for both completing methods,
1830 user names and machine names (except multi hop methods) as well as for
1831 files on remote machines.
1833 If you, for example, type @kbd{C-x C-f @value{prefix}t
1834 @key{TAB}}, @value{tramp} might give you as result the choice for
1836 @example
1837 @ifset emacs
1838 @value{prefixsinglehop}telnet@value{postfixsinglehop}                              tmp/
1839 @value{prefixsinglehop}toto@value{postfix}
1840 @end ifset
1841 @ifset xemacs
1842 @value{prefixsinglehop}telnet@value{postfixsinglehop}                              @value{prefixsinglehop}toto@value{postfix}
1843 @end ifset
1844 @end example
1846 @samp{@value{prefixsinglehop}telnet@value{postfixsinglehop}}
1847 is a possible completion for the respective method,
1848 @ifset emacs
1849 @samp{tmp/} stands for the directory @file{/tmp} on your local
1850 machine,
1851 @end ifset
1852 and @samp{@value{prefixsinglehop}toto@value{postfix}}
1853 might be a host @value{tramp} has detected in your @file{~/.ssh/known_hosts}
1854 file (given you're using default method @option{ssh}).
1856 If you go on to type @kbd{e @key{TAB}}, the minibuffer is completed to
1857 @samp{@value{prefix}telnet@value{postfixsinglehop}}.
1858 Next @kbd{@key{TAB}} brings you all machine names @value{tramp} detects in
1859 your @file{/etc/hosts} file, let's say
1861 @example
1862 @value{prefixsinglehop}telnet@value{postfixsinglehop}127.0.0.1@value{postfix}              @value{prefixsinglehop}telnet@value{postfixsinglehop}192.168.0.1@value{postfix}
1863 @value{prefixsinglehop}telnet@value{postfixsinglehop}localhost@value{postfix}              @value{prefixsinglehop}telnet@value{postfixsinglehop}melancholia.danann.net@value{postfix}
1864 @value{prefixsinglehop}telnet@value{postfixsinglehop}melancholia@value{postfix}
1865 @end example
1867 Now you can choose the desired machine, and you can continue to
1868 complete file names on that machine.
1870 As filename completion needs to fetch the listing of files from the
1871 remote machine, this feature is sometimes fairly slow.  As @value{tramp}
1872 does not yet cache the results of directory listing, there is no gain
1873 in performance the second time you complete filenames.
1875 If the configuration files (@pxref{Customizing Completion}), which
1876 @value{tramp} uses for analysis of completion, offer user names, those user
1877 names will be taken into account as well.
1880 @node Dired
1881 @section Dired
1882 @cindex dired
1884 @value{tramp} works transparently with dired, enabling you to use this powerful
1885 file management tool to manage files on any machine you have access to
1886 over the Internet.
1888 If you need to browse a directory tree, Dired is a better choice, at
1889 present, than filename completion.  Dired has its own cache mechanism
1890 and will only fetch the directory listing once.
1893 @node Compilation
1894 @section Compile remote files
1895 @cindex compile
1896 @cindex recompile
1898 @value{tramp} provides commands for compilation of files on remote
1899 machines.  In order to get them loaded, you need to require
1900 @file{tramp-util.el}:
1902 @lisp
1903 (require 'tramp-util)
1904 @end lisp
1906 Afterwards, you can use the commands @code{tramp-compile} and
1907 @code{tramp-recompile} instead of @code{compile} and @code{recompile},
1908 respectively; @inforef{Compilation, ,@value{emacsdir}}.  This does not
1909 work for the @option{ftp} and @option{smb} methods.
1911 The corresponding key bindings and menu entries calling these commands
1912 are redefined automatically for buffers associated with remote files.
1914 After finishing the compilation, you can use the usual commands like
1915 @code{previous-error}, @code{next-error} and @code{first-error} for
1916 navigation in the @file{*Compilation*} buffer.
1919 @node Bug Reports
1920 @chapter Reporting Bugs and Problems
1921 @cindex bug reports
1923 Bugs and problems with @value{tramp} are actively worked on by the development
1924 team. Feature requests and suggestions are also more than welcome.
1926 The @value{tramp} mailing list is a great place to get information on working
1927 with @value{tramp}, solving problems and general discussion and advice on topics
1928 relating to the package.
1930 The mailing list is at @email{tramp-devel@@gnu.org}.  Messages sent to
1931 this address go to all the subscribers. This is @emph{not} the address
1932 to send subscription requests to.
1934 Subscribing to the list is performed via
1935 @uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/,
1936 the @value{tramp} Mail Subscription Page}.
1938 To report a bug in @value{tramp}, you should execute @kbd{M-x tramp-bug}. This
1939 will automatically generate a buffer with the details of your system and
1940 @value{tramp} version.
1942 When submitting a bug report, please try to describe in excruciating
1943 detail the steps required to reproduce the problem, the setup of the
1944 remote machine and any special conditions that exist.
1946 If you can identify a minimal test case that reproduces the problem,
1947 include that with your bug report. This will make it much easier for the
1948 development team to analyze and correct the problem.
1950 @node Frequently Asked Questions
1951 @chapter Frequently Asked Questions
1952 @cindex frequently asked questions
1953 @cindex FAQ
1955 @itemize @bullet
1956 @item
1957 Where can I get the latest @value{tramp}?
1959 @value{tramp} is available under the URL below.
1961 @noindent
1962 @uref{http://ftp.gnu.org/gnu/tramp/}
1964 @noindent
1965 There is also a Savannah project page.
1967 @noindent
1968 @uref{http://savannah.gnu.org/projects/tramp/}
1970 @item
1971 Which systems does it work on?
1973 The package has been used successfully on GNU Emacs 20, GNU Emacs 21
1974 and GNU Emacs 22, as well as XEmacs 21.  XEmacs 20 is more
1975 problematic, see the notes in @file{tramp.el}.  I don't think anybody
1976 has really tried it on GNU Emacs 19.
1978 The package was intended to work on Unix, and it really expects a
1979 Unix-like system on the remote end (except the @option{smb} method),
1980 but some people seemed to have some success getting it to work on MS
1981 Windows NT/2000/XP @value{emacsname}.
1983 There is some informations on @value{tramp} on NT at the following URL;
1984 many thanks to Joe Stoy for providing the information:
1985 @uref{ftp://ftp.comlab.ox.ac.uk/tmp/Joe.Stoy/}
1987 @c The link is broken. I've contacted Tom for clarification. Michael.
1988 @ignore
1989 The above mostly contains patches to old ssh versions; Tom Roche has a
1990 Web page with instructions:
1991 @uref{http://www4.ncsu.edu/~tlroche/plinkTramp.html}
1992 @end ignore
1994 ??? Is the XEmacs info correct?
1996 ??? Can somebody provide some information for getting it to work on NT
1997 Emacs?  I think there was some issue with @command{ssh}?
2000 @item
2001 I can't stop @value{ftppackagename} starting with @value{emacsname}
2003 @ifset emacs
2004 @value{ftppackagename} is loaded from @value{tramp} automatically if you
2005 require a file by the ftp method.  Unfortunately, there are some Lisp
2006 packages which make @value{ftppackagename} file name handlers active.
2007 You can see it applying @kbd{C-h v file-name-handler-alist}:
2009 @example
2010 file-name-handler-alist's value is
2011 (("^/[^/:]*\\'" . ange-ftp-completion-hook-function)
2012  ("^/[^/:]*[^/:.]:" . ange-ftp-hook-function)
2013  ("^/[^/]*$" . tramp-completion-file-name-handler)
2014  ("\\`/[^/:]+:" . tramp-file-name-handler)
2015  ("\\`/:" . file-name-non-special))
2016 @end example
2018 Please try to find out which package is responsible for loading
2019 @value{ftppackagename}, and raise a bug report.
2021 A workaround is to require @value{ftppackagename} before @value{tramp} in
2022 your @file{~/.emacs}, because @value{tramp} cleans up the entries in
2023 @code{file-name-handler-alist}:
2025 @lisp
2026 ;; @value{ftppackagename} temporarily required
2027 (require 'ange-ftp)
2028 ;; @value{tramp} cleans up @code{file-name-handler-alist}
2029 (require 'tramp)
2030 @end lisp
2031 @end ifset
2033 @ifset xemacs
2034 Not all the older versions of @value{tramp} supported @value{emacsname}
2035 correctly.  The first thing to do is to make sure that you have the
2036 latest version of @value{tramp} installed.
2038 If you do, please try and find out exactly the conditions required for
2039 the @value{ftppackagename} handlers to fire.  If you can, putting a
2040 breakpoint on @code{efs-ftp-path} and sending in the stack trace along
2041 with your bug report would make it easier for the developers to work out
2042 what is going wrong.
2043 @end ifset
2046 @item
2047 File name completion does not work with @value{tramp}
2049 When you log in to the remote machine, do you see the output of
2050 @command{ls} in color? If so, this may be the cause of your problems.
2052 @command{ls} outputs @acronym{ANSI} escape sequences that your terminal
2053 emulator interprets to set the colors.  These escape sequences will
2054 confuse @value{tramp} however.
2056 In your @file{.bashrc}, @file{.profile} or equivalent on the remote
2057 machine you probably have an alias configured that adds the option
2058 @option{--color=yes} or @option{--color=auto}.
2060 You should remove that alias and ensure that a new login @emph{does not}
2061 display the output of @command{ls} in color.  If you still cannot use
2062 filename completion, report a bug to the @value{tramp} developers.
2065 @item
2066 File name completion does not work in large directories
2068 @value{tramp} uses globbing for some operations.  (Globbing means to use the
2069 shell to expand wildcards such as `*.c'.)  This might create long
2070 command lines, especially in directories with many files.  Some shells
2071 choke on long command lines, or don't cope well with the globbing
2072 itself.
2074 If you have a large directory on the remote end, you may wish to execute
2075 a command like @samp{ls -d * ..?* > /dev/null} and see if it hangs.
2076 Note that you must first start the right shell, which might be
2077 @command{/bin/sh}, @command{ksh} or @command{bash}, depending on which
2078 of those supports tilde expansion.
2081 @item
2082 How can I get notified when @value{tramp} file transfers are complete?
2084 The following snippet can be put in your @file{~/.emacs} file.  It
2085 makes @value{emacsname} beep after reading from or writing to the
2086 remote host.
2088 @lisp
2089 (defadvice tramp-handle-write-region
2090   (after tramp-write-beep-advice activate)
2091  " make tramp beep after writing a file."
2092  (interactive)
2093  (beep))
2094 (defadvice tramp-handle-do-copy-or-rename-file
2095   (after tramp-copy-beep-advice activate)
2096  " make tramp beep after copying a file."
2097  (interactive)
2098  (beep))
2099 (defadvice tramp-handle-insert-file-contents
2100   (after tramp-copy-beep-advice activate)
2101  " make tramp beep after copying a file."
2102  (interactive)
2103  (beep))
2104 @end lisp
2107 @item
2108 There's this @file{~/.sh_history} file on the remote host which keeps
2109 growing and growing.  What's that?
2111 Sometimes, @value{tramp} starts @code{ksh} on the remote host for tilde
2112 expansion.  Maybe @code{ksh} saves the history by default.  @value{tramp}
2113 tries to turn off saving the history, but maybe you have to help.  For
2114 example, you could put this in your @file{.kshrc}:
2116 @example
2117 if [ -f $HOME/.sh_history ] ; then
2118    /bin/rm $HOME/.sh_history
2120 if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
2121    unset HISTFILE
2123 if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
2124    unset HISTSIZE
2126 @end example
2129 @item
2130 @value{tramp} doesn't transfer strings with more than 500 characters
2131 correctly
2133 On some few systems, the implementation of @code{process-send-string}
2134 seems to be broken for longer strings.  This case, you should
2135 customize the variable @code{tramp-chunksize} to 500.  For a
2136 description how to determine whether this is necessary see the
2137 documentation of @code{tramp-chunksize}.
2138 @end itemize
2141 @c For the developer
2142 @node Version Control
2143 @chapter The inner workings of remote version control
2144 @cindex Version Control
2146 Unlike @value{ftppackagename}, @value{tramp} has full shell access to the
2147 remote machine. This makes it possible to provide version control for
2148 files accessed under @value{tramp}.
2150 The actual version control binaries must be installed on the remote
2151 machine, accessible in the directories specified in
2152 @var{tramp-remote-path}.
2154 This transparent integration with the version control systems is one of
2155 the most valuable features provided by @value{tramp}, but it is far from perfect.
2156 Work is ongoing to improve the transparency of the system.
2158 @menu
2159 * Version Controlled Files::    Determining if a file is under version control.
2160 * Remote Commands::             Executing the version control commands on the remote machine.
2161 * Changed workfiles::           Detecting if the working file has changed.
2162 * Checking out files::          Bringing the workfile out of the repository.
2163 * Miscellaneous Version Control::  Things related to Version Control that don't fit elsewhere.
2164 @end menu
2167 @node Version Controlled Files
2168 @section Determining if a file is under version control
2170 The VC package uses the existence of on-disk revision control master
2171 files to determine if a given file is under revision control. These file
2172 tests happen on the remote machine through the standard @value{tramp} mechanisms.
2175 @node Remote Commands
2176 @section Executing the version control commands on the remote machine
2178 There are no hooks provided by VC to allow intercepting of the version
2179 control command execution. The calls occur through the
2180 @code{call-process} mechanism, a function that is somewhat more
2181 efficient than the @code{shell-command} function but that does not
2182 provide hooks for remote execution of commands.
2184 To work around this, the functions @code{vc-do-command} and
2185 @code{vc-simple-command} have been advised to intercept requests for
2186 operations on files accessed via @value{tramp}.
2188 In the case of a remote file, the @code{shell-command} interface is
2189 used, with some wrapper code, to provide the same functionality on the
2190 remote machine as would be seen on the local machine.
2193 @node Changed workfiles
2194 @section Detecting if the working file has changed
2196 As there is currently no way to get access to the mtime of a file on a
2197 remote machine in a portable way, the @code{vc-workfile-unchanged-p}
2198 function is advised to call an @value{tramp} specific function for remote files.
2200 The @code{tramp-vc-workfile-unchanged-p} function uses the functioning VC
2201 diff functionality to determine if any changes have occurred between the
2202 workfile and the version control master.
2204 This requires that a shell command be executed remotely, a process that
2205 is notably heavier-weight than the mtime comparison used for local
2206 files. Unfortunately, unless a portable solution to the issue is found,
2207 this will remain the cost of remote version control.
2210 @node Checking out files
2211 @section Bringing the workfile out of the repository
2213 VC will, by default, check for remote files and refuse to act on them
2214 when checking out files from the repository. To work around this
2215 problem, the function @code{vc-checkout} knows about @value{tramp} files and
2216 allows version control to occur.
2219 @node Miscellaneous Version Control
2220 @section Things related to Version Control that don't fit elsewhere
2222 Minor implementation details, &c.
2224 @menu
2225 * Remote File Ownership::       How VC determines who owns a workfile.
2226 * Back-end Versions::           How VC determines what release your RCS is.
2227 @end menu
2230 @node Remote File Ownership
2231 @subsection How VC determines who owns a workfile
2233 @value{emacsname} provides the @code{user-full-name} function to
2234 return the login name of the current user as well as mapping from
2235 arbitrary user id values back to login names. The VC code uses this
2236 functionality to map from the uid of the owner of a workfile to the
2237 login name in some circumstances.
2239 This will not, for obvious reasons, work if the remote system has a
2240 different set of logins. As such, it is necessary to delegate to the
2241 remote machine the job of determining the login name associated with a
2242 uid.
2244 Unfortunately, with the profusion of distributed management systems such
2245 as @code{NIS}, @code{NIS+} and @code{NetInfo}, there is no simple,
2246 reliable and portable method for performing this mapping.
2248 Thankfully, the only place in the VC code that depends on the mapping of
2249 a uid to a login name is the @code{vc-file-owner} function. This returns
2250 the login of the owner of the file as a string.
2252 This function has been advised to use the output of @command{ls} on the
2253 remote machine to determine the login name, delegating the problem of
2254 mapping the uid to the login to the remote system which should know more
2255 about it than I do.
2258 @node Back-end Versions
2259 @subsection How VC determines what release your RCS is
2261 VC needs to know what release your revision control binaries you are
2262 running as not all features VC supports are available with older
2263 versions of @command{rcs(1)}, @command{cvs(1)} or @command{sccs(1)}.
2265 The default implementation of VC determines this value the first time it
2266 is needed and then stores the value globally to avoid the overhead of
2267 executing a process and parsing its output each time the information is
2268 needed.
2270 Unfortunately, life is not quite so easy when remote version control
2271 comes into the picture. Each remote machine may have a different version
2272 of the version control tools and, while this is painful, we need to
2273 ensure that unavailable features are not used remotely.
2275 To resolve this issue, @value{tramp} currently takes the sledgehammer
2276 approach of making the release values of the revision control tools
2277 local to each @value{tramp} buffer, forcing VC to determine these values
2278 again each time a new file is visited.
2280 This has, quite obviously, some performance implications. Thankfully,
2281 most of the common operations performed by VC do not actually require
2282 that the remote version be known. This makes the problem far less
2283 apparent.
2285 Eventually these values will be captured by @value{tramp} on a system by
2286 system basis and the results cached to improve performance.
2289 @node Files directories and localnames
2290 @chapter How file names, directories and localnames are mangled and managed.
2292 @menu
2293 * Localname deconstruction::    Breaking a localname into its components.
2294 @end menu
2297 @node Localname deconstruction
2298 @section Breaking a localname into its components.
2300 @value{tramp} file names are somewhat different, obviously, to ordinary file
2301 names. As such, the lisp functions @code{file-name-directory} and
2302 @code{file-name-nondirectory} are overridden within the @value{tramp}
2303 package.
2305 Their replacements are reasonably simplistic in their approach. They
2306 dissect the filename, call the original handler on the localname and
2307 then rebuild the @value{tramp} file name with the result.
2309 This allows the platform specific hacks in the original handlers to take
2310 effect while preserving the @value{tramp} file name information.
2313 @node Issues
2314 @chapter Debatable Issues and What Was Decided
2316 @itemize @bullet
2317 @item The uuencode method does not always work.
2319 Due to the design of @value{tramp}, the encoding and decoding programs need to
2320 read from stdin and write to stdout.  On some systems, @code{uudecode -o
2321 -} will read stdin and write the decoded file to stdout, on other
2322 systems @code{uudecode -p} does the same thing.  But some systems have
2323 uudecode implementations which cannot do this at all---it is not
2324 possible to call these uudecode implementations with suitable parameters
2325 so that they write to stdout.
2327 Of course, this could be circumvented: the @code{begin foo 644} line
2328 could be rewritten to put in some temporary file name, then
2329 @code{uudecode} could be called, then the temp file could be printed and
2330 deleted.
2332 But I have decided that this is too fragile to reliably work, so on some
2333 systems you'll have to do without the uuencode methods.
2335 @item @value{tramp} does not work on XEmacs 20.
2337 This is because it requires the macro @code{with-timeout} which does not
2338 appear to exist in XEmacs 20.  I'm somewhat reluctant to add an
2339 emulation macro to @value{tramp}, but if somebody who uses XEmacs 20 steps
2340 forward and wishes to implement and test it, please contact me or the
2341 mailing list.
2343 @item The @value{tramp} filename syntax differs between GNU Emacs and XEmacs.
2345 The GNU Emacs maintainers wish to use a unified filename syntax for
2346 Ange-FTP and @value{tramp} so that users don't have to learn a new
2347 syntax.  It is sufficient to learn some extensions to the old syntax.
2349 For the XEmacs maintainers, the problems caused from using a unified
2350 filename syntax are greater than the gains.  The XEmacs package system
2351 uses EFS for downloading new packages.  So, obviously, EFS has to be
2352 installed from the start.  If the filenames were unified, @value{tramp}
2353 would have to be installed from the start, too.
2355 @ifset xemacs
2356 @strong{Note:} If you'ld like to use a similar syntax like
2357 @value{ftppackagename}, you need the following settings in your init
2358 file:
2360 @lisp
2361 (setq tramp-unified-filenames t)
2362 (require 'tramp)
2363 @end lisp
2365 The autoload of the @value{emacsname} @value{tramp} package must be
2366 disabled.  This can be achieved by setting file permissions @code{000}
2367 to the files @file{.../xemacs-packages/lisp/tramp/auto-autoloads.el*}.
2369 In case of unified filenames, all @value{emacsname} download sites
2370 are added to @code{tramp-default-method-alist} with default method
2371 @code{ftp} @xref{Default Method}.  These settings shouldn't be touched
2372 for proper working of the @value{emacsname} package system.
2374 The syntax for unified filenames is described in the @value{tramp} manual
2375 for @value{emacsothername}.
2376 @end ifset
2378 @end itemize
2380 @node Concept Index
2381 @comment node-name,    next,  previous,      up
2382 @unnumbered Concept Index
2383 @printindex cp
2384 @contents
2385 @c End of tramp.texi - the TRAMP User Manual
2386 @bye
2388 @c TODO
2390 @c * Say something about the .login and .profile files of the remote
2391 @c   shells.
2392 @c * Explain how tramp.el works in principle: open a shell on a remote
2393 @c   host and then send commands to it.
2394 @c * Mention that bookmarks are a cool feature to go along with Tramp.
2395 @c * Make terminology "inline" vs "out-of-band" consistent.
2396 @c   It seems that "external" is also used instead of "out-of-band".
2398 @c * M. Albinus
2399 @c ** Use `filename' resp. `file name' consistently.
2400 @c ** Use `host' resp. `machine' consistently.
2401 @c ** Consistent small or capitalized words especially in menues.
2403 @ignore
2404    arch-tag: f96dd66e-6dd3-4c92-8d77-9c56205ba808
2405 @end ignore