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