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