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