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