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