2009-02-02 Carsten Dominik <dominik@science.uva.nl>
[bpt/emacs.git] / doc / misc / tramp.texi
CommitLineData
4009494e 1\input texinfo @c -*-texinfo-*-
db78a8cb 2@setfilename ../../info/tramp
4009494e
GM
3@c %**start of header
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
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.
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
18@include trampver.texi
19
20@c Macro for formatting a filename according to the repective syntax.
21@c xxx and yyy are auxiliary macros in order to omit leading and
22@c trailing whitespace. Not very elegant, but I don't know it better.
23
24@macro xxx {one}@c
25@set \one\@c
26@end macro
27
28@macro yyy {one, two}@c
29@xxx{x\one\}@c
30@ifclear x@c
31\one\@w{}\two\@c
32@end ifclear
33@clear x\one\@c
34@end macro
35
36@macro trampfn {method, user, host, localname}@c
37@value{prefix}@yyy{\method\,@value{postfixhop}}@yyy{\user\,@@}\host\@value{postfix}\localname\@c
38@end macro
39
40@copying
f18ce50c 41Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4a0cf14f 422006, 2007, 2008, 2009 Free Software Foundation, Inc.
4009494e
GM
43
44@quotation
45Permission is granted to copy, distribute and/or modify this document
6a2c4aec 46under the terms of the GNU Free Documentation License, Version 1.3 or
4009494e 47any later version published by the Free Software Foundation; with no
debf4439
GM
48Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
49and with the Back-Cover Texts as in (a) below. A copy of the license
50is included in the section entitled ``GNU Free Documentation License''.
4009494e 51
7ed4a047
MA
52(a) The FSF's Back-Cover Text is: ``You have the freedom to
53copy and modify this GNU manual. Buying copies from the FSF
54supports it in developing GNU and promoting software freedom.''
4009494e
GM
55@end quotation
56@end copying
57
58@c Entries for @command{install-info} to use
59@dircategory @value{emacsname}
60@direntry
61* TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
62 @value{emacsname} remote file access via rsh and rcp.
63@end direntry
64
65@tex
66
67@titlepage
68@title @value{tramp} version @value{trampver} User Manual
69
70@author by Daniel Pittman
71@author based on documentation by Kai Gro@ss{}johann
72
73@page
74@insertcopying
75
76@end titlepage
77@page
78
79@end tex
80
81@ifnottex
82@node Top, Overview, (dir), (dir)
83@top @value{tramp} version @value{trampver} User Manual
84
85This file documents @value{tramp} version @value{trampver}, a remote file
86editing package for @value{emacsname}.
87
88@value{tramp} stands for `Transparent Remote (file) Access, Multiple
89Protocol'. This package provides remote file editing, similar to
90@value{ftppackagename}.
91
92The difference is that @value{ftppackagename} uses FTP to transfer
93files between the local and the remote host, whereas @value{tramp} uses a
94combination of @command{rsh} and @command{rcp} or other work-alike
95programs, such as @command{ssh}/@command{scp}.
96
97You can find the latest version of this document on the web at
98@uref{http://www.gnu.org/software/tramp/}.
99
100@c Pointer to the other Emacs flavor is necessary only in case of
101@c standalone installation.
102@ifset installchapter
103The manual has been generated for @value{emacsname}.
104@ifinfo
105If you want to read the info pages for @value{emacsothername}, you
106should read in @ref{Installation} how to create them.
107@end ifinfo
108@ifhtml
109If you're using the other Emacs flavor, you should read the
110@uref{@value{emacsotherfilename}, @value{emacsothername}} pages.
111@end ifhtml
112@end ifset
113
114@ifhtml
115@ifset jamanual
116This manual is also available as a @uref{@value{japanesemanual},
117Japanese translation}.
118@end ifset
119
120The latest release of @value{tramp} is available for
121@uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
122@ref{Obtaining Tramp} for more details, including the CVS server
123details.
124
125@value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
126Savannah Project Page}.
127@end ifhtml
128
129There is a mailing list for @value{tramp}, available at
130@email{tramp-devel@@gnu.org}, and archived at
131@uref{http://lists.gnu.org/archive/html/tramp-devel/, the
132@value{tramp} Mail Archive}.
133@ifhtml
134Older archives are located at
135@uref{http://sourceforge.net/mailarchive/forum.php?forum=tramp-devel,
136SourceForge Mail Archive} and
137@uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/,
138The Mail Archive}.
139@c in HTML output, there's no new paragraph.
140@*@*
141@end ifhtml
142
143@insertcopying
144
145@end ifnottex
146
147@menu
148* Overview:: What @value{tramp} can and cannot do.
149
150For the end user:
151
152* Obtaining Tramp:: How to obtain @value{tramp}.
153* History:: History of @value{tramp}.
154@ifset installchapter
155* Installation:: Installing @value{tramp} with your @value{emacsname}.
156@end ifset
157* Configuration:: Configuring @value{tramp} for use.
158* Usage:: An overview of the operation of @value{tramp}.
159* Bug Reports:: Reporting Bugs and Problems.
160* Frequently Asked Questions:: Questions and answers from the mailing list.
dd753688
MA
161* Function Index:: @value{tramp} functions.
162* Variable Index:: User options and variables.
4009494e
GM
163* Concept Index:: An item for each concept.
164
165For the developer:
166
167* Version Control:: The inner workings of remote version control.
168* Files directories and localnames:: How file names, directories and localnames are mangled and managed.
169* Traces and Profiles:: How to Customize Traces.
170* Issues:: Debatable Issues and What Was Decided.
171
172* GNU Free Documentation License:: The license for this documentation.
173
174@detailmenu
175 --- The Detailed Node Listing ---
176@c
177@ifset installchapter
178Installing @value{tramp} with your @value{emacsname}
179
180* Installation parameters:: Parameters in order to control installation.
181* Load paths:: How to plug-in @value{tramp} into your environment.
182* Japanese manual:: Japanese manual.
183
184@end ifset
185
186Configuring @value{tramp} for use
187
188* Connection types:: Types of connections made to remote machines.
189* Inline methods:: Inline methods.
193e6828 190* External methods:: External methods.
4009494e
GM
191@ifset emacsgw
192* Gateway methods:: Gateway methods.
193@end ifset
194* Default Method:: Selecting a default method.
195* Default User:: Selecting a default user.
196* Default Host:: Selecting a default host.
197* Multi-hops:: Connecting to a remote host using multiple hops.
198* Customizing Methods:: Using Non-Standard Methods.
199* Customizing Completion:: Selecting config files for user/host name completion.
a06a4a12 200* Password handling:: Reusing passwords for several connections.
4009494e
GM
201* Connection caching:: Reusing connection related information.
202* Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
203* Remote shell setup:: Remote shell setup hints.
204* Windows setup hints:: Issues with Cygwin ssh.
205* Auto-save and Backup:: Auto-save and Backup.
206
207Using @value{tramp}
208
209* Filename Syntax:: @value{tramp} filename conventions.
210* Alternative Syntax:: URL-like filename syntax.
211* Filename completion:: Filename completion.
212* Remote processes:: Integration with other @value{emacsname} packages.
dd753688 213* Cleanup remote connections:: Cleanup remote connections.
4009494e
GM
214
215The inner workings of remote version control
216
217* Version Controlled Files:: Determining if a file is under version control.
218* Remote Commands:: Executing the version control commands on the remote machine.
219* Changed workfiles:: Detecting if the working file has changed.
220* Checking out files:: Bringing the workfile out of the repository.
221* Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
222
223Things related to Version Control that don't fit elsewhere
224
225* Remote File Ownership:: How VC determines who owns a workfile.
226* Back-end Versions:: How VC determines what release your RCS is.
227
228How file names, directories and localnames are mangled and managed
229
230* Localname deconstruction:: Breaking a localname into its components.
ea3fc256
MA
231@ifset emacs
232* External packages:: Integration with external Lisp packages.
233@end ifset
4009494e
GM
234
235@end detailmenu
236@end menu
237
238@node Overview
239@chapter An overview of @value{tramp}
240@cindex overview
241
242After the installation of @value{tramp} into your @value{emacsname}, you
243will be able to access files on remote machines as though they were
244local. Access to the remote file system for editing files, version
245control, and @code{dired} are transparently enabled.
246
247Your access to the remote machine can be with the @command{rsh},
248@command{rlogin}, @command{telnet} programs or with any similar
249connection method. This connection must pass @acronym{ASCII}
250successfully to be usable but need not be 8-bit clean.
251
252The package provides support for @command{ssh} connections out of the
253box, one of the more common uses of the package. This allows
254relatively secure access to machines, especially if @command{ftp}
255access is disabled.
256
e1176b47
MA
257Under Windows, @value{tramp} is integrated with the PuTTY package,
258using the @command{plink} program.
259
4009494e
GM
260The majority of activity carried out by @value{tramp} requires only that
261the remote login is possible and is carried out at the terminal. In
262order to access remote files @value{tramp} needs to transfer their content
263to the local machine temporarily.
264
265@value{tramp} can transfer files between the machines in a variety of ways.
266The details are easy to select, depending on your needs and the
267machines in question.
268
e1176b47
MA
269The fastest transfer methods for large files rely on a remote file
270transfer package such as @command{rcp}, @command{scp}, @command{rsync}
271or (under Windows) @command{pscp}.
4009494e
GM
272
273If the remote copy methods are not suitable for you, @value{tramp} also
274supports the use of encoded transfers directly through the shell.
275This requires that the @command{mimencode} or @command{uuencode} tools
276are available on the remote machine. These methods are generally
277faster for small files.
278
4009494e
GM
279@value{tramp} is still under active development and any problems you encounter,
280trivial or major, should be reported to the @value{tramp} developers.
281@xref{Bug Reports}.
282
283
284@subsubheading Behind the scenes
285@cindex behind the scenes
286@cindex details of operation
287@cindex how it works
288
289This section tries to explain what goes on behind the scenes when you
290access a remote file through @value{tramp}.
291
292Suppose you type @kbd{C-x C-f} and enter part of an @value{tramp} file name,
293then hit @kbd{@key{TAB}} for completion. Suppose further that this is
294the first time that @value{tramp} is invoked for the host in question. Here's
295what happens:
296
297@itemize
298@item
299@value{tramp} discovers that it needs a connection to the host. So it
300invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
301@var{user}} or a similar tool to connect to the remote host.
302Communication with this process happens through an
303@value{emacsname} buffer, that is, the output from the remote end
304goes into a buffer.
305
306@item
307The remote host may prompt for a login name (for @command{telnet}).
308The login name is given in the file name, so @value{tramp} sends the
309login name and a newline.
310
311@item
312The remote host may prompt for a password or pass phrase (for
313@command{rsh} or for @command{telnet} after sending the login name).
314@value{tramp} displays the prompt in the minibuffer, asking you for the
315password or pass phrase.
316
317You enter the password or pass phrase. @value{tramp} sends it to the remote
318host, followed by a newline.
319
320@item
321@value{tramp} now waits for the shell prompt or for a message that the login
322failed.
323
bc5300d3
MA
324If @value{tramp} sees neither of them after a certain period of time
325(a minute, say), then it issues an error message saying that it
326couldn't find the remote shell prompt and shows you what the remote
327host has sent.
4009494e
GM
328
329If @value{tramp} sees a @samp{login failed} message, it tells you so,
330aborts the login attempt and allows you to try again.
331
332@item
333Suppose that the login was successful and @value{tramp} sees the shell prompt
334from the remote host. Now @value{tramp} invokes @command{/bin/sh} because
335Bourne shells and C shells have different command
336syntaxes.@footnote{Invoking @command{/bin/sh} will fail if your login
337shell doesn't recognize @samp{exec /bin/sh} as a valid command.
338Maybe you use the Scheme shell @command{scsh}@dots{}}
339
340After the Bourne shell has come up, @value{tramp} sends a few commands to
341ensure a good working environment. It turns off echoing, it sets the
342shell prompt, and a few other things.
343
344@item
345Now the remote shell is up and it good working order. Remember, what
346was supposed to happen is that @value{tramp} tries to find out what files exist
347on the remote host so that it can do filename completion.
348
349So, @value{tramp} basically issues @command{cd} and @command{ls} commands and
350also sometimes @command{echo} with globbing. Another command that is
351often used is @command{test} to find out whether a file is writable or a
352directory or the like. The output of each command is parsed for the
353necessary operation.
354
355@item
356Suppose you are finished with filename completion, have entered @kbd{C-x
357C-f}, a full file name and hit @kbd{@key{RET}}. Now comes the time to
358transfer the file contents from the remote host to the local host so
359that you can edit them.
360
361See above for an explanation of how @value{tramp} transfers the file contents.
362
363For inline transfers, @value{tramp} issues a command like @samp{mimencode -b
364/path/to/remote/file}, waits until the output has accumulated in the
365buffer that's used for communication, then decodes that output to
366produce the file contents.
367
193e6828
MA
368For external transfers, @value{tramp} issues a command like the
369following:
4009494e
GM
370@example
371rcp user@@host:/path/to/remote/file /tmp/tramp.4711
372@end example
373It then reads the local temporary file @file{/tmp/tramp.4711} into a
374buffer and deletes the temporary file.
375
376@item
377You now edit the buffer contents, blithely unaware of what has happened
378behind the scenes. (Unless you have read this section, that is.) When
379you are finished, you type @kbd{C-x C-s} to save the buffer.
380
381@item
193e6828
MA
382Again, @value{tramp} transfers the file contents to the remote host
383either inline or external. This is the reverse of what happens when
384reading the file.
4009494e
GM
385@end itemize
386
387I hope this has provided you with a basic overview of what happens
388behind the scenes when you open a file with @value{tramp}.
389
390
391@c For the end user
392@node Obtaining Tramp
393@chapter Obtaining Tramp.
394@cindex obtaining Tramp
395
396@value{tramp} is freely available on the Internet and the latest
397release may be downloaded from
398@uref{ftp://ftp.gnu.org/gnu/tramp/}. This release includes the full
399documentation and code for @value{tramp}, suitable for installation.
400But GNU Emacs (22 or later) includes @value{tramp} already, and there
401is a @value{tramp} package for XEmacs, as well. So maybe it is easier
402to just use those. But if you want the bleeding edge, read
403on@dots{...}
404
405For the especially brave, @value{tramp} is available from CVS. The CVS
406version is the latest version of the code and may contain incomplete
407features or new issues. Use these versions at your own risk.
408
409Instructions for obtaining the latest development version of @value{tramp}
410from CVS can be found by going to the Savannah project page at the
411following URL and then clicking on the CVS link in the navigation bar
412at the top.
413
414@noindent
415@uref{http://savannah.gnu.org/projects/tramp/}
416
417@noindent
418Or follow the example session below:
419
420@example
421] @strong{cd ~/@value{emacsdir}}
422] @strong{export CVS_RSH="ssh"}
423] @strong{cvs -z3 -d:ext:anoncvs@@savannah.gnu.org:/cvsroot/tramp co tramp}
424@end example
425
426@noindent
427You should now have a directory @file{~/@value{emacsdir}/tramp}
428containing the latest version of @value{tramp}. You can fetch the latest
429updates from the repository by issuing the command:
430
431@example
432] @strong{cd ~/@value{emacsdir}/tramp}
433] @strong{export CVS_RSH="ssh"}
434] @strong{cvs update -d}
435@end example
436
437@noindent
438Once you've got updated files from the CVS repository, you need to run
439@command{autoconf} in order to get an up-to-date @file{configure}
440script:
441
442@example
443] @strong{cd ~/@value{emacsdir}/tramp}
444] @strong{autoconf}
445@end example
446
447People who have no direct CVS access (maybe because sitting behind a
448blocking firewall), can try the
449@uref{http://savannah.gnu.org/cvs-backup/tramp-sources.tar.gz, Nightly
450CVS Tree Tarball} instead of.
451
452
453@node History
454@chapter History of @value{tramp}
455@cindex history
456@cindex development history
457
458Development was started end of November 1998. The package was called
459@file{rssh.el}, back then. It only provided one method to access a
460file, using @command{ssh} to log in to a remote host and using
461@command{scp} to transfer the file contents. After a while, the name
462was changed to @file{rcp.el}, and now it's @value{tramp}. Along the way,
463many more methods for getting a remote shell and for transferring the
464file contents were added. Support for VC was added.
465
466The most recent addition of major features were the multi-hop methods
467added in April 2000 and the unification of @value{tramp} and Ange-FTP
468filenames in July 2002. In July 2004, multi-hop methods have been
469replaced by proxy hosts. Running commands on remote hosts was
470introduced in December 2005.
471@ifset emacsgw
472Support of gateways exists since April 2007.
473@end ifset
474
475In December 2001, @value{tramp} has been added to the XEmacs package
476repository. Being part of the GNU Emacs repository happened in June
4772002, the first release including @value{tramp} was GNU Emacs 22.1.
478
479@value{tramp} is also a GNU/Linux Debian package since February 2001.
480
481
482@c Installation chapter is necessary only in case of standalone
483@c installation. Text taken from trampinst.texi.
484@ifset installchapter
485@include trampinst.texi
486@end ifset
487
488@node Configuration
489@chapter Configuring @value{tramp} for use
490@cindex configuration
491
492@cindex default configuration
493@value{tramp} is (normally) fully functional when it is initially
494installed. It is initially configured to use the @command{scp}
495program to connect to the remote host. So in the easiest case, you
496just type @kbd{C-x C-f} and then enter the filename
497@file{@trampfn{, user, machine, /path/to.file}}.
498
499On some hosts, there are problems with opening a connection. These are
500related to the behavior of the remote shell. See @xref{Remote shell
501setup}, for details on this.
502
503If you do not wish to use these commands to connect to the remote
504host, you should change the default connection and transfer method
505that @value{tramp} uses. There are several different methods that @value{tramp}
506can use to connect to remote machines and transfer files
507(@pxref{Connection types}).
508
509If you don't know which method is right for you, see @xref{Default
510Method}.
511
512
513@menu
514* Connection types:: Types of connections made to remote machines.
515* Inline methods:: Inline methods.
193e6828 516* External methods:: External methods.
4009494e
GM
517@ifset emacsgw
518* Gateway methods:: Gateway methods.
519@end ifset
520* Default Method:: Selecting a default method.
521 Here we also try to help those who
522 don't have the foggiest which method
523 is right for them.
524* Default User:: Selecting a default user.
525* Default Host:: Selecting a default host.
526* Multi-hops:: Connecting to a remote host using multiple hops.
527* Customizing Methods:: Using Non-Standard Methods.
528* Customizing Completion:: Selecting config files for user/host name completion.
a06a4a12 529* Password handling:: Reusing passwords for several connections.
4009494e
GM
530* Connection caching:: Reusing connection related information.
531* Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
532* Remote shell setup:: Remote shell setup hints.
533* Windows setup hints:: Issues with Cygwin ssh.
534* Auto-save and Backup:: Auto-save and Backup.
535@end menu
536
537
538@node Connection types
539@section Types of connections made to remote machines.
540@cindex connection types, overview
541
542There are two basic types of transfer methods, each with its own
543advantages and limitations. Both types of connection make use of a
544remote shell access program such as @command{rsh}, @command{ssh} or
545@command{telnet} to connect to the remote machine.
546
547This connection is used to perform many of the operations that @value{tramp}
548requires to make the remote file system transparently accessible from
549the local machine. It is only when visiting files that the methods
550differ.
551
552@cindex inline methods
4009494e 553@cindex external methods
4009494e 554@cindex methods, inline
193e6828 555@cindex methods, external
4009494e 556Loading or saving a remote file requires that the content of the file
193e6828
MA
557be transfered between the two machines. The content of the file can
558be transfered using one of two methods: the @dfn{inline method} over
559the same connection used to log in to the remote machine, or the
560@dfn{external method} through another connection using a remote copy
561program such as @command{rcp}, @command{scp} or @command{rsync}.
562
563The performance of the external methods is generally better than that
564of the inline methods, at least for large files. This is caused by
565the need to encode and decode the data when transferring inline.
4009494e
GM
566
567The one exception to this rule are the @command{scp} based transfer
568methods. While these methods do see better performance when actually
569transferring files, the overhead of the cryptographic negotiation at
570startup may drown out the improvement in file transfer times.
571
193e6828
MA
572External methods should be configured such a way that they don't
573require a password (with @command{ssh-agent}, or such alike). Modern
574@command{scp} implementations offer options to reuse existing
4009494e 575@command{ssh} connections, see method @command{scpc}. If it isn't
a06a4a12 576possible, you should consider @ref{Password handling}, otherwise you
4009494e
GM
577will be prompted for a password every copy action.
578
579
580@node Inline methods
581@section Inline methods
582@cindex inline methods
583@cindex methods, inline
584
585The inline methods in @value{tramp} are quite powerful and can work in
586situations where you cannot use an external transfer program to connect.
587Inline methods are the only methods that work when connecting to the
588remote machine via telnet. (There are also strange inline methods which
589allow you to transfer files between @emph{user identities} rather than
590hosts, see below.)
591
592These methods depend on the existence of a suitable encoding and
593decoding command on remote machine. Locally, @value{tramp} may be able to
594use features of @value{emacsname} to decode and encode the files or
595it may require access to external commands to perform that task.
596
597@cindex uuencode
598@cindex mimencode
599@cindex base-64 encoding
600@value{tramp} checks the availability and usability of commands like
601@command{mimencode} (part of the @command{metamail} package) or
602@command{uuencode} on the remote host. The first reliable command
603will be used. The search path can be customized, see @ref{Remote
604Programs}.
605
606If both commands aren't available on the remote host, @value{tramp}
607transfers a small piece of Perl code to the remote host, and tries to
608apply it for encoding and decoding.
609
610
611@table @asis
612@item @option{rsh}
613@cindex method rsh
614@cindex rsh method
615
616Connect to the remote host with @command{rsh}. Due to the unsecure
617connection it is recommended for very local host topology only.
618
619On operating systems which provide the command @command{remsh} instead
620of @command{rsh}, you can use the method @option{remsh}. This is true
621for HP-UX or Cray UNICOS, for example.
622
623
624@item @option{ssh}
625@cindex method ssh
626@cindex ssh method
627
628Connect to the remote host with @command{ssh}. This is identical to
629the previous option except that the @command{ssh} package is used,
630making the connection more secure.
631
632There are also two variants, @option{ssh1} and @option{ssh2}, that
633call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
634explicitly select whether you want to use the SSH protocol version 1
635or 2 to connect to the remote host. (You can also specify in
636@file{~/.ssh/config}, the SSH configuration file, which protocol
637should be used, and use the regular @option{ssh} method.)
638
639Two other variants, @option{ssh1_old} and @option{ssh2_old}, use the
640@command{ssh1} and @command{ssh2} commands explicitly. If you don't
641know what these are, you do not need these options.
642
643All the methods based on @command{ssh} have an additional kludgy
644feature: you can specify a host name which looks like @file{host#42}
645(the real host name, then a hash sign, then a port number). This
646means to connect to the given host but to also pass @code{-p 42} as
647arguments to the @command{ssh} command.
648
649
650@item @option{telnet}
651@cindex method telnet
652@cindex telnet method
653
654Connect to the remote host with @command{telnet}. This is as unsecure
655as the @option{rsh} method.
656
657
658@item @option{su}
659@cindex method su
660@cindex su method
661
662This method does not connect to a remote host at all, rather it uses
663the @command{su} program to allow you to edit files as another user.
4605b7cd
MA
664That means, the specified host name in the file name must be either
665@samp{localhost} or the host name as returned by the function
666@command{(system-name)}. For an exception of this rule see
667@ref{Multi-hops}.
4009494e
GM
668
669
670@item @option{sudo}
671@cindex method sudo
672@cindex sudo method
673
674This is similar to the @option{su} method, but it uses @command{sudo}
675rather than @command{su} to become a different user.
676
677Note that @command{sudo} must be configured to allow you to start a
678shell as the user. It would be nice if it was sufficient if
679@command{ls} and @command{mimencode} were allowed, but that is not
680easy to implement, so I haven't got around to it, yet.
681
682
683@item @option{sshx}
684@cindex method sshx
685@cindex sshx method
686
687As you would expect, this is similar to @option{ssh}, only a little
688different. Whereas @option{ssh} opens a normal interactive shell on
689the remote host, this option uses @samp{ssh -t -t @var{host} -l
690@var{user} /bin/sh} to open a connection. This is useful for users
691where the normal login shell is set up to ask them a number of
692questions when logging in. This procedure avoids these questions, and
693just gives @value{tramp} a more-or-less `standard' login shell to work
694with.
695
696Note that this procedure does not eliminate questions asked by
697@command{ssh} itself. For example, @command{ssh} might ask ``Are you
698sure you want to continue connecting?'' if the host key of the remote
699host is not known. @value{tramp} does not know how to deal with such a
700question (yet), therefore you will need to make sure that you can log
701in without such questions.
702
703This is also useful for Windows users where @command{ssh}, when
704invoked from an @value{emacsname} buffer, tells them that it is not
705allocating a pseudo tty. When this happens, the login shell is wont
706to not print any shell prompt, which confuses @value{tramp} mightily.
707For reasons unknown, some Windows ports for @command{ssh} require the
708doubled @samp{-t} option.
709
710This supports the @samp{-p} kludge.
711
712
713@item @option{krlogin}
714@cindex method krlogin
715@cindex krlogin method
716@cindex Kerberos (with krlogin method)
717
718This method is also similar to @option{ssh}. It only uses the
719@command{krlogin -x} command to log in to the remote host.
720
721
722@item @option{plink}
723@cindex method plink
724@cindex plink method
725
726This method is mostly interesting for Windows users using the PuTTY
727implementation of SSH. It uses @samp{plink -ssh} to log in to the
728remote host.
729
730This supports the @samp{-P} kludge.
731
732Additionally, the methods @option{plink1} and @option{plink2} are
733provided, which call @samp{plink -1 -ssh} or @samp{plink -2 -ssh} in
734order to use SSH protocol version 1 or 2 explicitly.
735
736CCC: Do we have to connect to the remote host once from the command
737line to accept the SSH key? Maybe this can be made automatic?
738
739CCC: Say something about the first shell command failing. This might
740be due to a wrong setting of @code{tramp-rsh-end-of-line}.
741
742
743@item @option{plinkx}
744@cindex method plinkx
745@cindex plinkx method
746
747Another method using PuTTY on Windows. Instead of host names, it
748expects PuTTY session names, calling @samp{plink -load @var{session}
749-t"}. User names are relevant only in case the corresponding session
750hasn't defined a user name. Different port numbers must be defined in
751the session.
752
753
754@item @option{fish}
755@cindex method fish
756@cindex fish method
757
758This is an experimental implementation of the fish protocol, known from
759the GNU Midnight Commander or the KDE Konqueror. @value{tramp} expects
760the fish server implementation from the KDE kioslave. That means, the
761file @file{~/.fishsrv.pl} is expected to reside on the remote host.
762
763The implementation lacks good performance. The code is offered anyway,
764maybe somebody can improve the performance.
765
766@end table
767
768
193e6828
MA
769@node External methods
770@section External methods
771@cindex methods, external
772@cindex external methods
4009494e 773
193e6828
MA
774The external methods operate through multiple channels, using the
775remote shell connection for many actions while delegating file
4009494e
GM
776transfers to an external transfer utility.
777
778This saves the overhead of encoding and decoding that multiplexing the
779transfer through the one connection has with the inline methods.
780
193e6828
MA
781Since external methods need their own overhead opening a new channel,
782all files which are smaller than @var{tramp-copy-size-limit} are still
783transferred with the corresponding inline method. It should provide a
784fair trade-off between both approaches.
4009494e
GM
785
786@table @asis
787@item @option{rcp} --- @command{rsh} and @command{rcp}
788@cindex method rcp
789@cindex rcp method
790@cindex rcp (with rcp method)
791@cindex rsh (with rcp method)
792
793This method uses the @command{rsh} and @command{rcp} commands to connect
794to the remote machine and transfer files. This is probably the fastest
795connection method available.
796
797The alternative method @option{remcp} uses the @command{remsh} and
798@command{rcp} commands. It should be applied on machines where
799@command{remsh} is used instead of @command{rsh}.
800
801
802@item @option{scp} --- @command{ssh} and @command{scp}
803@cindex method scp
804@cindex scp method
805@cindex scp (with scp method)
806@cindex ssh (with scp method)
807
808Using @command{ssh} to connect to the remote host and @command{scp} to
809transfer files between the machines is the best method for securely
810connecting to a remote machine and accessing files.
811
812The performance of this option is also quite good. It may be slower than
813the inline methods when you often open and close small files however.
814The cost of the cryptographic handshake at the start of an @command{scp}
815session can begin to absorb the advantage that the lack of encoding and
816decoding presents.
817
818There are also two variants, @option{scp1} and @option{scp2}, that
819call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
820explicitly select whether you want to use the SSH protocol version 1
821or 2 to connect to the remote host. (You can also specify in
822@file{~/.ssh/config}, the SSH configuration file, which protocol
823should be used, and use the regular @option{scp} method.)
824
825Two other variants, @option{scp1_old} and @option{scp2_old}, use the
826@command{ssh1} and @command{ssh2} commands explicitly. If you don't
827know what these are, you do not need these options.
828
829All the @command{ssh} based methods support the kludgy @samp{-p}
830feature where you can specify a port number to connect to in the host
831name. For example, the host name @file{host#42} tells @value{tramp} to
832specify @samp{-p 42} in the argument list for @command{ssh}, and to
833specify @samp{-P 42} in the argument list for @command{scp}.
834
835
836@item @option{sftp} --- @command{ssh} and @command{sftp}
837@cindex method sftp
838@cindex sftp method
839@cindex sftp (with sftp method)
840@cindex ssh (with sftp method)
841
842That is mostly the same method as @option{scp}, but using
843@command{sftp} as transfer command. So the same remarks are valid.
844
845This command does not work like @value{ftppackagename}, where
846@command{ftp} is called interactively, and all commands are send from
847within this session. Instead of, @command{ssh} is used for login.
848
849This method supports the @samp{-p} hack.
850
851
852@item @option{rsync} --- @command{ssh} and @command{rsync}
853@cindex method rsync
854@cindex rsync method
855@cindex rsync (with rsync method)
856@cindex ssh (with rsync method)
857
858Using the @command{ssh} command to connect securely to the remote
859machine and the @command{rsync} command to transfer files is almost
860identical to the @option{scp} method.
861
862While @command{rsync} performs much better than @command{scp} when
863transferring files that exist on both hosts, this advantage is lost if
864the file exists only on one side of the connection.
865
866The @command{rsync} based method may be considerably faster than the
867@command{rcp} based methods when writing to the remote system. Reading
868files to the local machine is no faster than with a direct copy.
869
870This method supports the @samp{-p} hack.
871
872
873@item @option{scpx} --- @command{ssh} and @command{scp}
874@cindex method scpx
875@cindex scpx method
876@cindex scp (with scpx method)
877@cindex ssh (with scpx method)
878
879As you would expect, this is similar to @option{scp}, only a little
880different. Whereas @option{scp} opens a normal interactive shell on
881the remote host, this option uses @samp{ssh -t -t @var{host} -l
882@var{user} /bin/sh} to open a connection. This is useful for users
883where the normal login shell is set up to ask them a number of
884questions when logging in. This procedure avoids these questions, and
885just gives @value{tramp} a more-or-less `standard' login shell to work
886with.
887
888This is also useful for Windows users where @command{ssh}, when
889invoked from an @value{emacsname} buffer, tells them that it is not
890allocating a pseudo tty. When this happens, the login shell is wont
891to not print any shell prompt, which confuses @value{tramp} mightily.
892
893This method supports the @samp{-p} hack.
894
895
896@item @option{scpc} --- @command{ssh} and @command{scp}
897@cindex method scpx
898@cindex scpx method
899@cindex scp (with scpx method)
900@cindex ssh (with scpx method)
901
902Newer versions of @option{ssh} (for example OpenSSH 4) offer an option
903@option{ControlMaster}. This allows @option{scp} to reuse an existing
904@option{ssh} channel, which increases performance.
905
906Before you use this method, you shall check whether your @option{ssh}
907implementation does support this option. Try from the command line
908
909@example
910ssh localhost -o ControlMaster=yes
911@end example
912
913This method supports the @samp{-p} hack.
914
915
916@item @option{pscp} --- @command{plink} and @command{pscp}
917@cindex method pscp
918@cindex pscp method
919@cindex pscp (with pscp method)
920@cindex plink (with pscp method)
921@cindex PuTTY (with pscp method)
922
923This method is similar to @option{scp}, but it uses the
924@command{plink} command to connect to the remote host, and it uses
925@command{pscp} for transferring the files. These programs are part
926of PuTTY, an SSH implementation for Windows.
927
928This method supports the @samp{-P} hack.
929
930
931@item @option{psftp} --- @command{plink} and @command{psftp}
932@cindex method psftp
933@cindex psftp method
934@cindex psftp (with psftp method)
935@cindex plink (with psftp method)
936@cindex PuTTY (with psftp method)
937
938As you would expect, this method is similar to @option{sftp}, but it
939uses the @command{plink} command to connect to the remote host, and it
940uses @command{psftp} for transferring the files. These programs are
941part of PuTTY, an SSH implementation for Windows.
942
943This method supports the @samp{-P} hack.
944
945
946@item @option{fcp} --- @command{fsh} and @command{fcp}
947@cindex method fcp
948@cindex fcp method
949@cindex fsh (with fcp method)
950@cindex fcp (with fcp method)
951
952This method is similar to @option{scp}, but it uses the @command{fsh}
953command to connect to the remote host, and it uses @command{fcp} for
954transferring the files. @command{fsh/fcp} are a front-end for
955@command{ssh} which allow for reusing the same @command{ssh} session
956for submitting several commands. This avoids the startup overhead of
957@command{scp} (which has to establish a secure connection whenever it
958is called). Note, however, that you can also use one of the inline
959methods to achieve a similar effect.
960
961This method uses the command @samp{fsh @var{host} -l @var{user}
962/bin/sh -i} to establish the connection, it does not work to just say
963@command{fsh @var{host} -l @var{user}}.
964
965@cindex method fsh
966@cindex fsh method
967
968There is no inline method using @command{fsh} as the multiplexing
969provided by the program is not very useful in our context. @value{tramp}
970opens just one connection to the remote host and then keeps it open,
971anyway.
972
973
974@item @option{ftp}
975@cindex method ftp
976@cindex ftp method
977
978This is not a native @value{tramp} method. Instead of, it forwards all
979requests to @value{ftppackagename}.
980@ifset xemacs
981This works only for unified filenames, see @ref{Issues}.
982@end ifset
983
984
985@item @option{smb} --- @command{smbclient}
986@cindex method smb
987@cindex smb method
988
989This is another not natural @value{tramp} method. It uses the
990@command{smbclient} command on different Unices in order to connect to
991an SMB server. An SMB server might be a Samba (or CIFS) server on
992another UNIX host or, more interesting, a host running MS Windows. So
993far, it is tested towards MS Windows NT, MS Windows 2000, and MS
994Windows XP.
995
996The first directory in the localname must be a share name on the remote
997host. Remember, that the @code{$} character in which default shares
998usually end, must be written @code{$$} due to environment variable
999substitution in file names. If no share name is given (i.e. remote
1000directory @code{/}), all available shares are listed.
1001
1002Since authorization is done on share level, you will be prompted
1003always for a password if you access another share on the same host.
a06a4a12 1004This can be suppressed by @ref{Password handling}.
4009494e
GM
1005
1006MS Windows uses for authorization both a user name and a domain name.
1007Because of this, the @value{tramp} syntax has been extended: you can
1008specify a user name which looks like @code{user%domain} (the real user
1009name, then a percent sign, then the domain name). So, to connect to
1010the machine @code{melancholia} as user @code{daniel} of the domain
1011@code{BIZARRE}, and edit @file{.emacs} in the home directory (share
1012@code{daniel$}) I would specify the filename @file{@trampfn{smb,
1013daniel%BIZARRE, melancholia, /daniel$$/.emacs}}.
1014
1015Depending on the Windows domain configuration, a Windows user might be
1016considered as domain user per default. In order to connect as local
1017user, the WINS name of that machine must be given as domain name.
1018Usually, it is the machine name in capital letters. In the example
1019above, the local user @code{daniel} would be specified as
1020@file{@trampfn{smb, daniel%MELANCHOLIA, melancholia, /daniel$$/.emacs}}.
1021
1022The domain name as well as the user name are optional. If no user
1023name is specified at all, the anonymous user (without password
1024prompting) is assumed. This is different from all other @value{tramp}
1025methods, where in such a case the local user name is taken.
1026
1027The @option{smb} method supports the @samp{-p} hack.
1028
1029@strong{Please note:} If @value{emacsname} runs locally under MS
1030Windows, this method isn't available. Instead of, you can use UNC
1031file names like @file{//melancholia/daniel$$/.emacs}. The only
1032disadvantage is that there's no possibility to specify another user
1033name.
1034
1035@end table
1036
1037
1038@ifset emacsgw
1039@node Gateway methods
1040@section Gateway methods
1041@cindex methods, gateway
1042@cindex gateway methods
1043
1044Gateway methods are not methods to access a remote host directly.
1045These methods are intended to pass firewalls or proxy servers.
1046Therefore, they can be used for proxy host declarations
1047(@pxref{Multi-hops}) only.
1048
1049A gateway method must come always along with a method who supports
1050port setting (referred to as @samp{-p} kludge). This is because
1051@value{tramp} targets the accompanied method to
1052@file{localhost#random_port}, from where the firewall or proxy server
1053is accessed to.
1054
1055Gateway methods support user name and password declarations. These
1056are used to authenticate towards the corresponding firewall or proxy
1057server. They can be passed only if your friendly administrator has
1058granted your access.
1059
1060@table @asis
1061@item @option{tunnel}
1062@cindex method tunnel
1063@cindex tunnel method
1064
1065This method implements an HTTP tunnel via the @command{CONNECT}
1066command (see RFC 2616, 2817). Any HTTP 1.1 compliant (proxy) server
1067shall support this command.
1068
1069As authentication method, only @option{Basic Authentication} (see RFC
10702617) is implemented so far. If no port number is given in the
1071declaration, port @option{8080} is used for the proxy server.
1072
1073
1074@item @option{socks}
1075@cindex method socks
1076@cindex socks method
1077
1078The @command{socks} method provides access to SOCKSv5 servers (see
1079RFC 1928). @option{Username/Password Authentication} according to RFC
10801929 is supported.
1081
1082The default port number of the socks server is @option{1080}, if not
1083specified otherwise.
1084
1085@end table
1086@end ifset
1087
1088
1089@node Default Method
1090@section Selecting a default method
1091@cindex default method
1092
1093@vindex tramp-default-method
1094When you select an appropriate transfer method for your typical usage
1095you should set the variable @code{tramp-default-method} to reflect that
1096choice. This variable controls which method will be used when a method
1097is not specified in the @value{tramp} file name. For example:
1098
1099@lisp
1100(setq tramp-default-method "ssh")
1101@end lisp
1102
1103@vindex tramp-default-method-alist
1104You can also specify different methods for certain user/host
1105combinations, via the variable @code{tramp-default-method-alist}. For
1106example, the following two lines specify to use the @option{ssh}
1107method for all user names matching @samp{john} and the @option{rsync}
1108method for all host names matching @samp{lily}. The third line
1109specifies to use the @option{su} method for the user @samp{root} on
1110the machine @samp{localhost}.
1111
1112@lisp
1113(add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1114(add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1115(add-to-list 'tramp-default-method-alist
1116 '("\\`localhost\\'" "\\`root\\'" "su"))
1117@end lisp
1118
1119@noindent
1120See the documentation for the variable
1121@code{tramp-default-method-alist} for more details.
1122
193e6828
MA
1123External methods are normally preferable to inline methods, giving
1124better performance.
4009494e
GM
1125
1126@xref{Inline methods}.
193e6828 1127@xref{External methods}.
4009494e
GM
1128
1129Another consideration with the selection of transfer methods is the
1130environment you will use them in and, especially when used over the
1131Internet, the security implications of your preferred method.
1132
1133The @option{rsh} and @option{telnet} methods send your password as
1134plain text as you log in to the remote machine, as well as
1135transferring the files in such a way that the content can easily be
1136read from other machines.
1137
1138If you need to connect to remote systems that are accessible from the
1139Internet, you should give serious thought to using @option{ssh} based
1140methods to connect. These provide a much higher level of security,
1141making it a non-trivial exercise for someone to obtain your password
1142or read the content of the files you are editing.
1143
1144
1145@subsection Which method is the right one for me?
1146@cindex choosing the right method
1147
1148Given all of the above, you are probably thinking that this is all fine
1149and good, but it's not helping you to choose a method! Right you are.
1150As a developer, we don't want to boss our users around but give them
1151maximum freedom instead. However, the reality is that some users would
1152like to have some guidance, so here I'll try to give you this guidance
1153without bossing you around. You tell me whether it works @dots{}
1154
193e6828
MA
1155My suggestion is to use an inline method. For large files, external
1156methods might be more efficient, but I guess that most people will
1157want to edit mostly small files.
4009494e
GM
1158
1159I guess that these days, most people can access a remote machine by
1160using @command{ssh}. So I suggest that you use the @option{ssh}
1161method. So, type @kbd{C-x C-f @trampfn{ssh, root, otherhost,
1162/etc/motd} @key{RET}} to edit the @file{/etc/motd} file on the other
1163host.
1164
1165If you can't use @option{ssh} to log in to the remote host, then
1166select a method that uses a program that works. For instance, Windows
1167users might like the @option{plink} method which uses the PuTTY
1168implementation of @command{ssh}. Or you use Kerberos and thus like
1169@option{krlogin}.
1170
1171For the special case of editing files on the local host as another
1172user, see the @option{su} or @option{sudo} methods. They offer
1173shortened syntax for the @samp{root} account, like
1174@file{@trampfn{su, , , /etc/motd}}.
1175
1176People who edit large files may want to consider @option{scpc} instead
1177of @option{ssh}, or @option{pscp} instead of @option{plink}. These
193e6828
MA
1178external methods are faster than inline methods for large files.
1179Note, however, that external methods suffer from some limitations.
4009494e 1180Please try first whether you really get a noticeable speed advantage
193e6828 1181from using an external method! Maybe even for large files, inline
4009494e
GM
1182methods are fast enough.
1183
1184
1185@node Default User
1186@section Selecting a default user
1187@cindex default user
1188
1189The user part of a @value{tramp} file name can be omitted. Usually,
1190it is replaced by the user name you are logged in. Often, this is not
1191what you want. A typical use of @value{tramp} might be to edit some
1192files with root permissions on the local host. This case, you should
1193set the variable @code{tramp-default-user} to reflect that choice.
1194For example:
1195
1196@lisp
1197(setq tramp-default-user "root")
1198@end lisp
1199
1200@code{tramp-default-user} is regarded as obsolete, and will be removed
1201soon.
1202
1203@vindex tramp-default-user-alist
1204You can also specify different users for certain method/host
1205combinations, via the variable @code{tramp-default-user-alist}. For
1206example, if you always have to use the user @samp{john} in the domain
1207@samp{somewhere.else}, you can specify the following:
1208
1209@lisp
1210(add-to-list 'tramp-default-user-alist
1211 '("ssh" ".*\\.somewhere\\.else\\'" "john"))
1212@end lisp
1213
1214@noindent
1215See the documentation for the variable
1216@code{tramp-default-user-alist} for more details.
1217
1218One trap to fall in must be known. If @value{tramp} finds a default
1219user, this user will be passed always to the connection command as
1220parameter (for example @samp{ssh here.somewhere.else -l john}. If you
1221have specified another user for your command in its configuration
1222files, @value{tramp} cannot know it, and the remote access will fail.
1223If you have specified in the given example in @file{~/.ssh/config} the
1224lines
1225
1226@example
1227Host here.somewhere.else
1228 User lily
1229@end example
1230
1231@noindent
1232than you must discard selecting a default user by @value{tramp}. This
1233will be done by setting it to @code{nil} (or @samp{lily}, likewise):
1234
1235@lisp
1236(add-to-list 'tramp-default-user-alist
1237 '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
1238@end lisp
1239
1240The last entry in @code{tramp-default-user-alist} could be your
1241default user you'll apply predominantly. You shall @emph{append} it
1242to that list at the end:
1243
1244@lisp
1245(add-to-list 'tramp-default-user-alist '(nil nil "jonas") t)
1246@end lisp
1247
1248
1249@node Default Host
1250@section Selecting a default host
1251@cindex default host
1252
1253@vindex tramp-default-host
1254Finally, it is even possible to omit the host name part of a
1255@value{tramp} file name. This case, the value of the variable
1256@code{tramp-default-host} is used. Per default, it is initialized
1257with the host name your local @value{emacsname} is running.
1258
1259If you, for example, use @value{tramp} mainly to contact the host
1260@samp{target} as user @samp{john}, you can specify:
1261
1262@lisp
1263(setq tramp-default-user "john"
1264 tramp-default-host "target")
1265@end lisp
1266
1267Then the simple file name @samp{@trampfn{ssh, , ,}} will connect you
1268to John's home directory on target.
1269@ifset emacs
1270Note, however, that the most simplification @samp{/::} won't work,
1271because @samp{/:} is the prefix for quoted file names.
1272@end ifset
1273
1274
1275@node Multi-hops
1276@section Connecting to a remote host using multiple hops
1277@cindex multi-hop
1278@cindex proxy hosts
1279
1280Sometimes, the methods described before are not sufficient. Sometimes,
1281it is not possible to connect to a remote host using a simple command.
1282For example, if you are in a secured network, you might have to log in
1283to a `bastion host' first before you can connect to the outside world.
1284Of course, the target host may also require a bastion host.
1285
1286@vindex tramp-default-proxies-alist
1287In order to specify such multiple hops, it is possible to define a proxy
1288host to pass through, via the variable
1289@code{tramp-default-proxies-alist}. This variable keeps a list of
1290triples (@var{host} @var{user} @var{proxy}).
1291
1292 The first matching item specifies the proxy host to be passed for a
1293file name located on a remote target matching @var{user}@@@var{host}.
1294@var{host} and @var{user} are regular expressions or @code{nil}, which
1295is interpreted as a regular expression which always matches.
1296
1297@var{proxy} must be a Tramp filename which localname part is ignored.
1298Method and user name on @var{proxy} are optional, which is interpreted
1299with the default values.
1300@ifset emacsgw
1301The method must be an inline or gateway method (@pxref{Inline
1302methods}, @pxref{Gateway methods}).
1303@end ifset
1304@ifclear emacsgw
1305The method must be an inline method (@pxref{Inline methods}).
1306@end ifclear
1307If @var{proxy} is @code{nil}, no additional hop is required reaching
1308@var{user}@@@var{host}.
1309
1310If you, for example, must pass the host @samp{bastion.your.domain} as
1311user @samp{bird} for any remote host which is not located in your local
1312domain, you can set
1313
1314@lisp
1315(add-to-list 'tramp-default-proxies-alist
1316 '("\\." nil "@trampfn{ssh, bird, bastion.your.domain,}"))
1317(add-to-list 'tramp-default-proxies-alist
1318 '("\\.your\\.domain\\'" nil nil))
1319@end lisp
1320
1321Please note the order of the code. @code{add-to-list} adds elements at the
1322beginning of a list. Therefore, most relevant rules must be added last.
1323
1324Proxy hosts can be cascaded. If there is another host called
1325@samp{jump.your.domain}, which is the only one in your local domain who
1326is allowed connecting @samp{bastion.your.domain}, you can add another
1327rule:
1328
1329@lisp
1330(add-to-list 'tramp-default-proxies-alist
1331 '("\\`bastion\\.your\\.domain\\'"
1332 "\\`bird\\'"
1333 "@trampfn{ssh, , jump.your.domain,}"))
1334@end lisp
1335
1336@var{proxy} can contain the patterns @code{%h} or @code{%u}. These
1337patterns are replaced by the strings matching @var{host} or
1338@var{user}, respectively.
1339
1340If you, for example, wants to work as @samp{root} on hosts in the
1341domain @samp{your.domain}, but login as @samp{root} is disabled for
1342non-local access, you might add the following rule:
1343
1344@lisp
1345(add-to-list 'tramp-default-proxies-alist
1346 '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh, , %h,}"))
1347@end lisp
1348
1349Opening @file{@trampfn{sudo, , randomhost.your.domain,}} would connect
1350first @samp{randomhost.your.domain} via @code{ssh} under your account
1351name, and perform @code{sudo -u root} on that host afterwards. It is
1352important to know that the given method is applied on the host which
1353has been reached so far. @code{sudo -u root}, applied on your local
1354host, wouldn't be useful here.
1355
1356This is the recommended configuration to work as @samp{root} on remote
1357Ubuntu hosts.
1358
1359@ifset emacsgw
1360Finally, @code{tramp-default-proxies-alist} can be used to pass
1361firewalls or proxy servers. Imagine your local network has a host
1362@samp{proxy.your.domain} which is used on port 3128 as HTTP proxy to
1363the outer world. Your friendly administrator has granted you access
1364under your user name to @samp{host.other.domain} on that proxy
1365server.@footnote{HTTP tunnels are intended for secure SSL/TLS
1366communication. Therefore, many proxy server restrict the tunnels to
1367related target ports. You might need to run your ssh server on your
1368target host @samp{host.other.domain} on such a port, like 443 (https).
1369See @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall}
1370for discussion of ethical issues.} You would need to add the
1371following rule:
1372
1373@lisp
1374(add-to-list 'tramp-default-proxies-alist
1375 '("\\`host\\.other\\.domain\\'" nil
1376 "@trampfn{tunnel, , proxy.your.domain#3128,}"))
1377@end lisp
1378
1379Gateway methods can be declared as first hop only in a multiple hop
1380chain.
1381@end ifset
1382
1383
1384@node Customizing Methods
1385@section Using Non-Standard Methods
1386@cindex customizing methods
1387@cindex using non-standard methods
1388@cindex create your own methods
1389
1390There is a variable @code{tramp-methods} which you can change if the
1391predefined methods don't seem right.
1392
1393For the time being, I'll refer you to the Lisp documentation of that
1394variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
1395
1396
1397@node Customizing Completion
1398@section Selecting config files for user/host name completion
1399@cindex customizing completion
1400@cindex selecting config files
1401@vindex tramp-completion-function-alist
1402
1403The variable @code{tramp-completion-function-alist} is intended to
1404customize which files are taken into account for user and host name
1405completion (@pxref{Filename completion}). For every method, it keeps
1406a set of configuration files, accompanied by a Lisp function able to
1407parse that file. Entries in @code{tramp-completion-function-alist}
1408have the form (@var{method} @var{pair1} @var{pair2} ...).
1409
1410Each @var{pair} is composed of (@var{function} @var{file}).
1411@var{function} is responsible to extract user names and host names
1412from @var{file} for completion. There are two functions which access
1413this variable:
1414
1415@defun tramp-get-completion-function method
1416This function returns the list of completion functions for @var{method}.
1417
1418Example:
1419@example
1420(tramp-get-completion-function "rsh")
1421
1422 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1423 (tramp-parse-rhosts "~/.rhosts"))
1424@end example
1425@end defun
1426
1427@defun tramp-set-completion-function method function-list
1428This function sets @var{function-list} as list of completion functions
1429for @var{method}.
1430
1431Example:
1432@example
1433(tramp-set-completion-function "ssh"
1434 '((tramp-parse-sconfig "/etc/ssh_config")
1435 (tramp-parse-sconfig "~/.ssh/config")))
1436
1437 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1438 (tramp-parse-sconfig "~/.ssh/config"))
1439@end example
1440@end defun
1441
1442The following predefined functions parsing configuration files exist:
1443
1444@table @asis
1445@item @code{tramp-parse-rhosts}
1446@findex tramp-parse-rhosts
1447
1448This function parses files which are syntactical equivalent to
1449@file{~/.rhosts}. It returns both host names and user names, if
1450specified.
1451
1452@item @code{tramp-parse-shosts}
1453@findex tramp-parse-shosts
1454
1455This function parses files which are syntactical equivalent to
1456@file{~/.ssh/known_hosts}. Since there are no user names specified
1457in such files, it can return host names only.
1458
1459@item @code{tramp-parse-sconfig}
1460@findex tramp-parse-shosts
1461
1462This function returns the host nicknames defined by @code{Host} entries
1463in @file{~/.ssh/config} style files.
1464
1465@item @code{tramp-parse-shostkeys}
1466@findex tramp-parse-shostkeys
1467
1468SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1469@file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1470@file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1471are always @code{nil}.
1472
1473@item @code{tramp-parse-sknownhosts}
1474@findex tramp-parse-shostkeys
1475
1476Another SSH2 style parsing of directories like
1477@file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1478case, hosts names are coded in file names
1479@file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1480
1481@item @code{tramp-parse-hosts}
1482@findex tramp-parse-hosts
1483
1484A function dedicated to @file{/etc/hosts} style files. It returns
1485host names only.
1486
1487@item @code{tramp-parse-passwd}
1488@findex tramp-parse-passwd
1489
1490A function which parses @file{/etc/passwd} like files. Obviously, it
1491can return user names only.
1492
1493@item @code{tramp-parse-netrc}
1494@findex tramp-parse-netrc
1495
1496Finally, a function which parses @file{~/.netrc} like files.
1497@end table
1498
1499If you want to keep your own data in a file, with your own structure,
1500you might provide such a function as well. This function must meet
1501the following conventions:
1502
1503@defun my-tramp-parse file
1504@var{file} must be either a file name on your host, or @code{nil}.
1505The function must return a list of (@var{user} @var{host}), which are
1506taken as candidates for user and host name completion.
1507
1508Example:
1509@example
1510(my-tramp-parse "~/.my-tramp-hosts")
1511
1512 @result{} ((nil "toto") ("daniel" "melancholia"))
1513@end example
1514@end defun
1515
1516
a06a4a12 1517@node Password handling
4009494e
GM
1518@section Reusing passwords for several connections.
1519@cindex passwords
1520
1521Sometimes it is necessary to connect to the same remote host several
1522times. Reentering passwords again and again would be annoying, when
1523the chosen method does not support access without password prompt
1524through own configuration.
1525
a06a4a12
MA
1526The best recommendation is to use the method's own mechanism for
1527password handling. Consider @command{ssh-agent} for @option{ssh}-like
1528methods, or @command{pageant} for @option{plink}-like methods.
1529
1530However, if you cannot apply such native password handling,
1531@value{tramp} offers altenatives.
1532
1533
1534@anchor{auth-sources}
1535@subsection Using an authentication file
1536
1537@vindex auth-sources
1538The package @file{auth-source.el}, originally developed in No Gnus,
1539offers the possibility to read passwords from a file, like FTP does it
1540from @file{~/.netrc}. The default authentication file is
1541@file{~/.authinfo.gpg}, this can be changed via the variable
1542@code{auth-sources}.
1543
1544@noindent
1545A typical entry in the authentication file would be
1546
1547@example
1548machine melancholia port scp login daniel password geheim
1549@end example
1550
1551The port can be any @value{tramp} method (@pxref{Inline methods},
193e6828
MA
1552@pxref{External methods}), to match only this method. When you omit
1553the port, you match all @value{tramp} methods.
a06a4a12
MA
1554
1555
1556@anchor{password-cache}
1557@subsection Caching passwords
1558
1559If there is no authentication file, @value{tramp} caches the passwords
1560entered by you. They will be reused next time if a connection needs
1561them for the same user name and host name, independently of the
1562connection method.
4009494e
GM
1563
1564@vindex password-cache-expiry
1565Passwords are not saved permanently, that means the password caching
1566is limited to the lifetime of your @value{emacsname} session. You
1567can influence the lifetime of password caching by customizing the
1568variable @code{password-cache-expiry}. The value is the number of
1569seconds how long passwords are cached. Setting it to @code{nil}
1570disables the expiration.
1571
4009494e
GM
1572@vindex password-cache
1573If you don't like this feature for security reasons, password caching
1574can be disabled totally by customizing the variable
1575@code{password-cache} (setting it to @code{nil}).
1576
1577Implementation Note: password caching is based on the package
a06a4a12
MA
1578@file{password-cache.el}. For the time being, it is activated only
1579when this package is seen in the @code{load-path} while loading
4009494e
GM
1580@value{tramp}.
1581@ifset installchapter
1582If you don't use No Gnus, you can take @file{password.el} from the
1583@value{tramp} @file{contrib} directory, see @ref{Installation
1584parameters}.
1585@end ifset
4009494e
GM
1586
1587
1588@node Connection caching
1589@section Reusing connection related information.
1590@cindex caching
1591
1592@vindex tramp-persistency-file-name
1593In order to reduce initial connection time, @value{tramp} stores
1594connection related information persistently. The variable
1595@code{tramp-persistency-file-name} keeps the file name where these
1596information are written. Its default value is
1597@ifset emacs
1598@file{~/.emacs.d/tramp}.
1599@end ifset
1600@ifset xemacs
1601@file{~/.xemacs/tramp}.
1602@end ifset
1603It is recommended to choose a local file name.
1604
1605@value{tramp} reads this file during startup, and writes it when
1606exiting @value{emacsname}. You can simply remove this file if
1607@value{tramp} shall be urged to recompute these information next
1608@value{emacsname} startup time.
1609
1610Using such persistent information can be disabled by setting
1611@code{tramp-persistency-file-name} to @code{nil}.
1612
9bbb9638
MA
1613Once consequence of reusing connection related information is that
1614@var{tramp} needs to distinguish hosts. If you, for example, run a
1615local @code{sshd} on port 3001, which tunnels @command{ssh} to another
1616host, you could access both @file{@trampfn{ssh, , localhost,}} and
1617@file{@trampfn{ssh, , localhost#3001,}}. @var{tramp} would use the
1618same host related information (like paths, Perl variants, etc) for
1619both connections, although the information is valid only for one of
1620them.
1621
1622In order to avoid trouble, you must use another host name for one of
1623the connections, like introducing a @option{Host} section in
1624@file{~/.ssh/config} (@pxref{Frequently Asked Questions}) or applying
1625multiple hops (@pxref{Multi-hops}).
1626
bc5300d3
MA
1627When @value{tramp} detects a changed operating system version on a
1628remote host (via the command @command{uname -sr}), it flushes all
a06a4a12
MA
1629connection related information for this host, and opens the
1630connection, again.
bc5300d3 1631
4009494e
GM
1632
1633@node Remote Programs
1634@section How @value{tramp} finds and uses programs on the remote machine.
1635
1636@value{tramp} depends on a number of programs on the remote host in order to
1637function, including @command{ls}, @command{test}, @command{find} and
1638@command{cat}.
1639
1640In addition to these required tools, there are various tools that may be
1641required based on the connection method. See @ref{Inline methods} and
193e6828 1642@ref{External methods} for details on these.
4009494e
GM
1643
1644Certain other tools, such as @command{perl} (or @command{perl5}) and
1645@command{grep} will be used if they can be found. When they are
1646available, they are used to improve the performance and accuracy of
1647remote file access.
1648
1649@vindex tramp-remote-path
1650When @value{tramp} connects to the remote machine, it searches for the
1651programs that it can use. The variable @code{tramp-remote-path}
1652controls the directories searched on the remote machine.
1653
1654By default, this is set to a reasonable set of defaults for most
1655machines. The symbol @code{tramp-default-remote-path} is a place
1656holder, it is replaced by the list of directories received via the
1657command @command{getconf PATH} on your remote machine. For example,
1658on GNU Debian this is @file{/bin:/usr/bin}, whereas on Solaris this is
1659@file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin}. It is
1660recommended to apply this symbol on top of @code{tramp-remote-path}.
1661
1662It is possible, however, that your local (or remote ;) system
1663administrator has put the tools you want in some obscure local
1664directory.
1665
1666In this case, you can still use them with @value{tramp}. You simply
1667need to add code to your @file{.emacs} to add the directory to the
1668remote path. This will then be searched by @value{tramp} when you
1669connect and the software found.
1670
1671To add a directory to the remote search path, you could use code such
1672as:
1673
1674@lisp
1675@i{;; We load @value{tramp} to define the variable.}
1676(require 'tramp)
1677@i{;; We have @command{perl} in "/usr/local/perl/bin"}
1678(add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1679@end lisp
1680
1681@value{tramp} caches several information, like the Perl binary
1682location. The changed remote search path wouldn't affect these
1683settings. In order to force @value{tramp} to recompute these values,
1684you must exit @value{emacsname}, remove your persistency file
1685(@pxref{Connection caching}), and restart @value{emacsname}.
1686
1687
1688@node Remote shell setup
4009494e
GM
1689@section Remote shell setup hints
1690@cindex remote shell setup
1691@cindex @file{.profile} file
1692@cindex @file{.login} file
1693@cindex shell init files
1694
1695As explained in the @ref{Overview} section, @value{tramp} connects to the
1696remote host and talks to the shell it finds there. Of course, when you
1697log in, the shell executes its init files. Suppose your init file
1698requires you to enter the birth date of your mother; clearly @value{tramp}
1699does not know this and hence fails to log you in to that host.
1700
1701There are different possible strategies for pursuing this problem. One
1702strategy is to enable @value{tramp} to deal with all possible situations.
1703This is a losing battle, since it is not possible to deal with
1704@emph{all} situations. The other strategy is to require you to set up
1705the remote host such that it behaves like @value{tramp} expects. This might
1706be inconvenient because you have to invest a lot of effort into shell
1707setup before you can begin to use @value{tramp}.
1708
1709The package, therefore, pursues a combined approach. It tries to
1710figure out some of the more common setups, and only requires you to
1711avoid really exotic stuff. For example, it looks through a list of
1712directories to find some programs on the remote host. And also, it
1713knows that it is not obvious how to check whether a file exists, and
1714therefore it tries different possibilities. (On some hosts and
1715shells, the command @command{test -e} does the trick, on some hosts
1716the shell builtin doesn't work but the program @command{/usr/bin/test
1717-e} or @command{/bin/test -e} works. And on still other hosts,
1718@command{ls -d} is the right way to do this.)
1719
1720Below you find a discussion of a few things that @value{tramp} does not deal
1721with, and that you therefore have to set up correctly.
1722
1723@table @asis
1724@item @var{shell-prompt-pattern}
1725@vindex shell-prompt-pattern
1726
1727After logging in to the remote host, @value{tramp} has to wait for the remote
1728shell startup to finish before it can send commands to the remote
1729shell. The strategy here is to wait for the shell prompt. In order to
1730recognize the shell prompt, the variable @code{shell-prompt-pattern} has
1731to be set correctly to recognize the shell prompt on the remote host.
1732
1733Note that @value{tramp} requires the match for @code{shell-prompt-pattern}
1734to be at the end of the buffer. Many people have something like the
1735following as the value for the variable: @code{"^[^>$][>$] *"}. Now
1736suppose your shell prompt is @code{a <b> c $ }. In this case,
1737@value{tramp} recognizes the @code{>} character as the end of the prompt,
1738but it is not at the end of the buffer.
1739
1740@item @var{tramp-shell-prompt-pattern}
1741@vindex tramp-shell-prompt-pattern
1742
1743This regular expression is used by @value{tramp} in the same way as
1744@code{shell-prompt-pattern}, to match prompts from the remote shell.
1745This second variable exists because the prompt from the remote shell
1746might be different from the prompt from a local shell --- after all,
1747the whole point of @value{tramp} is to log in to remote hosts as a
1748different user. The default value of
1749@code{tramp-shell-prompt-pattern} is the same as the default value of
1750@code{shell-prompt-pattern}, which is reported to work well in many
1751circumstances.
1752
dd753688
MA
1753@item @var{tramp-password-prompt-regexp}
1754@vindex tramp-password-prompt-regexp
1755@vindex tramp-wrong-passwd-regexp
1756
1757During login, @value{tramp} might be forced to enter a password or a
1758passphrase. The difference between both is that a password is
1759requested from the shell on the remote host, while a passphrase is
1760needed for accessing local authentication information, like your ssh
1761key.
1762
1763@var{tramp-password-prompt-regexp} handles the detection of such
1764requests for English environments. When you use another localization
1765of your (local or remote) host, you might need to adapt this. Example:
1766
1767@lisp
1768(setq
1769 tramp-password-prompt-regexp
1770 (concat
1771 "^.*"
1772 (regexp-opt
1773 '("passphrase" "Passphrase"
1774 ;; English
1775 "password" "Password"
1776 ;; Deutsch
1777 "passwort" "Passwort"
1778 ;; Fran@,{c}ais
1779 "mot de passe" "Mot de passe") t)
1780 ".*:\0? *"))
1781@end lisp
1782
1783In parallel, it might also be necessary to adapt
1784@var{tramp-wrong-passwd-regexp}.
1785
4009494e
GM
1786@item @command{tset} and other questions
1787@cindex Unix command tset
1788@cindex tset Unix command
1789
1790Some people invoke the @command{tset} program from their shell startup
1791scripts which asks the user about the terminal type of the shell.
1792Maybe some shells ask other questions when they are started.
1793@value{tramp} does not know how to answer these questions. There are
1794two approaches for dealing with this problem. One approach is to take
1795care that the shell does not ask any questions when invoked from
1796@value{tramp}. You can do this by checking the @code{TERM}
1797environment variable, it will be set to @code{dumb} when connecting.
1798
1799@vindex tramp-terminal-type
1800The variable @code{tramp-terminal-type} can be used to change this value
1801to @code{dumb}.
1802
1803@vindex tramp-actions-before-shell
1804The other approach is to teach @value{tramp} about these questions. See
1805the variable @code{tramp-actions-before-shell}. Example:
1806
1807@lisp
1808(defconst my-tramp-prompt-regexp
1809 (concat (regexp-opt '("Enter the birth date of your mother:") t)
1810 "\\s-*")
1811 "Regular expression matching my login prompt question.")
1812
1813(defun my-tramp-action (proc vec)
1814 "Enter \"19000101\" in order to give a correct answer."
1815 (save-window-excursion
1816 (with-current-buffer (tramp-get-connection-buffer vec)
1817 (tramp-message vec 6 "\n%s" (buffer-string))
1818 (tramp-send-string vec "19000101"))))
1819
1820(add-to-list 'tramp-actions-before-shell
1821 '(my-tramp-prompt-regexp my-tramp-action))
1822@end lisp
1823
1824
1825@item Environment variables named like users in @file{.profile}
1826
1827If you have a user named frumple and set the variable @code{FRUMPLE} in
1828your shell environment, then this might cause trouble. Maybe rename
1829the variable to @code{FRUMPLE_DIR} or the like.
1830
1831This weird effect was actually reported by a @value{tramp} user!
1832
1833
1834@item Non-Bourne commands in @file{.profile}
1835
1836After logging in to the remote host, @value{tramp} issues the command
1837@command{exec /bin/sh}. (Actually, the command is slightly
1838different.) When @command{/bin/sh} is executed, it reads some init
1839files, such as @file{~/.shrc} or @file{~/.profile}.
1840
1841Now, some people have a login shell which is not @code{/bin/sh} but a
1842Bourne-ish shell such as bash or ksh. Some of these people might put
1843their shell setup into the files @file{~/.shrc} or @file{~/.profile}.
1844This way, it is possible for non-Bourne constructs to end up in those
1845files. Then, @command{exec /bin/sh} might cause the Bourne shell to
1846barf on those constructs.
1847
1848As an example, imagine somebody putting @command{export FOO=bar} into
1849the file @file{~/.profile}. The standard Bourne shell does not
1850understand this syntax and will emit a syntax error when it reaches
1851this line.
1852
1853Another example is the tilde (@code{~}) character, say when adding
1854@file{~/bin} to @code{$PATH}. Many Bourne shells will not expand this
1855character, and since there is usually no directory whose name consists
1856of the single character tilde, strange things will happen.
1857
1858What can you do about this?
1859
1860Well, one possibility is to make sure that everything in
1861@file{~/.shrc} and @file{~/.profile} on all remote hosts is
1862Bourne-compatible. In the above example, instead of @command{export
1863FOO=bar}, you might use @command{FOO=bar; export FOO} instead.
1864
1865The other possibility is to put your non-Bourne shell setup into some
1866other files. For example, bash reads the file @file{~/.bash_profile}
1867instead of @file{~/.profile}, if the former exists. So bash
1868aficionados just rename their @file{~/.profile} to
1869@file{~/.bash_profile} on all remote hosts, and Bob's your uncle.
1870
1871The @value{tramp} developers would like to circumvent this problem, so
1872if you have an idea about it, please tell us. However, we are afraid
1873it is not that simple: before saying @command{exec /bin/sh},
1874@value{tramp} does not know which kind of shell it might be talking
1875to. It could be a Bourne-ish shell like ksh or bash, or it could be a
1876csh derivative like tcsh, or it could be zsh, or even rc. If the
1877shell is Bourne-ish already, then it might be prudent to omit the
1878@command{exec /bin/sh} step. But how to find out if the shell is
1879Bourne-ish?
1880
1881@end table
1882
1883
1884@node Auto-save and Backup
1885@section Auto-save and Backup configuration
1886@cindex auto-save
1887@cindex backup
1888@ifset emacs
1889@vindex backup-directory-alist
1890@end ifset
1891@ifset xemacs
1892@vindex bkup-backup-directory-info
1893@end ifset
1894
1895Normally, @value{emacsname} writes backup files to the same directory
1896as the original files, but this behavior can be changed via the
1897variable
1898@ifset emacs
1899@code{backup-directory-alist}.
1900@end ifset
1901@ifset xemacs
1902@code{bkup-backup-directory-info}.
1903@end ifset
1904In connection with @value{tramp}, this can have unexpected side
1905effects. Suppose that you specify that all backups should go to the
1906directory @file{~/.emacs.d/backups/}, and then you edit the file
1907@file{@trampfn{su, root, localhost, /etc/secretfile}}. The effect is
1908that the backup file will be owned by you and not by root, thus
1909possibly enabling others to see it even if they were not intended to
1910see it.
1911
1912When
1913@ifset emacs
1914@code{backup-directory-alist}
1915@end ifset
1916@ifset xemacs
1917@code{bkup-backup-directory-info}
1918@end ifset
1919is @code{nil} (the default), such problems do not occur.
1920
1921Therefore, it is useful to set special values for @value{tramp}
1922files. For example, the following statement effectively `turns off'
1923the effect of
1924@ifset emacs
1925@code{backup-directory-alist}
1926@end ifset
1927@ifset xemacs
1928@code{bkup-backup-directory-info}
1929@end ifset
1930for @value{tramp} files:
1931
1932@ifset emacs
1933@lisp
1934(add-to-list 'backup-directory-alist
1935 (cons tramp-file-name-regexp nil))
1936@end lisp
1937@end ifset
1938@ifset xemacs
1939@lisp
1940(require 'backup-dir)
1941(add-to-list 'bkup-backup-directory-info
1942 (list tramp-file-name-regexp ""))
1943@end lisp
1944@end ifset
1945
1946Another possibility is to use the @value{tramp} variable
1947@ifset emacs
1948@code{tramp-backup-directory-alist}.
1949@end ifset
1950@ifset xemacs
1951@code{tramp-bkup-backup-directory-info}.
1952@end ifset
1953This variable has the same meaning like
1954@ifset emacs
1955@code{backup-directory-alist}.
1956@end ifset
1957@ifset xemacs
1958@code{bkup-backup-directory-info}.
1959@end ifset
1960If a @value{tramp} file is backed up, and DIRECTORY is an absolute
1961local file name, DIRECTORY is prepended with the @value{tramp} file
1962name prefix of the file to be backed up.
1963
1964@noindent
1965Example:
1966
1967@ifset emacs
1968@lisp
1969(add-to-list 'backup-directory-alist
1970 (cons "." "~/.emacs.d/backups/"))
1971(setq tramp-backup-directory-alist backup-directory-alist)
1972@end lisp
1973@end ifset
1974@ifset xemacs
1975@lisp
1976(require 'backup-dir)
1977(add-to-list 'bkup-backup-directory-info
1978 (list "." "~/.emacs.d/backups/" 'full-path))
1979(setq tramp-bkup-backup-directory-info bkup-backup-directory-info)
1980@end lisp
1981@end ifset
1982
1983@noindent
1984The backup file name of @file{@trampfn{su, root, localhost,
1985/etc/secretfile}} would be
1986@ifset emacs
1987@file{@trampfn{su, root, localhost,
1988~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}}
1989@end ifset
1990@ifset xemacs
1991@file{@trampfn{su, root, localhost,
1992~/.emacs.d/backups/![su!root@@localhost]!etc!secretfile~}}
1993@end ifset
1994
1995The same problem can happen with auto-saving files.
1996@ifset emacs
1997Since @value{emacsname} 21, the variable
1998@code{auto-save-file-name-transforms} keeps information, on which
1999directory an auto-saved file should go. By default, it is initialized
2000for @value{tramp} files to the local temporary directory.
2001
2002On some versions of @value{emacsname}, namely the version built for
2003Debian GNU/Linux, the variable @code{auto-save-file-name-transforms}
2004contains the directory where @value{emacsname} was built. A
2005workaround is to manually set the variable to a sane value.
2006
2007If auto-saved files should go into the same directory as the original
2008files, @code{auto-save-file-name-transforms} should be set to @code{nil}.
2009
2010Another possibility is to set the variable
2011@code{tramp-auto-save-directory} to a proper value.
2012@end ifset
2013@ifset xemacs
2014For this purpose you can set the variable @code{auto-save-directory}
2015to a proper value.
2016@end ifset
2017
2018
2019@node Windows setup hints
2020@section Issues with Cygwin ssh
2021@cindex Cygwin, issues
2022
2023This section needs a lot of work! Please help.
2024
2025@cindex method sshx with Cygwin
2026@cindex sshx method with Cygwin
2027The recent Cygwin installation of @command{ssh} works only with a
2028Cygwinized @value{emacsname}. You can check it by typing @kbd{M-x
2029eshell}, and starting @kbd{ssh test.machine}. The problem is evident
2030if you see a message like this:
2031
2032@example
2033Pseudo-terminal will not be allocated because stdin is not a terminal.
2034@end example
2035
2036Older @command{ssh} versions of Cygwin are told to cooperate with
2037@value{tramp} selecting @option{sshx} as the connection method. You
2038can find information about setting up Cygwin in their FAQ at
2039@uref{http://cygwin.com/faq/}.
2040
2041@cindex method scpx with Cygwin
2042@cindex scpx method with Cygwin
2043If you wish to use the @option{scpx} connection method, then you might
2044have the problem that @value{emacsname} calls @command{scp} with a
2045Windows filename such as @code{c:/foo}. The Cygwin version of
2046@command{scp} does not know about Windows filenames and interprets
2047this as a remote filename on the host @code{c}.
2048
2049One possible workaround is to write a wrapper script for @option{scp}
2050which converts the Windows filename to a Cygwinized filename.
2051
2052@cindex Cygwin and ssh-agent
2053@cindex SSH_AUTH_SOCK and @value{emacsname} on Windows
2054If you want to use either @option{ssh} based method on Windows, then
2055you might encounter problems with @command{ssh-agent}. Using this
2056program, you can avoid typing the pass-phrase every time you log in.
2057However, if you start @value{emacsname} from a desktop shortcut, then
2058the environment variable @code{SSH_AUTH_SOCK} is not set and so
2059@value{emacsname} and thus @value{tramp} and thus @command{ssh} and
2060@command{scp} started from @value{tramp} cannot communicate with
2061@command{ssh-agent}. It works better to start @value{emacsname} from
2062the shell.
2063
2064If anyone knows how to start @command{ssh-agent} under Windows in such a
2065way that desktop shortcuts can profit, please holler. I don't really
2066know anything at all about Windows@dots{}
2067
2068
2069@node Usage
2070@chapter Using @value{tramp}
2071@cindex using @value{tramp}
2072
2073Once you have installed @value{tramp} it will operate fairly
2074transparently. You will be able to access files on any remote machine
2075that you can log in to as though they were local.
2076
2077Files are specified to @value{tramp} using a formalized syntax specifying the
2078details of the system to connect to. This is similar to the syntax used
2079by the @value{ftppackagename} package.
2080
2081@cindex type-ahead
2082Something that might happen which surprises you is that
2083@value{emacsname} remembers all your keystrokes, so if you see a
2084password prompt from @value{emacsname}, say, and hit @kbd{@key{RET}}
2085twice instead of once, then the second keystroke will be processed by
2086@value{emacsname} after @value{tramp} has done its thing. Why, this
2087type-ahead is normal behavior, you say. Right you are, but be aware
2088that opening a remote file might take quite a while, maybe half a
2089minute when a connection needs to be opened. Maybe after half a
2090minute you have already forgotten that you hit that key!
2091
2092@menu
2093* Filename Syntax:: @value{tramp} filename conventions.
2094* Alternative Syntax:: URL-like filename syntax.
2095* Filename completion:: Filename completion.
2096* Remote processes:: Integration with other @value{emacsname} packages.
dd753688 2097* Cleanup remote connections:: Cleanup remote connections.
4009494e
GM
2098@end menu
2099
2100
2101@node Filename Syntax
2102@section @value{tramp} filename conventions
2103@cindex filename syntax
2104@cindex filename examples
2105
2106To access the file @var{localname} on the remote machine @var{machine}
2107you would specify the filename @file{@trampfn{, , machine,
2108localname}}. This will connect to @var{machine} and transfer the file
2109using the default method. @xref{Default Method}.
2110
2111Some examples of @value{tramp} filenames are shown below.
2112
2113@table @file
2114@item @trampfn{, , melancholia, .emacs}
2115Edit the file @file{.emacs} in your home directory on the machine
2116@code{melancholia}.
2117
2118@item @trampfn{, , melancholia.danann.net, .emacs}
2119This edits the same file, using the fully qualified domain name of
2120the machine.
2121
2122@item @trampfn{, , melancholia, ~/.emacs}
2123This also edits the same file --- the @file{~} is expanded to your
2124home directory on the remote machine, just like it is locally.
2125
2126@item @trampfn{, , melancholia, ~daniel/.emacs}
2127This edits the file @file{.emacs} in the home directory of the user
2128@code{daniel} on the machine @code{melancholia}. The @file{~<user>}
2129construct is expanded to the home directory of that user on the remote
2130machine.
2131
2132@item @trampfn{, , melancholia, /etc/squid.conf}
2133This edits the file @file{/etc/squid.conf} on the machine
2134@code{melancholia}.
2135
2136@end table
2137
4a0cf14f
MA
2138@var{machine} can also be an IPv4 or IPv6 address, like in
2139@file{@trampfn{, , 127.0.0.1, .emacs}} or @file{@trampfn{, ,
2140@value{ipv6prefix}::1@value{ipv6postfix}, .emacs}}.
2141@ifset emacs
2142For syntactical reasons, IPv6 addresses must be embedded in square
2143brackets @file{@value{ipv6prefix}} and @file{@value{ipv6postfix}}.
2144@end ifset
2145
4009494e
GM
2146Unless you specify a different name to use, @value{tramp} will use the
2147current local user name as the remote user name to log in with. If you
2148need to log in as a different user, you can specify the user name as
2149part of the filename.
2150
2151To log in to the remote machine as a specific user, you use the syntax
2152@file{@trampfn{, user, machine, path/to.file}}. That means that
2153connecting to @code{melancholia} as @code{daniel} and editing
2154@file{.emacs} in your home directory you would specify
2155@file{@trampfn{, daniel, melancholia, .emacs}}.
2156
2157It is also possible to specify other file transfer methods
193e6828
MA
2158(@pxref{Inline methods}, @pxref{External methods}) as part of the
2159filename.
4009494e
GM
2160@ifset emacs
2161This is done by putting the method before the user and host name, as
2162in @file{@value{prefix}@var{method}@value{postfixhop}} (Note the
2163trailing colon).
2164@end ifset
2165@ifset xemacs
2166This is done by replacing the initial @file{@value{prefix}} with
2167@file{@value{prefix}<method>@value{postfixhop}}. (Note the trailing
2168slash!).
2169@end ifset
2170The user, machine and file specification remain the same.
2171
2172So, to connect to the machine @code{melancholia} as @code{daniel},
2173using the @option{ssh} method to transfer files, and edit
2174@file{.emacs} in my home directory I would specify the filename
2175@file{@trampfn{ssh, daniel, melancholia, .emacs}}.
2176
2177
2178@node Alternative Syntax
2179@section URL-like filename syntax
2180@cindex filename syntax
2181@cindex filename examples
2182
2183Additionally to the syntax described in the previous chapter, it is
2184possible to use a URL-like syntax for @value{tramp}. This can be
2185switched on by customizing the variable @code{tramp-syntax}. Please
2186note that this feature is experimental for the time being.
2187
2188The variable @code{tramp-syntax} must be set before requiring @value{tramp}:
2189
2190@lisp
2191(setq tramp-syntax 'url)
2192(require 'tramp)
2193@end lisp
2194
2195Then, a @value{tramp} filename would look like this:
2196@file{/@var{method}://@var{user}@@@var{machine}:@var{port}/@var{path/to.file}}.
2197@file{/@var{method}://} is mandatory, all other parts are optional.
2198@file{:@var{port}} is useful for methods only who support this.
2199
2200The last example from the previous section would look like this:
2201@file{/ssh://daniel@@melancholia/.emacs}.
2202
2203For the time being, @code{tramp-syntax} can have the following values:
2204
2205@itemize @w{}
2206@ifset emacs
2207@item @code{ftp} -- That is the default syntax
2208@item @code{url} -- URL-like syntax
2209@end ifset
2210@ifset xemacs
2211@item @code{sep} -- That is the default syntax
2212@item @code{url} -- URL-like syntax
2213@item @code{ftp} -- EFS-like syntax
2214@end ifset
2215@end itemize
2216
2217
2218@node Filename completion
2219@section Filename completion
2220@cindex filename completion
2221
2222Filename completion works with @value{tramp} for completion of method
2223names, of user names and of machine names as well as for completion of
2224file names on remote machines.
2225@ifset emacs
2c81b468 2226In order to enable this, Partial Completion mode must be set on.
4009494e
GM
2227@ifinfo
2228@xref{Completion Options, , , @value{emacsdir}}.
2229@end ifinfo
2230@end ifset
2231
2232If you, for example, type @kbd{C-x C-f @value{prefix}t
2233@key{TAB}}, @value{tramp} might give you as result the choice for
2234
2235@example
4a0cf14f 2236@multitable {@trampfn{telnet, , melancholia.danann.net,}} {@trampfn{telnet, , 192.168.0.1,}}
4009494e 2237@ifset emacs
4a0cf14f
MA
2238@item @value{prefixhop}telnet@value{postfixhop} @tab tmp/
2239@item @value{prefixhop}toto@value{postfix} @tab
4009494e
GM
2240@end ifset
2241@ifset xemacs
4a0cf14f 2242@item @value{prefixhop}telnet@value{postfixhop} @tab @value{prefixhop}toto@value{postfix}
4009494e 2243@end ifset
4a0cf14f 2244@end multitable
4009494e
GM
2245@end example
2246
2247@samp{@value{prefixhop}telnet@value{postfixhop}}
2248is a possible completion for the respective method,
2249@ifset emacs
2250@samp{tmp/} stands for the directory @file{/tmp} on your local
2251machine,
2252@end ifset
2253and @samp{@value{prefixhop}toto@value{postfix}}
2254might be a host @value{tramp} has detected in your @file{~/.ssh/known_hosts}
2255file (given you're using default method @option{ssh}).
2256
2257If you go on to type @kbd{e @key{TAB}}, the minibuffer is completed to
2258@samp{@value{prefix}telnet@value{postfixhop}}.
2259Next @kbd{@key{TAB}} brings you all machine names @value{tramp} detects in
2260your @file{/etc/hosts} file, let's say
2261
2262@example
4a0cf14f
MA
2263@multitable {@trampfn{telnet, , melancholia.danann.net,}} {@trampfn{telnet, , 192.168.0.1,}}
2264@item @trampfn{telnet, , 127.0.0.1,} @tab @trampfn{telnet, , 192.168.0.1,}
2265@item @trampfn{telnet, , @value{ipv6prefix}::1@value{ipv6postfix},} @tab @trampfn{telnet, , localhost,}
2266@item @trampfn{telnet, , melancholia.danann.net,} @tab @trampfn{telnet, , melancholia,}
2267@end multitable
4009494e
GM
2268@end example
2269
2270Now you can choose the desired machine, and you can continue to
2271complete file names on that machine.
2272
2273If the configuration files (@pxref{Customizing Completion}), which
2274@value{tramp} uses for analysis of completion, offer user names, those user
2275names will be taken into account as well.
2276
2277Remote machines, which have been visited in the past and kept
2278persistently (@pxref{Connection caching}), will be offered too.
2279
2280Once the remote machine identification is completed, it comes to
2281filename completion on the remote host. This works pretty much like
2282for files on the local host, with the exception that minibuffer
2283killing via a double-slash works only on the filename part, except
2284that filename part starts with @file{//}.
b048d478 2285@ifset emacs
fffa137c 2286A triple-slash stands for the default behavior.
b048d478 2287@end ifset
4009494e
GM
2288@ifinfo
2289@xref{Minibuffer File, , , @value{emacsdir}}.
2290@end ifinfo
2291
b048d478
MA
2292@noindent
2293Example:
2294
2295@example
4009494e 2296@ifset emacs
b048d478
MA
2297@kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin//etc} @key{TAB}}
2298 @print{} @trampfn{telnet, , melancholia, /etc}
2299
2300@kbd{C-x C-f @trampfn{telnet, , melancholia, //etc} @key{TAB}}
2301 @print{} /etc
2302
2303@kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin///etc} @key{TAB}}
2304 @print{} /etc
4009494e
GM
2305@end ifset
2306
2307@ifset xemacs
b048d478
MA
2308@kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin//}}
2309 @print{} @trampfn{telnet, , melancholia, /}
2310
2311@kbd{C-x C-f @trampfn{telnet, , melancholia, //}}
2312 @print{} /
4009494e 2313@end ifset
b048d478
MA
2314@end example
2315
2316A remote directory might have changed its contents out of
2317@value{emacsname} control, for example by creation or deletion of
2318files by other processes. Therefore, during filename completion the
2319remote directory contents is reread regularly in order to detect such
2320changes, which would be invisible otherwise (@pxref{Connection caching}).
2321
2322@defopt tramp-completion-reread-directory-timeout
2323This variable defines the number of seconds since last remote command
2324before rereading a directory contents. A value of 0 would require an
2325immediate reread during filename completion, @code{nil} means to use
2326always cached values for the directory contents.
2327@end defopt
4009494e
GM
2328
2329
2330@node Remote processes
2331@section Integration with other @value{emacsname} packages.
2332@cindex compile
2333@cindex recompile
2334
2335@value{tramp} supports running processes on a remote host. This
2336allows to exploit @value{emacsname} packages without modification for
2337remote file names. It does not work for the @option{ftp} and
2338@option{smb} methods.
2339
2340Remote processes are started when a corresponding command is executed
2341from a buffer belonging to a remote file or directory. Up to now, the
2342packages @file{compile.el} (commands like @code{compile} and
2343@code{grep}) and @file{gud.el} (@code{gdb} or @code{perldb}) have been
2344integrated. Integration of further packages is planned, any help for
2345this is welcome!
2346
2347When your program is not found in the default search path
2348@value{tramp} sets on the remote machine, you should either use an
2349absolute path, or extend @code{tramp-remote-path} (see @ref{Remote
2350Programs}):
2351
2352@lisp
2353(add-to-list 'tramp-remote-path "~/bin")
2354(add-to-list 'tramp-remote-path "/appli/pub/bin")
2355@end lisp
2356
2357The environment for your program can be adapted by customizing
2358@code{tramp-remote-process-environment}. This variable is a list of
2359strings. It is structured like @code{process-environment}. Each
2360element is a string of the form ENVVARNAME=VALUE. An entry
2361ENVVARNAME= disables the corresponding environment variable, which
2362might have been set in your init file like @file{~/.profile}.
2363
2364@noindent
2365Adding an entry can be performed via @code{add-to-list}:
2366
2367@lisp
2368(add-to-list 'tramp-remote-process-environment "JAVA_HOME=/opt/java")
2369@end lisp
2370
2371Changing or removing an existing entry is not encouraged. The default
2372values are chosen for proper @value{tramp} work. Nevertheless, if for
2373example a paranoid system administrator disallows changing the
2374@var{$HISTORY} environment variable, you can customize
2375@code{tramp-remote-process-environment}, or you can apply the
2376following code in your @file{.emacs}:
2377
2378@lisp
2379(let ((process-environment tramp-remote-process-environment))
2380 (setenv "HISTORY" nil)
2381 (setq tramp-remote-process-environment process-environment))
2382@end lisp
2383
2384If you use other @value{emacsname} packages which do not run
2385out-of-the-box on a remote host, please let us know. We will try to
2386integrate them as well. @xref{Bug Reports}.
2387
2388
f18ce50c
MA
2389@subsection Running shell-command on a remote host
2390@cindex shell-command
2391
2392@code{shell-command} allows to execute commands in a shell, either
2393synchronously, either asynchronously. This works also on remote
2394hosts. Example:
2395
2396@example
2397@kbd{C-x C-f @trampfn{sudo, , , } @key{RET}}
2398@kbd{M-! tail -f /var/log/syslog.log & @key{RET}}
2399@end example
2400
2401You will see the buffer @file{*Async Shell Command*}, containing the
2402continous output of the @command{tail} command.
2403
2404
4009494e
GM
2405@subsection Running eshell on a remote host
2406@cindex eshell
2407
2408@value{tramp} is integrated into @file{eshell.el}. That is, you can
2409open an interactive shell on your remote host, and run commands there.
2410After you have started @code{eshell}, you could perform commands like
2411this:
2412
2413@example
2414@b{~ $} cd @trampfn{sudo, , , /etc} @key{RET}
2415@b{@trampfn{sudo, root, host, /etc} $} hostname @key{RET}
2416host
2417@b{@trampfn{sudo, root, host, /etc} $} id @key{RET}
2418uid=0(root) gid=0(root) groups=0(root)
2419@b{@trampfn{sudo, root, host, /etc} $} find-file shadow @key{RET}
2420#<buffer shadow>
2421@b{@trampfn{sudo, root, host, /etc} $}
2422@end example
2423
2424
2425@anchor{Running a debugger on a remote host}
2426@subsection Running a debugger on a remote host
2427@cindex gud
2428@cindex gdb
2429@cindex perldb
2430
2431@file{gud.el} offers an unified interface to several symbolic
2432debuggers
2433@ifset emacs
2434@ifinfo
2435(@ref{Debuggers, , , @value{emacsdir}}).
2436@end ifinfo
2437@end ifset
2438With @value{tramp}, it is possible to debug programs on
2439remote hosts. You can call @code{gdb} with a remote file name:
2440
2441@example
2442@kbd{M-x gdb @key{RET}}
2443@b{Run gdb (like this):} gdb --annotate=3 @trampfn{ssh, , host, ~/myprog} @key{RET}
2444@end example
2445
2446The file name can also be relative to a remote default directory.
2447Given you are in a buffer that belongs to the remote directory
2448@trampfn{ssh, , host, /home/user}, you could call
2449
2450@example
2451@kbd{M-x perldb @key{RET}}
2452@b{Run perldb (like this):} perl -d myprog.pl @key{RET}
2453@end example
2454
2455It is not possible to use just the absolute local part of a remote
2456file name as program to debug, like @kbd{perl -d
2457/home/user/myprog.pl}, though.
2458
2459Arguments of the program to be debugged are taken literally. That
f18ce50c 2460means, file names as arguments must be given as ordinary relative or
4009494e
GM
2461absolute file names, without any remote specification.
2462
2463
dd753688
MA
2464@node Cleanup remote connections
2465@section Cleanup remote connections.
2466@cindex cleanup
2467
2468Sometimes it is useful to cleanup remote connections. The following
2469commands support this.
2470
2471@deffn Command tramp-cleanup-connection vec
2472This command flushes all connection related objects. @option{vec} is
2473the internal representation of a remote connection. Called
2474interactively, the command offers all active remote connections in the
2475minibuffer as remote file name prefix like @file{@trampfn{method,
2476user, host, }}. The cleanup includes password cache (@pxref{Password
a06a4a12 2477handling}), file cache, connection cache (@pxref{Connection caching}),
dd753688
MA
2478connection buffers.
2479@end deffn
2480
2481@deffn Command tramp-cleanup-all-connections
2482This command flushes objects for all active remote connections. The
2483same objects are removed as in @code{tramp-cleanup-connection}.
2484@end deffn
2485
2486@deffn Command tramp-cleanup-all-buffers
2487Like in @code{tramp-cleanup-all-connections}, all remote connections
2488are cleaned up. Additionally all buffers, which are related to a
2489remote connection, are killed.
2490@end deffn
2491
2492
4009494e
GM
2493@node Bug Reports
2494@chapter Reporting Bugs and Problems
2495@cindex bug reports
2496
2497Bugs and problems with @value{tramp} are actively worked on by the
2498development team. Feature requests and suggestions are also more than
2499welcome.
2500
2501The @value{tramp} mailing list is a great place to get information on
2502working with @value{tramp}, solving problems and general discussion
2503and advice on topics relating to the package. It is moderated so
2504non-subscribers can post but messages will be delayed, possibly up to
250548 hours (or longer in case of holidays), until the moderator approves
2506your message.
2507
2508The mailing list is at @email{tramp-devel@@gnu.org}. Messages sent to
2509this address go to all the subscribers. This is @emph{not} the address
2510to send subscription requests to.
2511
2512Subscribing to the list is performed via
2513@uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/,
2514the @value{tramp} Mail Subscription Page}.
2515
dd753688 2516@findex tramp-bug
4009494e
GM
2517To report a bug in @value{tramp}, you should execute @kbd{M-x
2518tramp-bug}. This will automatically generate a buffer with the details
2519of your system and @value{tramp} version.
2520
2521When submitting a bug report, please try to describe in excruciating
2522detail the steps required to reproduce the problem, the setup of the
2523remote machine and any special conditions that exist. You should also
2524check that your problem is not described already in @xref{Frequently
2525Asked Questions}.
2526
2527If you can identify a minimal test case that reproduces the problem,
2528include that with your bug report. This will make it much easier for
2529the development team to analyze and correct the problem.
2530
2531Before reporting the bug, you should set the verbosity level to 6
2532(@pxref{Traces and Profiles, Traces}) in the @file{~/.emacs} file and
2533repeat the bug. Then, include the contents of the @file{*tramp/foo*}
2534and @file{*debug tramp/foo*} buffers in your bug report. A verbosity
2535level greater than 6 will produce a very huge debug buffer, which is
2536mostly not necessary for the analysis.
2537
2538Please be aware that, with a verbosity level of 6 or greater, the
2539contents of files and directories will be included in the debug
2540buffer. Passwords you've typed will never be included there.
2541
2542
2543@node Frequently Asked Questions
2544@chapter Frequently Asked Questions
2545@cindex frequently asked questions
2546@cindex FAQ
2547
2548@itemize @bullet
2549@item
2550Where can I get the latest @value{tramp}?
2551
2552@value{tramp} is available under the URL below.
2553
2554@noindent
2555@uref{ftp://ftp.gnu.org/gnu/tramp/}
2556
2557@noindent
2558There is also a Savannah project page.
2559
2560@noindent
2561@uref{http://savannah.gnu.org/projects/tramp/}
2562
2563
2564@item
2565Which systems does it work on?
2566
2567The package has been used successfully on GNU Emacs 21, GNU Emacs 22
2568and XEmacs 21 (starting with 21.4). Gateway methods are supported for
2569GNU Emacs 22 only.
2570
2571The package was intended to work on Unix, and it really expects a
2572Unix-like system on the remote end (except the @option{smb} method),
2573but some people seemed to have some success getting it to work on MS
2574Windows NT/2000/XP @value{emacsname}.
2575
2576There is some informations on @value{tramp} on NT at the following URL;
2577many thanks to Joe Stoy for providing the information:
2578@uref{ftp://ftp.comlab.ox.ac.uk/tmp/Joe.Stoy/}
2579
2580@c The link is broken. I've contacted Tom for clarification. Michael.
2581@ignore
2582The above mostly contains patches to old ssh versions; Tom Roche has a
2583Web page with instructions:
2584@uref{http://www4.ncsu.edu/~tlroche/plinkTramp.html}
2585@end ignore
2586
2587@item
2588How could I speed up @value{tramp}?
2589
2590In the backstage, @value{tramp} needs a lot of operations on the
2591remote host. The time for transferring data from and to the remote
2592host as well as the time needed to perform the operations there count.
2593In order to speed up @value{tramp}, one could either try to avoid some
2594of the operations, or one could try to improve their performance.
2595
193e6828 2596Use an external method, like @option{scpc}.
4009494e
GM
2597
2598Use caching. This is already enabled by default. Information about
2599the remote host as well as the remote files are cached for reuse. The
2600information about remote hosts is kept in the file specified in
2601@code{tramp-persistency-file-name}. Keep this file.
2602
2603Disable version control. If you access remote files which are not
2604under version control, a lot of check operations can be avoided by
2605disabling VC. This can be achieved by
2606
2607@lisp
2608(setq vc-handled-backends nil)
2609@end lisp
2610
2611Disable excessive traces. The default trace level of @value{tramp},
2612defined in the variable @code{tramp-verbose}, is 3. You should
2613increase this level only temporarily, hunting bugs.
2614
2615
2616@item
2617@value{tramp} does not connect to the remote host
2618
2619When @value{tramp} does not connect to the remote host, there are two
2620reasons heading the bug mailing list:
2621
2622@itemize @minus
2623
2624@item
2625Unknown characters in the prompt
2626
2627@value{tramp} needs to recognize the prompt on the remote machine
2628after execution any command. This is not possible, when the prompt
2629contains unknown characters like escape sequences for coloring. This
2630should be avoided on the remote side. @xref{Remote shell setup}. for
2631setting the regular expression detecting the prompt.
2632
2633You can check your settings after an unsuccessful connection by
2634switching to the @value{tramp} connection buffer @file{*tramp/foo*},
2635setting the cursor at the top of the buffer, and applying the expression
2636
2637@example
2638@kbd{M-: (re-search-forward (concat tramp-shell-prompt-pattern "$"))}
2639@end example
2640
2641If it fails, or the cursor is not moved at the end of the buffer, your
135305ed 2642prompt is not recognized correctly.
4009494e
GM
2643
2644A special problem is the zsh, which uses left-hand side and right-hand
2645side prompts in parallel. Therefore, it is necessary to disable the
2646zsh line editor on the remote host. You shall add to @file{~/.zshrc}
2647the following command:
2648
2649@example
2650[ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
2651@end example
2652
2653
2654@item
2655@value{tramp} doesn't transfer strings with more than 500 characters
2656correctly
2657
2658On some few systems, the implementation of @code{process-send-string}
2659seems to be broken for longer strings. It is reported for HP-UX,
2660FreeBSD and Tru64 Unix, for example. This case, you should customize
2661the variable @code{tramp-chunksize} to 500. For a description how to
2662determine whether this is necessary see the documentation of
2663@code{tramp-chunksize}.
2664
2665Additionally, it will be useful to set @code{file-precious-flag} to
2666@code{t} for @value{tramp} files. Then the file contents will be
2667written into a temporary file first, which is checked for correct
2668checksum.
2669@ifinfo
2670@pxref{Saving Buffers, , , elisp}
2671@end ifinfo
2672
2673@lisp
2674(add-hook
2675 'find-file-hooks
2676 '(lambda ()
2677 (when (file-remote-p default-directory)
2678 (set (make-local-variable 'file-precious-flag) t))))
2679@end lisp
2680
2681@end itemize
2682
2683
2684@item
2685File name completion does not work with @value{tramp}
2686
2687When you log in to the remote machine, do you see the output of
2688@command{ls} in color? If so, this may be the cause of your problems.
2689
2690@command{ls} outputs @acronym{ANSI} escape sequences that your terminal
2691emulator interprets to set the colors. These escape sequences will
2692confuse @value{tramp} however.
2693
2694In your @file{.bashrc}, @file{.profile} or equivalent on the remote
2695machine you probably have an alias configured that adds the option
2696@option{--color=yes} or @option{--color=auto}.
2697
2698You should remove that alias and ensure that a new login @emph{does not}
2699display the output of @command{ls} in color. If you still cannot use
2700filename completion, report a bug to the @value{tramp} developers.
2701
2702
2703@item
2704File name completion does not work in large directories
2705
2706@value{tramp} uses globbing for some operations. (Globbing means to use the
2707shell to expand wildcards such as `*.c'.) This might create long
2708command lines, especially in directories with many files. Some shells
2709choke on long command lines, or don't cope well with the globbing
2710itself.
2711
2712If you have a large directory on the remote end, you may wish to execute
2713a command like @samp{ls -d * ..?* > /dev/null} and see if it hangs.
2714Note that you must first start the right shell, which might be
2715@command{/bin/sh}, @command{ksh} or @command{bash}, depending on which
2716of those supports tilde expansion.
2717
2718
2719@item
2720How can I get notified when @value{tramp} file transfers are complete?
2721
2722The following snippet can be put in your @file{~/.emacs} file. It
2723makes @value{emacsname} beep after reading from or writing to the
2724remote host.
2725
2726@lisp
2727(defadvice tramp-handle-write-region
2728 (after tramp-write-beep-advice activate)
e1176b47
MA
2729 "Make tramp beep after writing a file."
2730 (interactive)
2731 (beep))
4009494e
GM
2732
2733(defadvice tramp-handle-do-copy-or-rename-file
2734 (after tramp-copy-beep-advice activate)
e1176b47
MA
2735 "Make tramp beep after copying a file."
2736 (interactive)
2737 (beep))
4009494e
GM
2738
2739(defadvice tramp-handle-insert-file-contents
e1176b47
MA
2740 (after tramp-insert-beep-advice activate)
2741 "Make tramp beep after inserting a file."
2742 (interactive)
2743 (beep))
2744@end lisp
2745
2746
2747@ifset emacs
2748@item
2749I'ld like to get a Visual Warning when working in a sudo:ed context
2750
2751When you are working with @samp{root} privileges, it might be useful
2752to get an indication in the buffer's modeline. The following code,
2753tested with @value{emacsname} 22.1, does the job. You should put it
2754into your @file{~/.emacs}:
2755
2756@lisp
2757(defun my-mode-line-function ()
2758 (when (string-match "^/su\\(do\\)?:" default-directory)
2759 (setq mode-line-format
2760 (format-mode-line mode-line-format 'font-lock-warning-face))))
2761
2762(add-hook 'find-file-hooks 'my-mode-line-function)
2763(add-hook 'dired-mode-hook 'my-mode-line-function)
4009494e 2764@end lisp
e1176b47 2765@end ifset
4009494e
GM
2766
2767
2768@ifset emacs
2769@item
2770I'ld like to see a host indication in the mode line when I'm remote
2771
2772The following code has been tested with @value{emacsname} 22.1. You
2773should put it into your @file{~/.emacs}:
2774
2775@lisp
2776(defconst my-mode-line-buffer-identification
2777 (list
2778 '(:eval
2779 (let ((host-name
2780 (if (file-remote-p default-directory)
2781 (tramp-file-name-host
2782 (tramp-dissect-file-name default-directory))
2783 (system-name))))
2784 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
2785 (substring host-name 0 (match-beginning 1))
2786 host-name)))
2787 ": %12b"))
2788
2789(setq-default
2790 mode-line-buffer-identification
2791 my-mode-line-buffer-identification)
2792
2793(add-hook
2794 'dired-mode-hook
2795 '(lambda ()
2796 (setq
2797 mode-line-buffer-identification
2798 my-mode-line-buffer-identification)))
2799@end lisp
2800
2801Since @value{emacsname} 23.1, the mode line contains an indication if
2802@code{default-directory} for the current buffer is on a remote host.
2803The corresponding tooltip includes the name of that host. If you
2804still want the host name as part of the mode line, you can use the
2805example above, but the @code{:eval} clause can be simplified:
2806
2807@lisp
2808 '(:eval
2809 (let ((host-name
2810 (or (file-remote-p default-directory 'host)
2811 (system-name))))
2812 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
2813 (substring host-name 0 (match-beginning 1))
2814 host-name)))
2815@end lisp
2816@end ifset
2817
2818
2819@ifset emacs
2820@item
2821My remote host does not understand default directory listing options
2822
2823@value{emacsname} computes the @command{dired} options depending on
2824the local host you are working. If your @command{ls} command on the
2825remote host does not understand those options, you can change them
2826like this:
2827
2828@lisp
2829(add-hook
2830 'dired-before-readin-hook
2831 '(lambda ()
2832 (when (file-remote-p default-directory)
2833 (setq dired-actual-switches "-al"))))
2834@end lisp
2835@end ifset
2836
2837
2838@item
2839There's this @file{~/.sh_history} file on the remote host which keeps
2840growing and growing. What's that?
2841
2842Sometimes, @value{tramp} starts @command{ksh} on the remote host for
2843tilde expansion. Maybe @command{ksh} saves the history by default.
2844@value{tramp} tries to turn off saving the history, but maybe you have
2845to help. For example, you could put this in your @file{.kshrc}:
2846
2847@example
2848if [ -f $HOME/.sh_history ] ; then
2849 /bin/rm $HOME/.sh_history
2850fi
2851if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
2852 unset HISTFILE
2853fi
2854if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
2855 unset HISTSIZE
2856fi
2857@end example
2858
2859
2860@item There are longish file names to type. How to shorten this?
2861
2862Let's say you need regularly access to @file{@trampfn{ssh, news,
2863news.my.domain, /opt/news/etc}}, which is boring to type again and
2864again. The following approaches can be mixed:
2865
2866@enumerate
2867
2868@item Use default values for method and user name:
2869
2870You can define default methods and user names for hosts,
2871(@pxref{Default Method}, @pxref{Default User}):
2872
2873@lisp
2874(setq tramp-default-method "ssh"
2875 tramp-default-user "news")
2876@end lisp
2877
2878The file name left to type would be
2879@kbd{C-x C-f @trampfn{, , news.my.domain, /opt/news/etc}}.
2880
2881Note, that there are some useful settings already. Accessing your
2882local host as @samp{root} user, is possible just by @kbd{C-x C-f
2883@trampfn{su, , ,}}.
2884
2885@item Use configuration possibilities of your method:
2886
2887Several connection methods (i.e. the programs used) offer powerful
2888configuration possibilities (@pxref{Customizing Completion}). In the
2889given case, this could be @file{~/.ssh/config}:
2890
2891@example
2892Host xy
2893 HostName news.my.domain
2894 User news
2895@end example
2896
2897The file name left to type would be @kbd{C-x C-f @trampfn{ssh, , xy,
2898/opt/news/etc}}. Depending on files in your directories, it is even
9bbb9638 2899possible to complete the host name with @kbd{C-x C-f
4009494e
GM
2900@value{prefix}ssh@value{postfixhop}x @key{TAB}}.
2901
2902@item Use environment variables:
2903
2904File names typed in the minibuffer can be expanded by environment
2905variables. You can set them outside @value{emacsname}, or even with
2906Lisp:
2907
2908@lisp
2909(setenv "xy" "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}")
2910@end lisp
2911
2912Then you need simply to type @kbd{C-x C-f $xy @key{RET}}, and here you
2913are. The disadvantage is, that you cannot edit the file name, because
2914environment variables are not expanded during editing in the
2915minibuffer.
2916
2917@item Define own keys:
2918
2919You can define your own key sequences in @value{emacsname}, which can
2920be used instead of @kbd{C-x C-f}:
2921
2922@lisp
2923(global-set-key
2924 [(control x) (control y)]
2925 (lambda ()
2926 (interactive)
2927 (find-file
2928 (read-file-name
2929 "Find Tramp file: "
2930 "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))))
2931@end lisp
2932
2933Simply typing @kbd{C-x C-y} would initialize the minibuffer for
2934editing with your beloved file name.
2935
2936See also @uref{http://www.emacswiki.org/cgi-bin/wiki/TrampMode, the
2937Emacs Wiki} for a more comprehensive example.
2938
2939@item Define own abbreviation (1):
2940
2941It is possible to define an own abbreviation list for expanding file
2942names:
2943
2944@lisp
2945(add-to-list
2946 'directory-abbrev-alist
2947 '("^/xy" . "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))
2948@end lisp
2949
2950This shortens the file openening command to @kbd{C-x C-f /xy
2951@key{RET}}. The disadvantage is, again, that you cannot edit the file
2952name, because the expansion happens after entering the file name only.
2953
2954@item Define own abbreviation (2):
2955
2956The @code{abbrev-mode} gives more flexibility for editing the
2957minibuffer:
2958
2959@lisp
2960(define-abbrev-table 'my-tramp-abbrev-table
2961 '(("xy" "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}")))
2962
2963(add-hook
2964 'minibuffer-setup-hook
2965 '(lambda ()
2966 (abbrev-mode 1)
2967 (setq local-abbrev-table my-tramp-abbrev-table)))
2968
2969(defadvice minibuffer-complete
2970 (before my-minibuffer-complete activate)
2971 (expand-abbrev))
2972
2973;; If you use partial-completion-mode
2974(defadvice PC-do-completion
2975 (before my-PC-do-completion activate)
2976 (expand-abbrev))
2977@end lisp
2978
2979After entering @kbd{C-x C-f xy @key{TAB}}, the minibuffer is
2980expanded, and you can continue editing.
2981
2982@item Use bookmarks:
2983
2984Bookmarks can be used to visit Tramp files or directories.
2985@ifinfo
2986@pxref{Bookmarks, , , @value{emacsdir}}
2987@end ifinfo
2988
2989When you have opened @file{@trampfn{ssh, news, news.my.domain,
2990/opt/news/etc/}}, you should save the bookmark via
2991@ifset emacs
2992@kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{set}}.
2993@end ifset
2994@ifset xemacs
2995@kbd{@key{menu-bar} @key{view} @key{bookmarks} @key{set}}.
2996@end ifset
2997
2998Later on, you can always navigate to that bookmark via
2999@ifset emacs
3000@kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{jump}}.
3001@end ifset
3002@ifset xemacs
3003@kbd{@key{menu-bar} @key{view} @key{bookmarks} @key{jump}}.
3004@end ifset
3005
3006@item Use recent files:
3007
3008@ifset emacs
3009@file{recentf}
3010@end ifset
3011@ifset xemacs
3012@file{recent-files}
3013@end ifset
3014remembers visited places.
3015@ifinfo
3016@ifset emacs
3017@pxref{File Conveniences, , , @value{emacsdir}}
3018@end ifset
3019@ifset xemacs
3020@pxref{recent-files, , , edit-utils}
3021@end ifset
3022@end ifinfo
3023
3024You could keep remote file names in the recent list without checking
3025their readability through a remote access:
3026
3027@lisp
3028@ifset emacs
3029(recentf-mode 1)
3030@end ifset
3031@ifset xemacs
3032(recent-files-initialize)
3033(add-hook
3034 'find-file-hooks
3035 (lambda ()
3036 (when (file-remote-p (buffer-file-name))
3037 (recent-files-make-permanent)))
3038 'append)
3039@end ifset
3040@end lisp
3041
3042The list of files opened recently is reachable via
3043@ifset emacs
3044@kbd{@key{menu-bar} @key{file} @key{Open Recent}}.
3045@end ifset
3046@ifset xemacs
3047@kbd{@key{menu-bar} @key{Recent Files}}.
3048@end ifset
3049
3050@ifset emacs
3051@item Use filecache:
3052
3053@file{filecache} remembers visited places. Add the directory into
3054the cache:
3055
3056@lisp
3057(eval-after-load "filecache"
3058 '(file-cache-add-directory
3059 "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))
3060@end lisp
3061
3062Whenever you want to load a file, you can enter @kbd{C-x C-f
3063C-@key{TAB}} in the minibuffer. The completion is done for the given
3064directory.
3065@end ifset
3066
3067@ifset emacs
3068@item Use bbdb:
3069
3070@file{bbdb} has a built-in feature for @value{ftppackagename} files,
3071which works also for @value{tramp}.
3072@ifinfo
3073@pxref{bbdb-ftp, Storing FTP sites in the BBDB, , bbdb}
3074@end ifinfo
3075
3076You need to load @file{bbdb}:
3077
3078@lisp
3079(require 'bbdb)
3080(bbdb-initialize)
3081@end lisp
3082
3083Then you can create a BBDB entry via @kbd{M-x bbdb-create-ftp-site}.
3084Because BBDB is not prepared for @value{tramp} syntax, you must
3085specify a method together with the user name, when needed. Example:
3086
3087@example
3088@kbd{M-x bbdb-create-ftp-site @key{RET}}
3089@b{Ftp Site:} news.my.domain @key{RET}
3090@b{Ftp Directory:} /opt/news/etc/ @key{RET}
3091@b{Ftp Username:} ssh@value{postfixhop}news @key{RET}
3092@b{Company:} @key{RET}
3093@b{Additional Comments:} @key{RET}
3094@end example
3095
3096When you have opened your BBDB buffer, you can access such an entry by
3097pressing the key @key{F}.
3098@end ifset
3099
3100@end enumerate
3101
3102I would like to thank all @value{tramp} users, who have contributed to
3103the different recipes!
3104
3105
3106@item
3107How can I disable @value{tramp}?
3108
3109Shame on you, why did you read until now?
3110
586b90f1
MA
3111@itemize @minus
3112
3113@item
4009494e
GM
3114@ifset emacs
3115If you just want to have @value{ftppackagename} as default remote
3116files access package, you should apply the following code:
3117
3118@lisp
3119(setq tramp-default-method "ftp")
3120@end lisp
3121@end ifset
3122
586b90f1
MA
3123@item
3124In order to disable
3125@ifset emacs
3126@value{tramp} (and @value{ftppackagename}),
3127@end ifset
3128@ifset xemacs
3129@value{tramp},
3130@end ifset
3131you must set @code{tramp-mode} to @code{nil}:
3132
3133@lisp
3134(setq tramp-mode nil)
3135@end lisp
3136
3137@item
4009494e
GM
3138Unloading @value{tramp} can be achieved by applying @kbd{M-x
3139tramp-unload-tramp}.
3140@ifset emacs
3141This resets also the @value{ftppackagename} plugins.
3142@end ifset
3143@end itemize
586b90f1 3144@end itemize
4009494e
GM
3145
3146
3147@c For the developer
3148@node Version Control
3149@chapter The inner workings of remote version control
3150@cindex Version Control
3151
3152Unlike @value{ftppackagename}, @value{tramp} has full shell access to the
3153remote machine. This makes it possible to provide version control for
3154files accessed under @value{tramp}.
3155
3156The actual version control binaries must be installed on the remote
3157machine, accessible in the directories specified in
3158@code{tramp-remote-path}.
3159
3160This transparent integration with the version control systems is one of
3161the most valuable features provided by @value{tramp}, but it is far from perfect.
3162Work is ongoing to improve the transparency of the system.
3163
3164@menu
3165* Version Controlled Files:: Determining if a file is under version control.
3166* Remote Commands:: Executing the version control commands on the remote machine.
3167* Changed workfiles:: Detecting if the working file has changed.
3168* Checking out files:: Bringing the workfile out of the repository.
3169* Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
3170@end menu
3171
3172
3173@node Version Controlled Files
3174@section Determining if a file is under version control
3175
3176The VC package uses the existence of on-disk revision control master
3177files to determine if a given file is under revision control. These file
3178tests happen on the remote machine through the standard @value{tramp} mechanisms.
3179
3180
3181@node Remote Commands
3182@section Executing the version control commands on the remote machine
3183
3184There are no hooks provided by VC to allow intercepting of the version
3185control command execution. The calls occur through the
3186@code{call-process} mechanism, a function that is somewhat more
3187efficient than the @code{shell-command} function but that does not
3188provide hooks for remote execution of commands.
3189
3190To work around this, the functions @code{vc-do-command} and
3191@code{vc-simple-command} have been advised to intercept requests for
3192operations on files accessed via @value{tramp}.
3193
3194In the case of a remote file, the @code{shell-command} interface is
3195used, with some wrapper code, to provide the same functionality on the
3196remote machine as would be seen on the local machine.
3197
3198
3199@node Changed workfiles
3200@section Detecting if the working file has changed
3201
3202As there is currently no way to get access to the mtime of a file on a
3203remote machine in a portable way, the @code{vc-workfile-unchanged-p}
3204function is advised to call an @value{tramp} specific function for remote files.
3205
3206The @code{tramp-vc-workfile-unchanged-p} function uses the functioning VC
3207diff functionality to determine if any changes have occurred between the
3208workfile and the version control master.
3209
3210This requires that a shell command be executed remotely, a process that
3211is notably heavier-weight than the mtime comparison used for local
3212files. Unfortunately, unless a portable solution to the issue is found,
3213this will remain the cost of remote version control.
3214
3215
3216@node Checking out files
3217@section Bringing the workfile out of the repository
3218
3219VC will, by default, check for remote files and refuse to act on them
3220when checking out files from the repository. To work around this
3221problem, the function @code{vc-checkout} knows about @value{tramp} files and
3222allows version control to occur.
3223
3224
3225@node Miscellaneous Version Control
3226@section Things related to Version Control that don't fit elsewhere
3227
3228Minor implementation details, &c.
3229
3230@menu
3231* Remote File Ownership:: How VC determines who owns a workfile.
3232* Back-end Versions:: How VC determines what release your RCS is.
3233@end menu
3234
3235
3236@node Remote File Ownership
3237@subsection How VC determines who owns a workfile
3238
3239@value{emacsname} provides the @code{user-login-name} function to
3240return the login name of the current user as well as mapping from
3241arbitrary user id values back to login names. The VC code uses this
3242functionality to map from the uid of the owner of a workfile to the
3243login name in some circumstances.
3244
3245This will not, for obvious reasons, work if the remote system has a
3246different set of logins. As such, it is necessary to delegate to the
3247remote machine the job of determining the login name associated with a
3248uid.
3249
3250Unfortunately, with the profusion of distributed management systems such
3251as @code{NIS}, @code{NIS+} and @code{NetInfo}, there is no simple,
3252reliable and portable method for performing this mapping.
3253
3254Thankfully, the only place in the VC code that depends on the mapping of
3255a uid to a login name is the @code{vc-file-owner} function. This returns
3256the login of the owner of the file as a string.
3257
3258This function has been advised to use the output of @command{ls} on the
3259remote machine to determine the login name, delegating the problem of
3260mapping the uid to the login to the remote system which should know more
3261about it than I do.
3262
3263
3264@node Back-end Versions
3265@subsection How VC determines what release your RCS is
3266
3267VC needs to know what release your revision control binaries you are
3268running as not all features VC supports are available with older
3269versions of @command{rcs(1)}, @command{cvs(1)} or @command{sccs(1)}.
3270
3271The default implementation of VC determines this value the first time it
3272is needed and then stores the value globally to avoid the overhead of
3273executing a process and parsing its output each time the information is
3274needed.
3275
3276Unfortunately, life is not quite so easy when remote version control
3277comes into the picture. Each remote machine may have a different version
3278of the version control tools and, while this is painful, we need to
3279ensure that unavailable features are not used remotely.
3280
3281To resolve this issue, @value{tramp} currently takes the sledgehammer
3282approach of making the release values of the revision control tools
3283local to each @value{tramp} buffer, forcing VC to determine these values
3284again each time a new file is visited.
3285
3286This has, quite obviously, some performance implications. Thankfully,
3287most of the common operations performed by VC do not actually require
3288that the remote version be known. This makes the problem far less
3289apparent.
3290
3291Eventually these values will be captured by @value{tramp} on a system by
3292system basis and the results cached to improve performance.
3293
3294
3295@node Files directories and localnames
3296@chapter How file names, directories and localnames are mangled and managed.
3297
3298@menu
3299* Localname deconstruction:: Breaking a localname into its components.
ea3fc256
MA
3300@ifset emacs
3301* External packages:: Integration with external Lisp packages.
3302@end ifset
4009494e
GM
3303@end menu
3304
3305
3306@node Localname deconstruction
3307@section Breaking a localname into its components.
3308
3309@value{tramp} file names are somewhat different, obviously, to ordinary file
3310names. As such, the lisp functions @code{file-name-directory} and
3311@code{file-name-nondirectory} are overridden within the @value{tramp}
3312package.
3313
3314Their replacements are reasonably simplistic in their approach. They
3315dissect the filename, call the original handler on the localname and
3316then rebuild the @value{tramp} file name with the result.
3317
3318This allows the platform specific hacks in the original handlers to take
3319effect while preserving the @value{tramp} file name information.
3320
3321
ea3fc256
MA
3322@ifset emacs
3323@node External packages
3324@section Integration with external Lisp packages.
3325
3326While reading filenames in the minibuffer, @value{tramp} must decide
3327whether it completes possible incomplete filenames, or not. Imagine
3328there is the following situation: You have typed @kbd{C-x C-f
3329@value{prefix}ssh@value{postfixhop} @key{TAB}}. @value{tramp} cannot
3330know, whether @option{ssh} is a method or a host name. It checks
3331therefore the last input character you have typed. If this is
3332@key{TAB}, @key{SPACE} or @kbd{?}, @value{tramp} assumes that you are
3333still in filename completion, and it does not connect to the possible
3334remote host @option{ssh}.
3335
3336@vindex tramp-completion-mode
3337External packages, which use other characters for completing filenames
3338in the minibuffer, must signal this to @value{tramp}. For this case,
3339the variable @code{tramp-completion-mode} can be bound temporarily to
3340a non-nil value.
3341
3342@lisp
3343(let ((tramp-completion-mode t))
3344 ...)
3345@end lisp
3346@end ifset
3347
3348
4009494e
GM
3349@node Traces and Profiles
3350@chapter How to Customize Traces
3351
3352All @value{tramp} messages are raised with a verbosity level. The
3353verbosity level can be any number between 0 and 10. Only messages with
3354a verbosity level less than or equal to @code{tramp-verbose} are
3355displayed.
3356
3357The verbosity levels are
3358
3359 @w{ 0} silent (no @value{tramp} messages at all)
3360@*@indent @w{ 1} errors
3361@*@indent @w{ 2} warnings
3362@*@indent @w{ 3} connection to remote hosts (default verbosity)
3363@*@indent @w{ 4} activities
3364@*@indent @w{ 5} internal
3365@*@indent @w{ 6} sent and received strings
3366@*@indent @w{ 7} file caching
3367@*@indent @w{ 8} connection properties
3368@*@indent @w{10} traces (huge)
3369
3370When @code{tramp-verbose} is greater than or equal to 4, the messages
3371are also written into a @value{tramp} debug buffer. This debug buffer
3372is useful for analysing problems; sending a @value{tramp} bug report
3373should be done with @code{tramp-verbose} set to a verbosity level of at
3374least 6 (@pxref{Bug Reports}).
3375
3376The debug buffer is in
3377@ifinfo
3378@ref{Outline Mode, , , @value{emacsdir}}.
3379@end ifinfo
3380@ifnotinfo
3381Outline Mode.
3382@end ifnotinfo
3383That means, you can change the level of messages to be viewed. If you
3384want, for example, see only messages up to verbosity level 5, you must
3385enter @kbd{C-u 6 C-c C-q}.
3386@ifinfo
3387Other keys for navigating are described in
3388@ref{Outline Visibility, , , @value{emacsdir}}.
3389@end ifinfo
3390
3391@value{tramp} errors are handled internally in order to raise the
3392verbosity level 1 messages. When you want to get a Lisp backtrace in
3393case of an error, you need to set both
3394
3395@lisp
3396(setq debug-on-error t
3397 debug-on-signal t)
3398@end lisp
3399
3400Sometimes, it might be even necessary to step through @value{tramp}
3401function call traces. Such traces are enabled by the following code:
3402
3403@lisp
3404(require 'tramp)
3405(require 'trace)
03b5bade
MA
3406(dolist (elt (all-completions "tramp-" obarray 'functionp))
3407 (trace-function-background (intern elt)))
4009494e
GM
3408(untrace-function 'tramp-read-passwd)
3409(untrace-function 'tramp-gw-basic-authentication)
3410@end lisp
3411
3412The function call traces are inserted in the buffer
3413@file{*trace-output*}. @code{tramp-read-passwd} and
3414@code{tramp-gw-basic-authentication} shall be disabled when the
3415function call traces are added to @value{tramp}, because both
3416functions return password strings, which should not be distributed.
3417
3418
3419@node Issues
3420@chapter Debatable Issues and What Was Decided
3421
3422@itemize @bullet
3423@item The uuencode method does not always work.
3424
3425Due to the design of @value{tramp}, the encoding and decoding programs
3426need to read from stdin and write to stdout. On some systems,
3427@command{uudecode -o -} will read stdin and write the decoded file to
3428stdout, on other systems @command{uudecode -p} does the same thing.
3429But some systems have uudecode implementations which cannot do this at
3430all---it is not possible to call these uudecode implementations with
3431suitable parameters so that they write to stdout.
3432
3433Of course, this could be circumvented: the @code{begin foo 644} line
3434could be rewritten to put in some temporary file name, then
3435@command{uudecode} could be called, then the temp file could be
3436printed and deleted.
3437
3438But I have decided that this is too fragile to reliably work, so on some
3439systems you'll have to do without the uuencode methods.
3440
3441@item The @value{tramp} filename syntax differs between GNU Emacs and XEmacs.
3442
3443The GNU Emacs maintainers wish to use a unified filename syntax for
3444Ange-FTP and @value{tramp} so that users don't have to learn a new
3445syntax. It is sufficient to learn some extensions to the old syntax.
3446
3447For the XEmacs maintainers, the problems caused from using a unified
3448filename syntax are greater than the gains. The XEmacs package system
3449uses EFS for downloading new packages. So, obviously, EFS has to be
3450installed from the start. If the filenames were unified, @value{tramp}
3451would have to be installed from the start, too.
3452
3453@ifset xemacs
3454@strong{Note:} If you'd like to use a similar syntax like
3455@value{ftppackagename}, you need the following settings in your init
3456file:
3457
3458@lisp
3459(setq tramp-unified-filenames t)
3460(require 'tramp)
3461@end lisp
3462
3463The autoload of the @value{emacsname} @value{tramp} package must be
3464disabled. This can be achieved by setting file permissions @code{000}
3465to the files @file{.../xemacs-packages/lisp/tramp/auto-autoloads.el*}.
3466
3467In case of unified filenames, all @value{emacsname} download sites are
3468added to @code{tramp-default-method-alist} with default method
3469@option{ftp} @xref{Default Method}. These settings shouldn't be
3470touched for proper working of the @value{emacsname} package system.
3471
3472The syntax for unified filenames is described in the @value{tramp} manual
3473for @value{emacsothername}.
3474@end ifset
3475@end itemize
3476
3477@node GNU Free Documentation License
3478@appendix GNU Free Documentation License
3479@include doclicense.texi
3480
dd753688
MA
3481@node Function Index
3482@unnumbered Function Index
3483@printindex fn
3484
3485@node Variable Index
3486@unnumbered Variable Index
3487@printindex vr
3488
4009494e 3489@node Concept Index
4009494e
GM
3490@unnumbered Concept Index
3491@printindex cp
dd753688 3492
4009494e
GM
3493@contents
3494@c End of tramp.texi - the TRAMP User Manual
3495@bye
3496
3497@c TODO
3498@c
3499@c * Say something about the .login and .profile files of the remote
3500@c shells.
3501@c * Explain how tramp.el works in principle: open a shell on a remote
3502@c host and then send commands to it.
193e6828
MA
3503@c * Use `filename' resp. `file name' consistently.
3504@c * Use `host' resp. `machine' consistently.
3505@c * Consistent small or capitalized words especially in menues.
4009494e
GM
3506
3507@ignore
3508 arch-tag: f96dd66e-6dd3-4c92-8d77-9c56205ba808
3509@end ignore