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