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