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