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