1 \input texinfo @c -*- mode: texinfo; coding: utf-8 -*-
2 @setfilename ../../info/tramp.info
4 @settitle TRAMP User Manual
8 @c This is *so* much nicer :)
11 @c In the Tramp repository, the version number is auto-frobbed from
12 @c configure.ac, so you should edit that file and run
13 @c "autoconf && ./configure" to change the version number.
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.
18 @include trampver.texi
20 @c Macro for formatting a file name according to the respective syntax.
21 @c Macro arguments should not have any leading or
22 @c trailing whitespace. Not very elegant, but I don't know it better.
24 @macro trampfn {method, userhost, localname}
26 \method\@value{postfixhop}@c
27 \userhost\@value{postfix}\localname\
30 @c Similar, but without a method prefix.
32 @macro trampf {userhost, localname}
34 \userhost\@value{postfix}\localname\
38 Copyright @copyright{} 1999--2016 Free Software Foundation, Inc.
41 Permission is granted to copy, distribute and/or modify this document
42 under the terms of the GNU Free Documentation License, Version 1.3 or
43 any later version published by the Free Software Foundation; with no
44 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
45 and with the Back-Cover Texts as in (a) below. A copy of the license
46 is included in the section entitled ``GNU Free Documentation License''.
48 (a) The FSF's Back-Cover Text is: ``You have the freedom to
49 copy and modify this GNU manual.''
53 @c Entries for @command{install-info} to use
54 @dircategory @value{emacsname} network features
56 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
57 @value{emacsname} remote file access via ssh and scp.
61 @title @value{tramp} version @value{trampver} User Manual
62 @author by Daniel Pittman
63 @author based on documentation by Kai Großjohann
72 @node Top, Overview, (dir), (dir)
73 @top @value{tramp} version @value{trampver} User Manual
75 This file documents @value{tramp} version @value{trampver}, a remote file
76 editing package for @value{emacsname}.
78 @value{tramp} stands for ``Transparent Remote (file) Access, Multiple
79 Protocol''. This package provides remote file editing, similar to
80 @value{ftppackagename}.
82 The difference is that @value{ftppackagename} uses FTP to transfer
83 files between the local and the remote host, whereas @value{tramp} uses a
84 combination of @command{rsh} and @command{rcp} or other work-alike
85 programs, such as @command{ssh}/@command{scp}.
87 You can find the latest version of this document on the web at
88 @uref{http://www.gnu.org/software/tramp/}.
90 @c Pointer to the other Emacs flavor is necessary only in case of
91 @c standalone installation.
93 The manual has been generated for @value{emacsname}.
95 If you want to read the info pages for @value{emacsothername}, you
96 should read in @ref{Installation} how to create them.
99 If you're using the other Emacs flavor, you should read the
100 @uref{@value{emacsotherfilename}, @value{emacsothername}} pages.
105 The latest release of @value{tramp} is available for
106 @uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
107 @ref{Obtaining Tramp} for more details, including the Git server
110 @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
111 Savannah Project Page}.
114 There is a mailing list for @value{tramp}, available at
115 @email{tramp-devel@@gnu.org}, and archived at
116 @uref{http://lists.gnu.org/archive/html/tramp-devel/, the
117 @value{tramp} Mail Archive}.
119 Older archives are located at
120 @uref{http://sourceforge.net/mailarchive/forum.php?forum=tramp-devel,
121 SourceForge Mail Archive} and
122 @uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/,
124 @c in HTML output, there's no new paragraph.
133 * Overview:: What @value{tramp} can and cannot do.
137 * Obtaining Tramp:: How to obtain @value{tramp}.
138 * History:: History of @value{tramp}.
139 @ifset installchapter
140 * Installation:: Installing @value{tramp} with your @value{emacsname}.
142 * Configuration:: Configuring @value{tramp} for use.
143 * Usage:: An overview of the operation of @value{tramp}.
144 * Bug Reports:: Reporting Bugs and Problems.
145 * Frequently Asked Questions:: Questions and answers from the mailing list.
149 * Files directories and localnames::
150 How file names, directories and localnames
151 are mangled and managed.
152 * Traces and Profiles:: How to Customize Traces.
153 * Issues:: Debatable Issues and What Was Decided.
155 * GNU Free Documentation License:: The license for this documentation.
156 * Function Index:: @value{tramp} functions.
157 * Variable Index:: User options and variables.
158 * Concept Index:: An item for each concept.
161 --- The Detailed Node Listing ---
163 @ifset installchapter
164 Installing @value{tramp} with your @value{emacsname}
166 * Installation parameters:: Parameters in order to control installation.
167 * Load paths:: How to plug-in @value{tramp} into your environment.
171 Configuring @value{tramp} for use
173 * Connection types:: Types of connections to remote hosts.
174 * Inline methods:: Inline methods.
175 * External methods:: External methods.
177 * GVFS based methods:: GVFS based external methods.
180 * Gateway methods:: Gateway methods.
182 * Default Method:: Selecting a default method.
183 * Default User:: Selecting a default user.
184 * Default Host:: Selecting a default host.
185 * Multi-hops:: Connecting to a remote host using multiple hops.
186 * Customizing Methods:: Using Non-Standard Methods.
187 * Customizing Completion:: Selecting config files for user/host name completion.
188 * Password handling:: Reusing passwords for several connections.
189 * Connection caching:: Reusing connection related information.
190 * Predefined connection information::
191 Setting own connection related information.
192 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
193 * Remote shell setup:: Remote shell setup hints.
194 * Android shell setup:: Android shell setup hints.
195 * Auto-save and Backup:: Auto-save and Backup.
196 * Windows setup hints:: Issues with Cygwin ssh.
200 * File name Syntax:: @value{tramp} file name conventions.
201 * File name completion:: File name completion.
202 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
203 * Remote processes:: Integration with other @value{emacsname} packages.
204 * Cleanup remote connections:: Cleanup remote connections.
206 How file names, directories and localnames are mangled and managed
208 * Localname deconstruction:: Breaking a localname into its components.
210 * External packages:: Integration with external Lisp packages.
218 @chapter An overview of @value{tramp}
221 @value{tramp} is for transparently accessing remote files from within
222 @value{emacsname}. @value{tramp} enables an easy, convenient, and
223 consistent interface to remote files as if they are local files.
224 @value{tramp}'s transparency extends to editing, version control, and
227 @value{tramp} can access remote hosts using any number of access
228 methods, such as @command{rsh}, @command{rlogin}, @command{telnet},
229 and related programs. If these programs can successfully pass
230 @acronym{ASCII]} characters, @value{tramp} can use them.
231 @value{tramp} does not require or mandate 8-bit clean connections.
233 @value{tramp}'s most common access method is through @command{ssh}, a
234 more secure alternative to @command{ftp} and other older access
237 @value{tramp} on Windows operating systems is integrated with the
238 PuTTY package, and uses the @command{plink} program.
240 @value{tramp} mostly operates transparently in the background using
241 the connection programs. As long as these programs enable remote login
242 and can use the terminal, @value{tramp} can adapt them for seamless
243 and transparent access.
245 @value{tramp} temporarily transfers a remote file's contents to the
246 local host editing and related operations. @value{tramp} can also
247 transfer files between hosts using standard Emacs interfaces, a
248 benefit of direct integration of @value{tramp} in @value{emacsname}.
250 @value{tramp} can transfer files using any number of available host
251 programs for remote files, such as @command{rcp}, @command{scp},
252 @command{rsync} or (under Windows) @command{pscp}. @value{tramp}
253 provides easy ways to specify these programs and customize them to
254 specific files, hosts, or access methods.
256 For faster small-size file transfers, @value{tramp} supports encoded
257 transfers directly through the shell using @command{mimencode} or
258 @command{uuencode} provided such tools are available on the remote
262 @subsubheading @value{tramp} behind the scenes
263 @cindex behind the scenes
264 @cindex details of operation
267 Accessing a remote file through @value{tramp} entails a series of
268 actions, many of which are transparent to the user. Yet some actions
269 may require user response (such as entering passwords or completing
270 file names). One typical scenario, opening a file on a remote host, is
271 presented here to illustrate the steps involved:
273 @kbd{C-x C-f} to initiate find-file, enter part of the @value{tramp}
274 file name, then hit @kbd{@key{TAB}} for completion. If this is the
275 first time connection to that host, here's what happens:
279 @value{tramp} invokes @samp{telnet @var{host}} or @samp{rsh @var{host}
280 -l @var{user}} and establishes an external process to connect to the
281 remote host. @value{tramp} communicates with the process through an
282 @value{emacsname} buffer, which also shows output from the remote
286 The remote host may prompt for a login name (for @command{telnet}, for
287 example) in the buffer. If on the other hand, the login name was
288 included in the file name portion, @value{tramp} sends the login name
289 followed by a newline.
292 The remote host may then prompt for a password or pass phrase (for
293 @command{rsh} or for @command{telnet}). @value{tramp} displays the
294 password prompt in the minibuffer. @value{tramp} then sends whatever
295 is entered to the remote host, followed by a newline.
298 @value{tramp} now waits for either the shell prompt or a failed login
301 If @value{tramp} does not receive any messages within a timeout period
302 (a minute, for example), then @value{tramp} responds with an error
303 message about not finding the remote shell prompt. If any messages
304 from the remote host, @value{tramp} displays them in the buffer.
306 For any @samp{login failed} message from the remote host,
307 @value{tramp} aborts the login attempt, and repeats the login steps
311 Upon successful login and @value{tramp} recognizes the shell prompt
312 from the remote host, @value{tramp} prepares the shell environment by
313 turning off echoing, setting shell prompt, and other housekeeping
316 @strong{Note} that for the remote shell, @value{tramp} invokes
317 @command{/bin/sh}. The remote host must recognize @samp{exec /bin/sh}
318 and execute the appropriate shell. This shell must support Bourne
322 @value{tramp} executes @command{cd} and @command{ls} commands to find
323 which files exist on the remote host. @value{tramp} sometimes uses
324 @command{echo} with globbing. @value{tramp} checks if a file or
325 directory is writable with @command{test}. After each command,
326 @value{tramp} parses the output from the remote host for completing
330 After remote file name completion, @value{tramp} transfers the file
331 contents from the remote host.
333 For inline transfers, @value{tramp} sends a command, such as
334 @samp{mimencode -b /path/to/remote/file}, waits until the output has
335 accumulated in the buffer, decodes that output to produce the file's
338 For external transfers, @value{tramp} sends a command as follows:
340 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
342 @value{tramp} reads the local temporary file @file{/tmp/tramp.4711}
343 into a buffer, and then deletes the temporary file.
346 Edit, modify, change the buffer contents as normal, and then save the
347 buffer wth @kbd{C-x C-s}.
350 @value{tramp} transfers the buffer contents to the remote host in
351 a reverse of the process using the appropriate inline or external
355 I hope this has provided you with a basic overview of what happens
356 behind the scenes when you open a file with @value{tramp}.
360 @node Obtaining Tramp
361 @chapter Obtaining Tramp.
362 @cindex obtaining Tramp
364 @value{tramp} is included as part of Emacs (since Emacs version 22.1).
366 @value{tramp} is also freely packaged for download on the Internet at
367 @uref{ftp://ftp.gnu.org/gnu/tramp/}.
369 @value{tramp} development versions are available on Git servers.
370 Development versions contain new and incomplete features.
372 One way to obtain from Git server is to visit the Savannah project
373 page at the following URL and then clicking on the Git link in the
374 navigation bar at the top.
377 @uref{http://savannah.gnu.org/projects/tramp/}
380 Another way is to follow the terminal session below:
383 ] @strong{cd ~/@value{emacsdir}}
384 ] @strong{git clone git://git.savannah.gnu.org/tramp.git}
388 From behind a firewall:
391 ] @strong{git config --global http.proxy http://user:pwd@@proxy.server.com:8080}
392 ] @strong{git clone http://git.savannah.gnu.org/r/tramp.git}
399 ] @strong{git clone login@@git.sv.gnu.org:/srv/git/tramp.git}
403 After one of the above commands, @file{~/@value{emacsdir}/tramp} will
404 containing the latest version of @value{tramp}.
407 To fetch updates from the repository, use git pull:
410 ] @strong{cd ~/@value{emacsdir}/tramp}
415 Run @command{autoconf} as follows to generate an up-to-date
416 @file{configure} script:
419 ] @strong{cd ~/@value{emacsdir}/tramp}
425 @chapter History of @value{tramp}
427 @cindex development history
429 @value{tramp} development started at the end of November 1998 as
430 @file{rssh.el}. It provided only one method of access. It used
431 @command{ssh} for login and @command{scp} to transfer file contents.
432 The name was changed to @file{rcp.el} before it got its preset name
433 @value{tramp}. New methods of remote access were added, so was support
436 April 2000 was the first time when multi-hop methods were added. In
437 July 2002, @value{tramp} unified file names with Ange-FTP@. In July
438 2004, proxy hosts replaced multi-hop methods. Running commands on
439 remote hosts was introduced in December 2005.
441 Support for gateways since April 2007.
444 GVFS integration started in February 2009.
447 Remote commands on Windows hosts since September 2011.
449 Ad-hoc multi-hop methods (with a changed syntax) re-enabled in November
452 In November 2012, added Juergen Hoetzel's @file{tramp-adb.el}.
454 In December 2001, XEmacs package repository adds @value{tramp}.
457 @c Installation chapter is necessary only in case of standalone
458 @c installation. Text taken from trampinst.texi.
459 @ifset installchapter
460 @include trampinst.texi
465 @chapter Configuring @value{tramp}
466 @cindex configuration
467 @cindex default configuration
469 @value{tramp} is initially configured to use the @command{scp} program
470 to connect to the remote host. Just type @kbd{C-x C-f} and then enter
471 file name @file{@trampf{user@@host,/path/to.file}}. For details,
472 see @xref{Default Method}.
474 For problems related to the behavior of remote shell, see @ref{Remote
475 shell setup} for details.
477 For changing the connection type and file access method from the
478 defaults to one of several other options, see (@pxref{Connection
481 @strong{Note} that some user options and variables described in these
482 examples are not auto loaded by @value{emacsname}. All examples
483 require @value{tramp} is installed and loaded:
491 * Connection types:: Types of connections to remote hosts.
492 * Inline methods:: Inline methods.
493 * External methods:: External methods.
495 * GVFS based methods:: GVFS based external methods.
498 * Gateway methods:: Gateway methods.
500 * Default Method:: Selecting a default method.
501 Here we also try to help those who
502 don't have the foggiest which method
504 * Default User:: Selecting a default user.
505 * Default Host:: Selecting a default host.
506 * Multi-hops:: Connecting to a remote host using multiple hops.
507 * Customizing Methods:: Using Non-Standard Methods.
508 * Customizing Completion:: Selecting config files for user/host name completion.
509 * Password handling:: Reusing passwords for several connections.
510 * Connection caching:: Reusing connection related information.
511 * Predefined connection information::
512 Setting own connection related information.
513 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
514 * Remote shell setup:: Remote shell setup hints.
515 * Android shell setup:: Android shell setup hints.
516 * Auto-save and Backup:: Auto-save and Backup.
517 * Windows setup hints:: Issues with Cygwin ssh.
521 @node Connection types
522 @section Types of connections to remote hosts
523 @cindex connection types, overview
525 @dfn{Inline method} and @dfn{external method} are the two basic types
526 of access methods. While they both use the same remote shell access
527 programs, such as @command{rsh}, @command{ssh}, or @command{telnet},
528 they differ in the file access methods. Choosing the right method
529 becomes important for editing files, transferring large files, or
530 operating on a large number of files.
532 @cindex inline methods
533 @cindex external methods
534 @cindex methods, inline
535 @cindex methods, external
537 The performance of the external methods is generally better than that
538 of the inline methods, at least for large files. This is caused by
539 the need to encode and decode the data when transferring inline.
541 The one exception to this rule are the @option{scp}-based access
542 methods. While these methods do see better performance when actually
543 transferring files, the overhead of the cryptographic negotiation at
544 startup may drown out the improvement in file transfer times.
546 External methods should be configured such a way that they don't
547 require a password (with @command{ssh-agent}, or such alike). Modern
548 @command{scp} implementations offer options to reuse existing
549 @command{ssh} connections, which will be enabled by default if
550 available. If it isn't possible, you should consider @ref{Password
551 handling}, otherwise you will be prompted for a password every copy
556 @section Inline methods
557 @cindex inline methods
558 @cindex methods, inline
560 Inline methods use the same login connection to transfer file
561 contents. Inline methods are quick and easy for small files. They
562 depend on the availability of suitable encoding and decoding programs
563 on the remote host. For local source and destination, @value{tramp}
564 may use built-in equivalents of such programs in @value{emacsname}.
566 Inline methods can work in situations where an external transfer
567 program is unavailable. Inline methods also work when transferring
568 files between different @emph{user identities} on the same host.
572 @cindex base-64 encoding
574 @value{tramp} checks the remote host for the availability and
575 usability of @command{mimencode} (part of the @command{metamail}
576 package) or @command{uuencode}. @value{tramp} uses the first reliable
577 command it finds. @value{tramp}'s search path can be customized, see
578 @ref{Remote programs}.
580 In case both @command{mimencode} and @command{uuencode} are
581 unavailable, @value{tramp} first transfers a small Perl program to the
582 remote host, and then tries that program for encoding and decoding.
584 To increase transfer speeds for large text files, use compression
585 before encoding. The variable @var{tramp-inline-compress-start-size}
586 specifies the file size for such optimization.
593 @command{rsh} is an option for connecting to hosts within local
594 networks since @command{rsh} is not as secure as other methods.
601 @command{ssh} is a more secure option than others to connect to a
604 @command{ssh} can also take extra parameters as port numbers. For
605 example, a host on port 42 is specified as @file{host#42} (the real
606 host name, a hash sign, then a port number). It is the same as passing
607 @code{-p 42} to the @command{ssh} command.
609 @item @option{telnet}
610 @cindex method telnet
611 @cindex telnet method
613 Connecting to a remote host with @command{telnet} is as insecure
614 as the @option{rsh} method.
621 Instead of connecting to a remote host, @command{su} program allows
622 editing as another user. The host can be either @samp{localhost} or
623 the host returned by the function @command{(system-name)}. See
624 @ref{Multi-hops} for an exception to this behavior.
630 Similar to @option{su} method, @option{sudo} uses @command{sudo}.
631 @command{sudo} must have sufficient rights to start a shell.
637 Works like @option{ssh} but without the extra authentication prompts.
638 @option{sshx} uses @samp{ssh -t -t @var{host} -l @var{user} /bin/sh}
639 to open a connection with a ``standard'' login shell.
641 @strong{Note} that @option{sshx} does not bypass authentication
642 questions. For example, if the host key of the remote host is not
643 known, @option{sshx} will still ask ``Are you sure you want to
644 continue connecting?''. @value{tramp} cannot handle such questions.
645 Connections will have to be setup where logins can proceed without
648 @option{sshx} is useful for Windows users when @command{ssh} triggers
649 an error about allocating a pseudo tty. This happens due to missing
650 shell prompts that confuses @value{tramp}.
652 @option{sshx} supports the @samp{-p} argument.
654 @item @option{krlogin}
655 @cindex method krlogin
656 @cindex krlogin method
657 @cindex Kerberos (with krlogin method)
659 This method is also similar to @option{ssh}. It uses the
660 @command{krlogin -x} command only for remote host login.
665 @cindex Kerberos (with ksu method)
667 This is another method from the Kerberos suite. It behaves like @option{su}.
674 @option{plink} method is for Windows users with the PuTTY
675 implementation of SSH@. It uses @samp{plink -ssh} to log in to the
678 Check the @samp{Share SSH connections if possible} control for that
681 @option{plink} method supports the @samp{-P} argument.
684 @item @option{plinkx}
685 @cindex method plinkx
686 @cindex plinkx method
688 Another method using PuTTY on Windows with session names instead of
689 host names. @option{plinkx} calls @samp{plink -load @var{session} -t}.
690 User names and port numbers must be defined in the session.
692 Check the @samp{Share SSH connections if possible} control for that
698 @node External methods
699 @section External methods
700 @cindex methods, external
701 @cindex external methods
703 External methods operate over multiple channels, using the remote
704 shell connection for some actions while delegating file transfers to
705 an external transfer program.
707 External methods save on the overhead of encoding and decoding of
710 Since external methods have the overhead of opening a new channel,
711 files smaller than @var{tramp-copy-size-limit} still use inline
715 @item @option{rcp}---@command{rsh} and @command{rcp}
718 @cindex rcp (with rcp method)
719 @cindex rsh (with rcp method)
721 This method uses the @command{rsh} and @command{rcp} commands to
722 connect to the remote host and transfer files. This is the fastest
723 access method available.
725 The alternative method @option{remcp} uses the @command{remsh} and
726 @command{rcp} commands.
728 @item @option{scp}---@command{ssh} and @command{scp}
731 @cindex scp (with scp method)
732 @cindex ssh (with scp method)
734 Using a combination of @command{ssh} to connect and @command{scp} to
735 transfer is the most secure. While the performance is good, it is
736 slower than the inline methods for smaller files. Though there is no
737 overhead of encoding and decoding of the inline methods,
738 @command{scp}'s cryptographic handshake negates those speed gains.
740 @option{ssh}-based methods support @samp{-p} feature for specifying
741 port numbers. For example, @file{host#42} passes @samp{-p 42} in the
742 argument list to @command{ssh}, and @samp{-P 42} in the argument list
745 @item @option{rsync}---@command{ssh} and @command{rsync}
748 @cindex rsync (with rsync method)
749 @cindex ssh (with rsync method)
751 @command{ssh} command to connect in combination with @command{rsync}
752 command to transfer is similar to the @option{scp} method.
754 @command{rsync} performs much better than @command{scp} when
755 transferring files that exist on both hosts. However, this advantage
756 is lost if the file exists only on one side of the connection.
758 This method supports the @samp{-p} argument.
761 @item @option{scpx}---@command{ssh} and @command{scp}
764 @cindex scp (with scpx method)
765 @cindex ssh (with scpx method)
767 @option{scpx} is useful to avoid login shell questions. It is similar
768 in performance to @option{scp}. @option{scpx} uses @samp{ssh -t -t
769 @var{host} -l @var{user} /bin/sh} to open a connection.
771 @option{sshx} is useful for Windows users when @command{ssh} triggers
772 an error about allocating a pseudo tty. This happens due to missing
773 shell prompts that confuses @value{tramp}.
775 This method supports the @samp{-p} argument.
778 @item @option{pscp}---@command{plink} and @command{pscp}
779 @item @option{psftp}---@command{plink} and @command{psftp}
782 @cindex pscp (with pscp method)
783 @cindex plink (with pscp method)
784 @cindex PuTTY (with pscp method)
787 @cindex pscp (with psftp method)
788 @cindex plink (with psftp method)
789 @cindex PuTTY (with psftp method)
791 These methods are similar to @option{scp} or @option{sftp}, but they
792 use the @command{plink} command to connect to the remote host, and
793 they use @command{pscp} or @command{psftp} for transferring the files.
794 These programs are part of PuTTY, an SSH implementation for Windows.
796 Check the @samp{Share SSH connections if possible} control for that
799 These methods support the @samp{-P} argument.
802 @item @option{fcp}---@command{fsh} and @command{fcp}
805 @cindex fsh (with fcp method)
806 @cindex fcp (with fcp method)
808 This method is similar to @option{scp}, but uses @command{fsh} to
809 connect and @command{fcp} to transfer files. @command{fsh/fcp}, a
810 front-end for @command{ssh}, reuse @command{ssh} session by
811 submitting several commands. This avoids the startup overhead due to
812 @command{scp}'s secure connection. Inline methods have similar
815 The command used for this connection is: @samp{fsh @var{host} -l
816 @var{user} /bin/sh -i}
821 @option{fsh} has no inline method since the multiplexing it offers is
822 not useful for @value{tramp}. @command{fsh} connects to remote host
823 and @value{tramp} keeps that one connection open.
825 @item @option{nc}---@command{telnet} and @command{nc}
828 @cindex nc (with nc method)
829 @cindex telnet (with nc method)
831 Using @command{telnet} to connect and @command{nc} to transfer files
832 is sometimes the only combination suitable for accessing routers or
833 NAS hosts. These dumb devices have severely restricted local shells,
834 such as the @command{busybox} and do not host any other encode or
841 When @value{tramp} uses @option{ftp}, it forwards requests to whatever
842 ftp program is specified by @value{ftppackagename}. This external
843 program must be capable of servicing requests from @value{tramp}.
846 This method works only for unified file names, see @ref{Issues}.
850 @item @option{smb}---@command{smbclient}
854 This is another non-native @value{tramp} method. @command{smbclient}
855 connects to any server supporting the SMB/CIFS protocol, such as MS Windows and
856 Samba running on GNU/Linux. Tests show this @value{tramp} method
857 works with MS Windows NT, MS Windows 2000, MS Windows XP, MS Windows
858 Vista, and MS Windows 7.
860 Using @command{smbclient} requires a few tweaks when working with
863 The first directory in the localname must be a share name on the
866 Since smb shares end in the @code{$} character, @value{tramp} must use
867 @code{$$} when specifying those shares to avoid environment variable
870 When @value{tramp} is not specific about the share name or uses the
871 generic remote directory @code{/}, @command{smbclient} returns all
874 Since SMB authentication is based on each SMB share, @value{tramp}
875 prompts for a password even when accessing a different share on the
876 same SMB host. This prompting can be suppressed by @ref{Password
879 To accommodate user name/domain name syntax required by MS Windows
880 authorization, @value{tramp} provides for an extended syntax in
881 @code{user%domain} format (where user is username, @code{%} is the
882 percent symbol, and domain is the windows domain name). An example:
885 @trampfn{smb,daniel%BIZARRE@@melancholia,/daniel$$/.emacs}
888 where user @code{daniel} connects as a domain user to the SMB host
889 @code{melancholia} in the windows domain @code{BIZARRE} to edit
890 @file{.emacs} located in the home directory (share @code{daniel$}).
892 Alternatively, for local WINS users (as opposed to domain users),
893 substitute the domain name with the name of the local host in
894 UPPERCASE as shown here:
897 @trampfn{smb,daniel%MELANCHOLIA@@melancholia,/daniel$$/.emacs}
900 where user @code{daniel} connects as local user to the SMB host
901 @code{melancholia} in the local domain @code{MELANCHOLIA} to edit
902 @file{.emacs} located in the home directory (share @code{daniel$}).
904 The domain name and user name are optional for @command{smbclient}
905 authentication. When user name is not specified, @command{smbclient}
906 uses the anonymous user (without prompting for password). This
907 behavior is unlike other @value{tramp} methods, where local user name
910 @option{smb} method is unavailable if @value{emacsname} is run under a
911 local user authentication context in MS Windows. However such users
912 can still access remote files using UNC file names instead of @value{tramp}:
915 //melancholia/daniel$$/.emacs
918 UNC file name specification does not allow to specify a different user
919 name for authentication like the @command{smbclient} can.
926 This method uses Android Debug Bridge program for accessing Android
927 devices. The Android Debug Bridge must be installed locally for
928 @value{tramp} to work. Some GNU/Linux distributions provide Android
929 Debug Bridge as an installation package. Alternatively, the program is
930 installed as part of the Android SDK@. @value{tramp} finds the
931 @command{adb} program either via the @env{PATH} environment variable
932 or the absolute path set in the variable @var{tramp-adb-program}.
934 @value{tramp} connects to Android devices with @option{adb} only when
935 the custom option @option{tramp-adb-connect-if-not-connected} is not
936 @code{nil}. Otherwise, the connection must be established outside
939 @value{tramp} does not require a host name part of the remote file
940 name when a single Android device is connected to @command{adb}.
941 @value{tramp} instead uses @file{@trampfn{adb,,}} as the default
942 name. @command{adb devices} shows available host names.
944 @option{adb} method normally does not need user name to authenticate
945 on the Android device because it runs under the @command{adbd}
946 process. But when a user name is specified, however, @value{tramp}
947 applies an @command{su} in the syntax. When authentication does not
948 succeed, especially on un-rooted Android devices, @value{tramp}
949 displays login errors.
951 For Android devices connected through TCP/IP, a port number can be
952 specified using @file{device#42} host name syntax or @value{tramp} can
953 use the default value as declared in @command{adb} command. Port
954 numbers are not applicable to Android devices connected through USB@.
960 @node GVFS based methods
961 @section GVFS based external methods
962 @cindex methods, gvfs
963 @cindex gvfs based methods
966 GVFS is the virtual file system for the Gnome Desktop,
967 @uref{http://en.wikipedia.org/wiki/GVFS}. Remote files on GVFS are
968 mounted locally through FUSE and @value{tramp} uses this locally
969 mounted directory internally.
971 @value{emacsname} uses the D-Bus mechanism to communicate with GVFS@.
972 @value{emacsname} must have the message bus system, D-Bus integration
973 active, @pxref{Top, , D-Bus, dbus}.
980 This method is for connecting to remote hosts with the Apple Filing
981 Protocol for accessing files on Mac OS X volumes. @value{tramp} access
982 syntax requires a leading volume (share) name, for example:
983 @file{@trampfn{afp,user@@host,/volume}}.
992 @option{dav} method provides access to WebDAV files and directories
993 based on standard protocols, such as HTTP@. @option{davs} does the same
994 but with SSL encryption. Both methods support the port numbers.
1000 OBEX is an FTP-like access protocol for cell phones and similar simple
1001 devices. @value{tramp} supports OBEX over Bluetooth.
1008 This method uses @command{sftp} in order to securely access remote
1009 hosts. @command{sftp} is a more secure option for connecting to hosts
1010 that for security reasons refuse @command{ssh} connections.
1012 @item @option{synce}
1013 @cindex method synce
1014 @cindex synce method
1016 @option{synce} method allows connecting to Windows Mobile devices. It
1017 uses GVFS for mounting remote files and directories via FUSE and
1018 requires the SYNCE-GVFS plugin.
1022 @defopt tramp-gvfs-methods
1023 @vindex tramp-gvfs-methods
1024 This custom option is a list of external methods for GVFS@. By
1025 default, this list includes @option{afp}, @option{dav}, @option{davs},
1026 @option{obex}, @option{sftp} and @option{synce}. Other methods to
1027 include are: @option{ftp} and @option{smb}.
1033 @node Gateway methods
1034 @section Gateway methods
1035 @cindex methods, gateway
1036 @cindex gateway methods
1038 Gateway methods are for proxy host declarations (@pxref{Multi-hops})
1039 so as to pass through firewalls and proxy servers. They are not like
1040 the other methods that declare direct connections to a remote host.
1042 A gateway method always comes with a port setting. @value{tramp}
1043 targets the port number with the gateway method
1044 @file{localhost#random_port} from where the firewall or proxy server
1047 Gateway methods support user name and password declarations for
1048 authenticating the corresponding firewall or proxy server. Such
1049 authentication can be passed through only if granted access by system
1053 @item @option{tunnel}
1054 @cindex method tunnel
1055 @cindex tunnel method
1057 This method implements an HTTP tunnel via the @command{CONNECT}
1058 command (conforming to RFC 2616, 2817 specifications). Proxy servers
1059 using HTTP version 1.1 or later protocol support this command.
1061 For authentication, this protocol uses only @option{Basic
1062 Authentication} (see RFC 2617). When no port number is specified, this
1063 protocol defaults to @option{8080}.
1066 @item @option{socks}
1067 @cindex method socks
1068 @cindex socks method
1070 The @option{socks} method connects to SOCKSv5 servers (see RFC 1928)
1071 and supports @option{Username/Password Authentication}.
1073 The default port number for the socks server is @option{1080}, if not
1074 specified otherwise.
1080 @node Default Method
1081 @section Selecting a default method
1082 @cindex default method
1083 @vindex tramp-default-method
1084 @vindex tramp-default-method-alist
1086 Default method is for transferring files. The variable
1087 @code{tramp-default-method} sets it. @value{tramp} uses this variable
1088 to determine the default method for tramp file names that do not have
1092 (setq tramp-default-method "ssh")
1095 Default methods for transferring files can be customized for specific
1096 user and host combinations through the alist variable
1097 @code{tramp-default-method-alist}.
1099 For example, the following two lines specify to use the @option{ssh}
1100 method for all user names matching @samp{john} and the @option{rsync}
1101 method for all host names matching @samp{lily}. The third line
1102 specifies to use the @option{su} method for the user @samp{root} on
1103 the host @samp{localhost}.
1106 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1107 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1108 (add-to-list 'tramp-default-method-alist
1109 '("\\`localhost\\'" "\\`root\\'" "su"))
1113 See the documentation for the variable
1114 @code{tramp-default-method-alist} for details.
1117 External methods performance faster for large files.
1120 @xref{Inline methods}.
1121 @xref{External methods}.
1123 Choosing the access method also depends on the security environment.
1124 For example, @option{rsh} and @option{telnet} methods that use clear
1125 text password transfers are inappropriate for over the Internet
1126 connections. Secure remote connections should use @option{ssh} that
1130 @subsection Which method to use?
1131 @cindex choosing the right method
1133 @value{tramp} provides maximum number of choices for maximum
1134 flexibility. Choosing which method depends on the hosts, clients,
1135 network speeds, and the security context.
1137 Start by using an inline method.
1139 External methods might be more efficient for large files, but most
1140 @value{tramp} users edit small files more often than large files.
1142 Enable compression, @var{tramp-inline-compress-start-size}, for a
1143 performance boost for large files.
1145 Since @command{ssh} has become the most common method of remote host
1146 access and it has the most reasonable security protocols, use
1147 @option{ssh} method. Typical @option{ssh} usage to edit the
1148 @file{/etc/motd} file on the otherhost:
1151 @kbd{C-x C-f @trampfn{ssh,root@@otherhost,/etc/motd} @key{RET}}
1154 If @option{ssh} is unavailable for whatever reason, look for other
1155 obvious options. For Windows, try the @option{plink} method. For
1156 Kerberos, try @option{krlogin}.
1158 For editing local files as @option{su} or @option{sudo} methods, try
1159 the shortened syntax of @samp{root}:
1162 @kbd{C-x C-f @trampfn{su,,/etc/motd} @key{RET}}
1165 For editing large files, @option{scp} is faster than @option{ssh}.
1166 @option{pscp} is faster than @option{plink}. But this speed
1167 improvement is not always true.
1171 @section Selecting a default user
1172 @cindex default user
1173 @vindex tramp-default-user
1174 @vindex tramp-default-user-alist
1176 @value{tramp} file name can omit the user name part since
1177 @value{tramp} substitutes the currently logged-in user name. However
1178 this substitution can be overridden with @code{tramp-default-user}.
1182 (setq tramp-default-user "root")
1185 Instead of a single default user, @code{tramp-default-user-alist}
1186 allows multiple default user values based on access method or host
1187 name combinations. The alist can hold multiple values. For example, to
1188 use the @samp{john} as the default user for the domain
1189 @samp{somewhere.else} only:
1192 (add-to-list 'tramp-default-user-alist
1193 '("ssh" ".*\\.somewhere\\.else\\'" "john"))
1197 See the documentation for the variable @code{tramp-default-user-alist}
1200 A Caution: @value{tramp} will override any default user specified in
1201 the configuration files outside @value{emacsname}, such as
1202 @file{~/.ssh/config}. To stop @value{tramp} from applying the default
1203 value, set the corresponding alist entry to nil:
1206 (add-to-list 'tramp-default-user-alist
1207 '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
1210 The last entry in @code{tramp-default-user-alist} should be reserved
1211 for catch-all or most often used login.
1214 (add-to-list 'tramp-default-user-alist
1215 '(nil nil "jonas") t)
1220 @section Selecting a default host
1221 @cindex default host
1222 @vindex tramp-default-host
1223 @vindex tramp-default-host-alist
1225 When host name is omitted, @value{tramp} substitutes the value from
1226 the @code{tramp-default-host} variable. It is initially populated with
1227 the local hostname where @value{emacsname} is running. Both the
1228 default user and default host can be overridden as follows:
1231 (setq tramp-default-user "john"
1232 tramp-default-host "target")
1235 With both defaults set, @samp{@trampfn{ssh,,}} will connect
1236 @value{tramp} to John's home directory on target.
1239 @strong{Note} @samp{/::} won't work, because @samp{/:} is the prefix
1240 for quoted file names.
1243 Instead of a single default host, @code{tramp-default-host-alist}
1244 allows multiple default host values based on access method or user
1245 name combinations. The alist can hold multiple values. While
1246 @code{tramp-default-host} is sufficient in most cases, some methods,
1247 like @option{adb}, require defaults overwritten.
1250 See the documentation for the variable @code{tramp-default-host-alist}
1255 @section Connecting to a remote host using multiple hops
1259 Multi-hops are methods to reach hosts behind firewalls or to reach the
1260 outside world from inside a bastion host. With multi-hops,
1261 @value{tramp} can negotiate these hops with the appropriate user/host
1262 authentication at each hop. All methods until now have been the single
1263 hop kind, where the start and end points of the connection did not
1264 have intermediate check points.
1266 @defopt tramp-default-proxies-alist
1267 @vindex tramp-default-proxies-alist
1268 @option{tramp-default-proxies-alist} specifies proxy hosts to pass
1269 through. This variable is list of triples consisting of (@var{host}
1270 @var{user} @var{proxy}).
1272 The first match is the proxy host through which passes the file name
1273 and the target host matching @var{user}@@@var{host}. @var{host} and
1274 @var{user} are regular expressions or @code{nil}, interpreted as a
1275 regular expression which always matches.
1277 @var{proxy} is a literal @value{tramp} file name whose local name part
1278 is ignored, and the method and user name parts are optional.
1281 The method must be an inline or gateway method (@pxref{Inline
1282 methods}, @pxref{Gateway methods}).
1285 The method must be an inline method (@pxref{Inline methods}).
1287 If @var{proxy} is @code{nil}, no additional hop is required reaching
1288 @var{user}@@@var{host}.
1290 For example, to pass through the host @samp{bastion.your.domain} as
1291 user @samp{bird} to reach remote hosts outside the local domain:
1294 (add-to-list 'tramp-default-proxies-alist
1295 '("\\." nil "@trampfn{ssh,bird@@bastion.your.domain,}"))
1296 (add-to-list 'tramp-default-proxies-alist
1297 '("\\.your\\.domain\\'" nil nil))
1300 @strong{Note}: @code{add-to-list} adds elements at the beginning of a
1301 list. Therefore, most relevant rules must come last in the list.
1303 Proxy hosts can be cascaded in the alist. If there is another host
1304 called @samp{jump.your.domain}, which is the only host allowed to
1305 connect to @samp{bastion.your.domain}, then:
1308 (add-to-list 'tramp-default-proxies-alist
1309 '("\\`bastion\\.your\\.domain\\'"
1311 "@trampfn{ssh,jump.your.domain,}"))
1314 @var{proxy} can take patterns @code{%h} or @code{%u} for @var{host} or
1315 @var{user} respectively.
1317 To login as @samp{root} on remote hosts in the domain
1318 @samp{your.domain}, but login as @samp{root} is disabled for non-local
1319 access, then use this alist entry:
1322 (add-to-list 'tramp-default-proxies-alist
1323 '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh,%h,}"))
1326 Opening @file{@trampfn{sudo,randomhost.your.domain,}} first
1327 connects to @samp{randomhost.your.domain} via @code{ssh} under your
1328 account name, and then perform @code{sudo -u root} on that host.
1330 It is key for the sudo method in the above example to be applied on
1331 the host after reaching it and not on the local host.
1333 @var{host}, @var{user} and @var{proxy} can also take Lisp forms. These
1334 forms when evaluated must return either a string or @code{nil}.
1336 To generalize (from the previous example): For all hosts, except my
1337 local one, first connect via @command{ssh}, and then apply
1338 @command{sudo -u root}:
1341 (add-to-list 'tramp-default-proxies-alist
1342 '(nil "\\`root\\'" "@trampfn{ssh,%h,}"))
1343 (add-to-list 'tramp-default-proxies-alist
1344 '((regexp-quote (system-name)) nil nil))
1347 The above configuration allows @value{tramp} connection as @samp{root}
1348 to remote Ubuntu hosts.
1351 @code{tramp-default-proxies-alist} is also used for passing through
1352 firewalls or proxy servers.
1354 For example, the local host @samp{proxy.your.domain} on port 3128
1355 serves as HTTP proxy to the outer world. User has access rights to
1356 another proxy server on @samp{host.other.domain}.@footnote{HTTP tunnels
1357 are intended for secure SSL/TLS communication. Therefore, many proxy
1358 servers restrict the tunnels to related target ports. You might need
1359 to run your ssh server on your target host @samp{host.other.domain} on
1360 such a port, like 443 (https). See
1361 @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall} for
1362 discussion of ethical issues.} Then the configuration is:
1365 (add-to-list 'tramp-default-proxies-alist
1366 '("\\`host\\.other\\.domain\\'" nil
1367 "@trampfn{tunnel,proxy.your.domain#3128,}"))
1370 Gateway methods in a multiple hop chain can be declared only as the first hop.
1374 Passing through hops involves dealing with restricted shells, such as
1375 @command{rbash}. If @value{tramp} is made aware, then it would use
1376 them for proxies only.
1378 @defopt tramp-restricted-shell-hosts-alist
1379 @vindex tramp-restricted-shell-hosts-alist
1380 An alist of regular expressions of hosts running restricted shells,
1381 such as @command{rbash}. @value{tramp} will then use them only as
1384 To specify the bastion host from the example above as running a
1388 (add-to-list 'tramp-restricted-shell-hosts-alist
1389 "\\`bastion\\.your\\.domain\\'")
1394 @node Customizing Methods
1395 @section Using Non-Standard Methods
1396 @cindex customizing methods
1397 @cindex using non-standard methods
1398 @cindex create your own methods
1400 The @code{tramp-methods} variable currently has an exhaustive list of
1401 predefined methods. Any part of this list can be modified with more
1402 suitable settings. Refer to the Lisp documentation of that variable,
1403 accessible with @kbd{C-h v tramp-methods @key{RET}}.
1406 @node Customizing Completion
1407 @section Selecting config files for user/host name completion
1408 @cindex customizing completion
1409 @cindex selecting config files
1410 @vindex tramp-completion-function-alist
1412 @code{tramp-completion-function-alist} uses predefined files for user
1413 and host name completion (@pxref{File name completion}). For each
1414 method, it keeps a set of configuration files and a function that can
1415 parse that file. Each entry in @code{tramp-completion-function-alist}
1416 is of the form (@var{method} @var{pair1} @var{pair2} @dots{}).
1418 Each @var{pair} is composed of (@var{function} @var{file}).
1419 @var{function} is responsible for extracting user names and host names
1420 from @var{file} for completion. There are two functions which access
1423 @defun tramp-get-completion-function method
1424 This function returns the list of completion functions for @var{method}.
1428 (tramp-get-completion-function "rsh")
1430 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1431 (tramp-parse-rhosts "~/.rhosts"))
1435 @defun tramp-set-completion-function method function-list
1436 This function sets @var{function-list} as list of completion functions
1441 (tramp-set-completion-function "ssh"
1442 '((tramp-parse-sconfig "/etc/ssh_config")
1443 (tramp-parse-sconfig "~/.ssh/config")))
1445 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1446 (tramp-parse-sconfig "~/.ssh/config"))
1450 The following predefined functions parsing configuration files exist:
1453 @item @code{tramp-parse-rhosts}
1454 @findex tramp-parse-rhosts
1456 This function parses files which are syntactical equivalent to
1457 @file{~/.rhosts}. It returns both host names and user names, if
1460 @item @code{tramp-parse-shosts}
1461 @findex tramp-parse-shosts
1463 This function parses files which are syntactical equivalent to
1464 @file{~/.ssh/known_hosts}. Since there are no user names specified
1465 in such files, it can return host names only.
1467 @item @code{tramp-parse-sconfig}
1468 @findex tramp-parse-shosts
1470 This function returns the host nicknames defined by @code{Host} entries
1471 in @file{~/.ssh/config} style files.
1473 @item @code{tramp-parse-shostkeys}
1474 @findex tramp-parse-shostkeys
1476 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1477 @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1478 @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1479 are always @code{nil}.
1481 @item @code{tramp-parse-sknownhosts}
1482 @findex tramp-parse-shostkeys
1484 Another SSH2 style parsing of directories like
1485 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1486 case, hosts names are coded in file names
1487 @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1489 @item @code{tramp-parse-hosts}
1490 @findex tramp-parse-hosts
1492 A function dedicated to @file{/etc/hosts} for host names.
1494 @item @code{tramp-parse-passwd}
1495 @findex tramp-parse-passwd
1497 A function which parses @file{/etc/passwd} files for user names.
1499 @item @code{tramp-parse-netrc}
1500 @findex tramp-parse-netrc
1502 A function which parses @file{~/.netrc} and @file{~/.authinfo}-style files.
1506 To keep a custom file with custom data in a custom structure, a custom
1507 function has to be provided. This function must meet the following
1510 @defun my-tramp-parse file
1511 @var{file} must be either a file on the host, or @code{nil}. The
1512 function must return a list of (@var{user} @var{host}), which are
1513 taken as candidates for completion for user and host names.
1517 (my-tramp-parse "~/.my-tramp-hosts")
1519 @result{} ((nil "toto") ("daniel" "melancholia"))
1524 @node Password handling
1525 @section Reusing passwords for several connections
1528 To avoid repeated prompts for passwords, consider native caching
1529 mechanisms, such as @command{ssh-agent} for @option{ssh}-like
1530 methods, or @command{pageant} for @option{plink}-like methods.
1532 @value{tramp} offers alternatives when native solutions cannot meet
1536 @anchor{Using an authentication file}
1537 @subsection Using an authentication file
1538 @vindex auth-sources
1540 The package @file{auth-source.el}, originally developed for No Gnus,
1541 reads passwords from different sources, @xref{Help for users, ,
1542 auth-source, auth}. The default authentication file is
1543 @file{~/.authinfo.gpg}, but this can be changed via the variable
1544 @code{auth-sources}.
1547 A typical entry in the authentication file:
1550 machine melancholia port scp login daniel password geheim
1553 The port can take any @value{tramp} method (@pxref{Inline methods},
1554 @pxref{External methods}). Omitting port values matches all
1555 @value{tramp} methods.
1557 Setting @code{auth-source-debug} to @code{t} to debug messages.
1560 @anchor{Caching passwords}
1561 @subsection Caching passwords
1563 @value{tramp} can cache passwords as entered and reuse when needed for
1564 the same user or host name independent of the access method.
1566 @vindex password-cache-expiry
1568 @code{password-cache-expiry} sets the duration (in seconds) the
1569 passwords are remembered. Passwords are never saved permanently nor
1570 can they extend beyond the lifetime of the current @value{emacsname}
1571 session. Set @code{password-cache-expiry} to @code{nil} to disable
1574 @vindex password-cache
1576 Set @code{password-cache} to @code{nil} to disable password caching.
1578 @strong{Implementation Note}: password caching depends on
1579 @file{password-cache.el} package. @value{tramp} activates password
1580 caching only if @value{tramp} can discover, while @value{emacsname} is
1581 loading, the package through @code{load-path}.
1583 @ifset installchapter
1584 @file{password.el} is available from No Gnus or from the @value{tramp}
1585 @file{contrib} directory, see @ref{Installation parameters}.
1589 @node Connection caching
1590 @section Reusing connection related information
1592 @vindex tramp-persistency-file-name
1594 For faster initial connection times, @value{tramp} stores previous
1595 connection properties in a file specified by the variable
1596 @code{tramp-persistency-file-name}.
1598 The default file name for @code{tramp-persistency-file-name} is:
1600 @file{~/.emacs.d/tramp}.
1603 @file{~/.xemacs/tramp}.
1606 @value{tramp} reads this file during @value{emacsname} startup, and
1607 writes to it when exiting @value{emacsname}. Delete this file for
1608 @value{tramp} to recreate a new one on next @value{emacsname} startup.
1610 Set @code{tramp-persistency-file-name} to @code{nil} to disable
1611 storing connections persistently.
1613 To reuse connection information from the persistent list,
1614 @value{tramp} needs to uniquely identify every host. However in some
1615 cases, two different connections may result in the same persistent
1616 information. For example, connecting to a host using @command{ssh} and
1617 connecting to the same host through @code{sshd} on port 3001. Both
1618 access methods result in nearly identical persistent specifications
1619 @file{@trampfn{ssh,localhost,}} and @file{@trampfn{ssh,localhost#3001,}}.
1621 Changing host names could avoid duplicates. One way is to add a
1622 @option{Host} section in @file{~/.ssh/config} (@pxref{Frequently Asked
1623 Questions}). Another way is to apply multiple hops (@pxref{Multi-hops}).
1625 When @value{tramp} detects a change in the operating system version in
1626 a remote host (via the command @command{uname -sr}), it flushes all
1627 connection related information for that host and creates a new entry.
1630 @node Predefined connection information
1631 @section Setting own connection related information
1632 @vindex tramp-connection-properties
1634 For more precise customization, parameters specified by
1635 @code{tramp-methods} can be overwritten manually.
1637 Set @code{tramp-connection-properties} to manually override
1638 @code{tramp-methods}. Properties in this list are in the form
1639 @code{(@var{regexp} @var{property} @var{value})}. @var{regexp} matches
1640 remote file names. Use @code{nil} to match all. @var{property} is the
1641 property's name, and @var{value} is the property's value.
1643 @var{property} is any method specific parameter contained in
1644 @code{tramp-methods}. The parameter key in @code{tramp-methods} is a
1645 symbol name @code{tramp-<foo>}. To overwrite that property, use the
1646 string @samp{<foo>} for @var{property}. For example, this changes the
1650 (add-to-list 'tramp-connection-properties
1651 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1652 "remote-shell" "/bin/ksh"))
1653 (add-to-list 'tramp-connection-properties
1654 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1655 "remote-shell-login" '("-")))
1658 The parameters @code{tramp-remote-shell} and
1659 @code{tramp-remote-shell-login} in @code{tramp-methods} now have new
1660 values for the remote host.
1662 @var{property} could also be any property found in
1663 @code{tramp-persistency-file-name}.
1665 To get around how restricted shells randomly drop connections, set the
1666 special property @samp{busybox}. For example:
1669 (add-to-list 'tramp-connection-properties
1670 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1675 @node Remote programs
1676 @section How @value{tramp} finds and uses programs on the remote host
1678 @value{tramp} requires access to and rights to several commands on
1679 remote hosts: @command{ls}, @command{test}, @command{find} and
1682 Besides there are other required programs for @ref{Inline methods} and
1683 @ref{External methods} of connection.
1685 To improve performance and accuracy of remote file access,
1686 @value{tramp} uses @command{perl} (or @command{perl5}) and
1687 @command{grep} when available.
1689 @defopt tramp-remote-path
1690 @vindex tramp-remote-path
1691 @vindex tramp-default-remote-path
1692 @vindex tramp-own-remote-path
1693 @option{tramp-remote-path} specifies which remote directory paths
1694 @value{tramp} can search for @ref{Remote programs}.
1696 @value{tramp} uses standard defaults, such as @file{/bin} and
1697 @file{/usr/bin}, which are reasonable for most hosts. To accommodate
1698 differences in hosts and paths, for example, @file{/bin:/usr/bin} on
1700 @file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin} on
1701 Solaris, @value{tramp} queries the remote host with @command{getconf
1702 PATH} and updates the symbol @code{tramp-default-remote-path}.
1704 For instances where hosts keep obscure locations for paths for
1705 security reasons, manually add such paths to local @file{.emacs} as
1706 shown below for @value{tramp} to use when connecting.
1709 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1712 Another way to find the remote path is to use the path assigned to the
1713 remote user by the remote host. @value{tramp} does not normally retain
1714 this remote path after logging. However, @code{tramp-own-remote-path}
1715 preserves the path value, which can be used to update
1716 @code{tramp-remote-path}.
1719 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1723 When remote search paths are changed, local @value{tramp} caches must
1724 be recomputed. To force @value{tramp} to recompute afresh, exit
1725 @value{emacsname}, remove the persistent file (@pxref{Connection
1726 caching}), and restart @value{emacsname}.
1729 @node Remote shell setup
1730 @section Remote shell setup hints
1731 @cindex remote shell setup
1732 @cindex @file{.profile} file
1733 @cindex @file{.login} file
1734 @cindex shell init files
1736 @value{tramp} checks for the availability of standard programs in the
1737 usual locations. Common tactics include successively trying
1738 @command{test -e}, @command{/usr/bin/test -e}, and @command{/bin/test
1739 -e}. @command{ls -d} is another approach. But these approaches do not
1740 help with these new login patterns.
1742 When @value{tramp} encounters two-factor logins or additional challenge
1743 questions, such as entering birth date or security code or passphrase,
1744 @value{tramp} needs a few more configuration steps to accommodate
1747 The difference between a password prompt and a passphrase prompt is
1748 that the password for completing the login while the passphrase is
1749 for authorizing access to local authentication information, such as
1752 There is no one configuration to accommodate all the variations in
1753 login security, especially not the exotic ones. However, @value{tramp}
1754 provides a few tweaks to address the most common ones.
1757 @item @var{tramp-shell-prompt-pattern}
1758 @vindex tramp-shell-prompt-pattern
1760 @code{tramp-shell-prompt-pattern} is for remote login shell prompt,
1761 which may not be the same as the local login shell prompt,
1762 @code{shell-prompt-pattern}. Since most hosts use identical prompts,
1763 @value{tramp} sets a similar default value for both prompts.
1765 @item @var{tramp-password-prompt-regexp}
1766 @item @var{tramp-wrong-passwd-regexp}
1767 @vindex tramp-password-prompt-regexp
1768 @vindex tramp-wrong-passwd-regexp
1770 @value{tramp} uses @var{tramp-password-prompt-regexp} to distinguish
1771 between prompts for passwords and prompts for passphrases. By default,
1772 @var{tramp-password-prompt-regexp} handles the detection in English
1773 language environments. See a localization example below:
1777 tramp-password-prompt-regexp
1781 '("passphrase" "Passphrase"
1783 "password" "Password"
1785 "passwort" "Passwort"
1787 "mot de passe" "Mot de passe") t)
1791 Similar localization may be necessary for handling wrong password
1792 prompts, for which @value{tramp} uses @var{tramp-wrong-passwd-regexp}.
1794 @item @command{tset} and other questions
1795 @cindex Unix command tset
1796 @cindex tset Unix command
1797 @vindex tramp-terminal-type
1799 To suppress inappropriate prompts for terminal type, @value{tramp}
1800 sets the @env{TERM} to @code{dumb} before the remote login process
1801 begins via the variable @code{tramp-terminal-type}. This will silence
1802 common @command{tset} related prompts.
1804 @value{tramp}'s strategy for handling such prompts (commonly triggered
1805 from login scripts on remote hosts) is to set the environment
1806 variables so that no prompts interrupt the shell initialization
1809 @vindex tramp-actions-before-shell
1811 An alternative approach is to configure @value{tramp} with strings
1812 that can identify such questions using
1813 @code{tramp-actions-before-shell}. Example:
1816 (defconst my-tramp-prompt-regexp
1817 (concat (regexp-opt '("Enter the birth date of your mother:") t)
1819 "Regular expression matching my login prompt question.")
1821 (defun my-tramp-action (proc vec)
1822 "Enter \"19000101\" in order to give a correct answer."
1823 (save-window-excursion
1824 (with-current-buffer (tramp-get-connection-buffer vec)
1825 (tramp-message vec 6 "\n%s" (buffer-string))
1826 (tramp-send-string vec "19000101"))))
1828 (add-to-list 'tramp-actions-before-shell
1829 '(my-tramp-prompt-regexp my-tramp-action))
1833 @item Conflicting names for users and variables in @file{.profile}
1835 When a user name is the same as a variable name in a local file, such
1836 as @file{.profile}, then @value{tramp} may send incorrect values for
1837 environment variables. To avoid incorrect values, change the local
1838 variable name to something different from the user name. For example,
1839 if the user name is @env{FRUMPLE}, then change the variable name to
1843 @item Non-Bourne commands in @file{.profile}
1845 When the remote host's @file{.profile} is also used for shells other
1846 than Bourne shell, then some incompatible syntaxes for commands in
1847 @file{.profile} may trigger errors in Bourne shell on the host and may
1848 not complete client's @value{tramp} connections.
1850 One example of a Bourne shell incompatible syntax in @file{.profile}:
1851 using @command{export FOO=bar} instead of @command{FOO=bar; export
1852 FOO}. After remote login, @value{tramp} will trigger an error during
1853 its execution of @command{/bin/sh} on the remote host because Bourne
1854 shell does not recognize the export command as entered in
1857 Likewise, (@code{~}) character in paths will cause errors because
1858 Bourne shell does not do (@code{~}) character expansions.
1860 One approach to avoiding these incompatibilities is to make all
1861 commands in @file{~/.shrc} and @file{~/.profile} Bourne shell
1862 compatible so @value{tramp} can complete connections to that remote.
1863 To accommodate using non-Bourne shells on that remote, use other
1864 shell-specific config files. For example, bash can use
1865 @file{~/.bash_profile} and ignore @file{.profile}.
1868 @item Interactive shell prompt
1870 @value{tramp} redefines the remote shell prompt internally for robust
1871 parsing. This redefinition affects the looks of a prompt in an
1872 interactive remote shell through commands, such as @kbd{M-x
1873 shell}. Such prompts, however, can be reset to something more readable
1874 and recognizable using these @value{tramp} variables.
1876 @value{tramp} sets the @env{INSIDE_EMACS} variable in the startup
1877 script file @file{~/.emacs_SHELLNAME}.
1879 @env{SHELLNAME} is @code{bash} or equivalent shell names. Change it by
1880 setting the environment variable @env{ESHELL} in the @file{.emacs} as
1884 (setenv "ESHELL" "bash")
1887 Then re-set the prompt string in @file{~/.emacs_SHELLNAME} as follows:
1890 # Reset the prompt for remote Tramp shells.
1891 if [ "$@{INSIDE_EMACS/*tramp*/tramp@}" == "tramp" ] ; then
1898 @xref{Interactive Shell, , , @value{emacsdir}}.
1902 @item @command{busybox} / @command{nc}
1903 @cindex Unix command nc
1904 @cindex nc Unix command
1906 @value{tramp}'s @option{nc} method uses the @command{nc} command to
1907 install and execute a listener as follows (see @code{tramp-methods}):
1913 The above command-line syntax has changed with @command{busybox}
1914 versions. If @command{nc} refuses the @command{-p} parameter, then
1915 overwrite as follows:
1919 'tramp-connection-properties
1920 `(,(regexp-quote "192.168.0.1") "remote-copy-args" (("-l") ("%r"))))
1924 where @samp{192.168.0.1} is the remote host IP address
1925 (@pxref{Predefined connection information}).
1930 @node Android shell setup
1931 @section Android shell setup hints
1932 @cindex android shell setup
1934 @value{tramp} uses the @option{adb} method to access Android
1935 devices. Android devices provide a restricted shell access through an
1936 USB connection. The local host must have the Android SDK installed.
1938 Applications such as @code{SSHDroid} that run @command{sshd} process
1939 on the Android device can accept any @option{ssh}-based methods
1940 provided these settings are adjusted:
1942 @code{sh} must be specified for remote shell since Android devices do
1943 not provide @code{/bin/sh}. @code{sh} will then invoke whatever shell is
1944 installed on the device with this setting:
1947 (add-to-list 'tramp-connection-properties
1948 (list (regexp-quote "192.168.0.26") "remote-shell" "sh"))
1952 where @samp{192.168.0.26} is the Android device's IP address.
1953 (@pxref{Predefined connection information}).
1955 @value{tramp} requires preserving @env{PATH} environment variable from
1956 user settings. Android devices prefer @file{/system/xbin} path over
1957 @file{/system/bin}. Both of these are set as follows:
1960 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1961 (add-to-list 'tramp-remote-path "/system/xbin")
1965 When the Android device is not @samp{rooted}, specify a writable
1966 directory for temporary files:
1969 (add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")
1973 Open a remote connection with the command @kbd{C-x C-f
1974 @trampfn{ssh,192.168.0.26#2222,}}, where @command{sshd} is listening on port
1977 To add a corresponding entry to the @file{~/.ssh/config} file
1978 (recommended), use this:
1982 HostName 192.168.0.26
1988 To use the host name @samp{android} instead of the IP address shown in
1989 the previous example, fix the connection properties as follows:
1992 (add-to-list 'tramp-connection-properties
1993 (list (regexp-quote "android") "remote-shell" "sh"))
1997 Open a remote connection with a more concise command @kbd{C-x C-f
1998 @trampfn{ssh,android,}}.
2001 @node Auto-save and Backup
2002 @section Auto-save and Backup configuration
2006 @vindex backup-directory-alist
2009 @vindex bkup-backup-directory-info
2012 To avoid @value{tramp} from saving backup files owned by root to
2013 locations accessible to others, default backup settings in
2015 @code{backup-directory-alist}
2018 @code{bkup-backup-directory-info}
2022 Here's a scenario where files could be inadvertently
2023 exposed. @value{emacsname} by default writes backup files to the same
2024 directory as the original files unless changed to another location,
2025 such as @file{~/.emacs.d/backups/}. Such a directory will also be used
2026 by default by @value{tramp} when using, say, a restricted file
2027 @file{@trampfn{su,root@@localhost,/etc/secretfile}}. The backup file
2028 of the secretfile is now owned by the user logged in from tramp and
2033 @code{backup-directory-alist}
2036 @code{bkup-backup-directory-info}
2038 is @code{nil} (the default), such problems do not occur.
2040 To ``turns off'' the backup feature for @value{tramp} files and stop
2041 @value{tramp} from saving to the backup directory, use this:
2045 (add-to-list 'backup-directory-alist
2046 (cons tramp-file-name-regexp nil))
2051 (require 'backup-dir)
2052 (add-to-list 'bkup-backup-directory-info
2053 (list tramp-file-name-regexp ""))
2059 Disabling backups can be targeted to just the @option{su} and
2060 @option{sudo} methods:
2063 (setq backup-enable-predicate
2065 (and (normal-backup-enable-predicate name)
2067 (let ((method (file-remote-p name 'method)))
2068 (when (stringp method)
2069 (member method '("su" "sudo"))))))))
2073 Another option is to create better backup file naming with user and
2074 host names prefixed to the file name. For example, transforming
2075 @file{/etc/secretfile} to
2076 @file{~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile}, set the
2077 @value{tramp} variable
2079 @code{tramp-backup-directory-alist}
2082 @code{tramp-bkup-backup-directory-info}
2084 from the existing variable
2086 @code{backup-directory-alist}.
2089 @code{bkup-backup-directory-info}.
2092 Then @value{tramp} backs up to a file name that is transformed with a
2093 prefix consisting of the DIRECTORY name. This file name prefixing
2094 happens only when the DIRECTORY is an absolute local file name.
2101 (add-to-list 'backup-directory-alist
2102 (cons "." "~/.emacs.d/backups/"))
2103 (setq tramp-backup-directory-alist backup-directory-alist)
2108 (require 'backup-dir)
2109 (add-to-list 'bkup-backup-directory-info
2110 (list "." "~/.emacs.d/backups/" 'full-path))
2111 (setq tramp-bkup-backup-directory-info bkup-backup-directory-info)
2116 The backup file name of
2117 @file{@trampfn{su,root@@localhost,/etc/secretfile}} would be
2119 @file{@trampfn{su,root@@localhost,~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}}
2122 @file{@trampfn{su,root@@localhost,~/.emacs.d/backups/![su!root@@localhost]!etc!secretfile~}}
2125 Just as for backup files, similar issues of file naming affect
2126 auto-saving @value{tramp} files.
2128 Auto-saved files are saved in the directory specified by the variable
2129 @code{auto-save-file-name-transforms}. By default this is set to the
2130 local temporary directory. But in some versions of Debian GNU/Linux,
2131 this points to the source directory where the @value{emacsname} was
2132 compiled. Reset such values to a valid directory.
2134 Set @code{auto-save-file-name-transforms} to @code{nil} to save
2135 auto-saved files to the same directory as the original file.
2137 Alternatively, set the variable @code{tramp-auto-save-directory} to
2138 direct all auto saves to that location.
2141 @code{auto-save-directory} can also be used here instead of other
2142 locations specified above.
2145 @node Windows setup hints
2146 @section Issues with Cygwin ssh
2147 @cindex Cygwin, issues
2149 This section is incomplete. Please share your solutions.
2151 @cindex method sshx with Cygwin
2152 @cindex sshx method with Cygwin
2154 Cygwin's @command{ssh} works only with a Cygwin version of
2155 @value{emacsname}. To check for compatibility: type @kbd{M-x eshell}, and
2156 start @kbd{ssh test.host}. Incompatibilities trigger this message:
2159 Pseudo-terminal will not be allocated because stdin is not a terminal.
2162 Some older versions of Cygwin's @command{ssh} work with the
2163 @option{sshx} access method. Consult Cygwin's FAQ at
2164 @uref{http://cygwin.com/faq/} for details.
2167 @cindex method scpx with Cygwin
2168 @cindex scpx method with Cygwin
2170 When using the @option{scpx} access method, @value{emacsname} may call
2171 @command{scp} with Windows file naming, such as @code{c:/foo}. But
2172 the version of @command{scp} that is installed with Cygwin does not
2173 know about Windows file naming, which causes it to incorrectly look
2174 for a host named @code{c}.
2176 A workaround: write a wrapper script for @option{scp} to convert
2177 Windows file names to Cygwin file names.
2179 @cindex Cygwin and ssh-agent
2180 @cindex SSH_AUTH_SOCK and @value{emacsname} on Windows
2182 When using the @command{ssh-agent} on Windows for password-less
2183 interaction, @option{ssh} methods depend on the environment variable
2184 @env{SSH_AUTH_SOCK}. But this variable is not set when
2185 @value{emacsname} is started from a Desktop shortcut and
2186 authentication fails.
2188 One workaround is to use a Windows based SSH Agent, such as
2189 Pageant. It is part of the Putty Suite of tools.
2191 The fallback is to start @value{emacsname} from a shell.
2195 @chapter Using @value{tramp}
2196 @cindex using @value{tramp}
2198 @value{tramp} operates transparently, accessing remote files as if
2199 they are local. However, @value{tramp} employs a formalized remote
2200 file naming syntax to perform its functions transparently. This
2201 syntax consists of many parts specifying access methods,
2202 authentication, host names, and file names.
2204 @value{ftppackagename} uses a similar syntax.
2209 Unlike opening local files in @value{emacsname}, which are
2210 instantaneous, opening remote files in @value{tramp} is slower at
2211 first. Sometimes there is a noticeable delay before the prompts for
2212 passwords or authentication appear in the minibuffer. Hitting
2213 @kbd{@key{RET}} or other keys during this gap will be processed by
2214 @value{emacsname}. This type-ahead facility is a feature of
2215 @value{emacsname} that may cause missed prompts when using
2219 * File name Syntax:: @value{tramp} file name conventions.
2220 * File name completion:: File name completion.
2221 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
2222 * Remote processes:: Integration with other @value{emacsname} packages.
2223 * Cleanup remote connections:: Cleanup remote connections.
2227 @node File name Syntax
2228 @section @value{tramp} file name conventions
2229 @cindex file name syntax
2230 @cindex file name examples
2232 @file{@trampf{host,localfilename}}
2233 opens file @var{localfilename} on the remote host @var{host}, using
2234 the default method. @xref{Default Method}.
2237 @item @value{prefix}melancholia@value{postfix}.emacs
2238 For the file @file{.emacs} located in the home directory, on the host
2241 @item @value{prefix}melancholia.danann.net@value{postfix}.emacs
2242 For the file @file{.emacs} specified using the fully qualified domain name of
2245 @item @value{prefix}melancholia@value{postfix}~/.emacs
2246 For the file @file{.emacs} specified using the @file{~}, which is expanded.
2248 @item @value{prefix}melancholia@value{postfix}~daniel/.emacs
2249 For the file @file{.emacs} located in @code{daniel}'s home directory
2250 on the host, @code{melancholia}. The @file{~<user>} construct is
2251 expanded to the home directory of that user on the remote host.
2253 @item @value{prefix}melancholia@value{postfix}/etc/squid.conf
2254 For the file @file{/etc/squid.conf} on the host @code{melancholia}.
2258 @var{host} can take IPv4 or IPv6 address, as in
2259 @file{@trampf{127.0.0.1,.emacs}} or
2260 @file{@trampf{@value{ipv6prefix}::1@value{ipv6postfix},.emacs}}.
2262 For syntactical reasons, IPv6 addresses must be embedded in square
2263 brackets @file{@value{ipv6prefix}} and @file{@value{ipv6postfix}}.
2266 By default, @value{tramp} will use the current local user name as the
2267 remote user name for log in to the remote host. Specifying a different
2268 name using the proper syntax will override this default behavior:
2271 @trampf{user@@host,path/to.file}
2274 @file{@trampf{daniel@@melancholia,.emacs}} is for file
2275 @file{.emacs} in @code{daniel}'s home directory on the host,
2278 Specify other file access methods (@pxref{Inline methods},
2279 @pxref{External methods}) as part of the file name.
2282 Method name comes before user name, as in
2283 @file{@value{prefix}@var{method}@value{postfixhop}} (Note the trailing
2287 This is done by replacing the initial @file{@value{prefix}} with
2288 @file{@value{prefix}@var{method}@value{postfixhop}} (Note the trailing
2291 The syntax specifications for user, host, and file do not change.
2293 To connect to the host @code{melancholia} as @code{daniel}, using
2294 @option{ssh} method for @file{.emacs} in @code{daniel}'s home
2295 directory, the full specification is:
2296 @file{@trampfn{ssh,daniel@@melancholia,.emacs}}.
2298 A remote file name containing a host name, which is the same string as
2299 a method name, is not allowed.
2301 For specifying port numbers, affix @file{#<port>} to the host
2302 name. For example: @file{@trampfn{ssh,daniel@@melancholia#42,.emacs}}.
2305 @node File name completion
2306 @section File name completion
2307 @cindex file name completion
2309 @value{tramp} can complete the following @value{tramp} file name
2310 components: method names, user names, host names, and file names
2311 located on remote hosts.
2313 Enable this by activating partial completion in @file{.emacs}.
2315 @xref{Completion Options, , , @value{emacsdir}}.
2319 For example, type @kbd{C-x C-f @value{prefix}t @key{TAB}},
2320 @value{tramp} completion choices show up as
2323 @c @multitable {@trampfn{telnet,melancholia.danann.net,}} {@trampfn{telnet,192.168.0.1,}}
2324 @multitable @columnfractions .5 .5
2326 @item @value{prefixhop}telnet@value{postfixhop} @tab tmp/
2327 @item @value{prefixhop}toto@value{postfix} @tab
2330 @item @value{prefixhop}telnet@value{postfixhop} @tab @value{prefixhop}toto@value{postfix}
2335 @samp{@value{prefixhop}telnet@value{postfixhop}}
2336 is a possible completion for the respective method,
2338 @samp{tmp/} stands for the directory @file{/tmp} on your local host,
2340 and @samp{@value{prefixhop}toto@value{postfix}}
2341 might be a host @value{tramp} has detected in your @file{~/.ssh/known_hosts}
2342 file (when using @option{ssh} as default method).
2344 Type @kbd{e @key{TAB}} for the minibuffer completion to
2345 @samp{@value{prefix}telnet@value{postfixhop}}. Typing @kbd{@key{TAB}}
2346 shows host names @value{tramp} from @file{/etc/hosts} file, for example.
2349 @multitable @columnfractions .5 .5
2350 @c @multitable {@trampfn{telnet,melancholia.danann.net,}} {@trampfn{telnet,192.168.0.1,}}
2351 @item @trampfn{telnet,127.0.0.1,} @tab @trampfn{telnet,192.168.0.1,}
2352 @c @item @trampfn{telnet,@value{ipv6prefix}::1@value{ipv6postfix},} @tab @trampfn{telnet,localhost,}
2353 @item @value{prefix}telnet@value{postfixhop}@value{ipv6prefix}::1@value{ipv6postfix}@value{postfix} @tab @trampfn{telnet,localhost,}
2354 @item @trampfn{telnet,melancholia.danann.net,} @tab @trampfn{telnet,melancholia,}
2358 Choose a host from the above list and then continue to complete file
2361 When the configuration (@pxref{Customizing Completion}) includes user
2362 names, then the completion lists will account for the user names as well.
2364 Remote hosts previously visited or hosts whose connections are kept
2365 persistently (@pxref{Connection caching}) will be included in the
2368 After remote host name completion comes completion of file names on
2369 the remote host. It works the same as with local host file completion,
2370 except that killing with double-slash @file{//} kills only the file
2371 name part of the @value{tramp} file name syntax.
2373 A triple-slash stands for the default behavior.
2376 @xref{Minibuffer File, , , @value{emacsdir}}.
2384 @kbd{C-x C-f @trampfn{telnet,melancholia,/usr/local/bin//etc} @key{TAB}}
2385 @print{} @trampfn{telnet,melancholia,/etc}
2387 @kbd{C-x C-f @trampfn{telnet,melancholia,//etc} @key{TAB}}
2390 @kbd{C-x C-f @trampfn{telnet,melancholia,/usr/local/bin///etc} @key{TAB}}
2395 @kbd{C-x C-f @trampfn{telnet,melancholia,/usr/local/bin//}}
2396 @print{} @trampfn{telnet,melancholia,/}
2398 @kbd{C-x C-f @trampfn{telnet,melancholia,//}}
2403 During file name completion, remote directory contents are re-read
2404 regularly to account for any changes in the filesystem that may affect
2405 the completion candidates. Such re-reads can account for changes to
2406 the file system by applications outside @value{emacsname}
2407 (@pxref{Connection caching}).
2409 @defopt tramp-completion-reread-directory-timeout
2410 @vindex tramp-completion-reread-directory-timeout
2411 The timeout is number of seconds since last remote command for
2412 rereading remote directory contents. 0 re-reads immediately during
2413 file name completion, @code{nil} uses cached directory contents.
2417 @node Ad-hoc multi-hops
2418 @section Declaring multiple hops in the file name
2419 @cindex multi-hop, ad-hoc
2420 @cindex proxy hosts, ad-hoc
2422 @value{tramp} file name syntax can accommodate ad hoc specification of
2423 multiple proxies without using @code{tramp-default-proxies-alist}
2424 configuration setup(@pxref{Multi-hops}).
2426 Each proxy is specified using the same syntax as the remote host
2427 specification minus the file name part. Each hop is separated by a
2428 @samp{|}. Chain the proxies from the starting host to the destination
2429 remote host name and file name. For example, hopping over a single
2430 proxy @samp{bird@@bastion} to a remote file on @samp{you@@remotehost}:
2433 @c @kbd{C-x C-f @trampfn{ssh@value{postfixhop}bird@@bastion|ssh,you,remotehost,/path}}
2434 @kbd{C-x C-f @value{prefix}ssh@value{postfixhop}bird@@bastion|ssh@value{postfixhop}you@@remotehost@value{postfix}/path}
2437 Proxies can take patterns @code{%h} or @code{%u}.
2439 @value{tramp} adds the ad-hoc definitions on the fly to
2440 @code{tramp-default-proxies-alist} and is available for re-use during
2441 that @value{emacsname} session. Subsequent @value{tramp} connections
2442 to the same remote host can then use the shortcut form:
2443 @samp{@trampfn{ssh,you@@remotehost,/path}}.
2445 @defopt tramp-save-ad-hoc-proxies
2446 @vindex tramp-save-ad-hoc-proxies
2447 For ad-hoc definitions to be saved automatically in
2448 @option{tramp-default-proxies-alist} for future @value{emacsname}
2449 sessions, set @option{tramp-save-ad-hoc-proxies}.
2452 (setq tramp-save-ad-hoc-proxies t)
2457 @node Remote processes
2458 @section Integration with other @value{emacsname} packages
2462 @value{tramp} supports starting new running processes on the remote
2463 host for discovering remote file names. @value{emacsname} packages on
2464 the remote host need no specific modifications for @value{tramp}'s
2467 This type of integration does not work with the @option{ftp} method,
2468 and does not support the pty association as specified in
2469 @code{start-file-process}.
2471 @code{process-file} and @code{start-file-process} work on the remote
2472 host when the variable @code{default-directory} is remote:
2475 (let ((default-directory "/ssh:remote.host:"))
2476 (start-file-process "grep" (get-buffer-create "*grep*")
2477 "/bin/sh" "-c" "grep -e tramp *"))
2482 Remote processes do not apply to GVFS (see @ref{GVFS based methods})
2483 because the remote file system is mounted on the local host and
2484 @value{tramp} just accesses by changing the @code{default-directory}.
2487 @value{tramp} starts a remote process when a command is executed in a
2488 remote file or directory buffer. As of now, these packages have been
2489 integrated to work with @value{tramp}: @file{compile.el} (commands
2490 like @code{compile} and @code{grep}) and @file{gud.el} (@code{gdb} or
2493 For @value{tramp} to find the command on the remote, it must be
2494 accessible through the default search path as setup by @value{tramp}
2495 upon first connection. Alternatively, use an absolute path or extend
2496 @code{tramp-remote-path} (see @ref{Remote programs}):
2499 (add-to-list 'tramp-remote-path "~/bin")
2500 (add-to-list 'tramp-remote-path "/appli/pub/bin")
2503 Customize @code{tramp-remote-process-environment} to suit the remote
2504 program's environment for the remote host.
2505 @code{tramp-remote-process-environment} is a list of strings
2506 structured similar to @code{process-environment}, where each element
2507 is a string of the form @samp{ENVVARNAME=VALUE}.
2509 To avoid any conflicts with local host variables set through local
2510 configuration files, such as @file{~/.profile}, use @samp{ENVVARNAME=}
2511 to unset them for the remote environment.
2514 Use @code{add-to-list} to add entries:
2517 (add-to-list 'tramp-remote-process-environment "JAVA_HOME=/opt/java")
2520 Modifying or deleting already existing values in the
2521 @code{tramp-remote-process-environment} list may not be feasible on
2522 restricted remote hosts. For example, some system administrators
2523 disallow changing @env{HISTORY} variable. To accommodate such
2524 restrictions when using @value{tramp}, fix the
2525 @code{tramp-remote-process-environment} by the following code in the
2526 local @file{.emacs} file:
2529 (let ((process-environment tramp-remote-process-environment))
2530 (setenv "HISTORY" nil)
2531 (setq tramp-remote-process-environment process-environment))
2534 @value{tramp} does not use the defaults specified in
2535 @code{process-environment} for running @code{process-file} or
2536 @code{start-file-process} on remote hosts. When values from
2537 @code{process-environment} are needed for remote processes, then set
2541 (let ((process-environment (cons "HGPLAIN=1" process-environment)))
2542 (process-file @dots{}))
2545 This works only for environment variables not already set in the
2546 @code{process-environment}.
2548 For integrating other @value{emacsname} packages so @value{tramp} can
2549 execute remotely, please file a bug report. @xref{Bug Reports}.
2552 @subsection Running remote programs that create local X11 windows
2554 To allow a remote program to create an X11 window on the local host,
2555 set the @env{DISPLAY} environment variable for the remote host as
2556 follows in the local @file{.emacs} file:
2559 (add-to-list 'tramp-remote-process-environment
2560 (format "DISPLAY=%s" (getenv "DISPLAY")))
2564 @code{(getenv "DISPLAY")} should return a recognizable name for the
2565 local host that the remote host can redirect X11 window
2566 interactions. If querying for a recognizable name is not possible for
2567 whatever reason, then replace @code{(getenv "DISPLAY")} with a
2568 hard-coded, fixed name. Note that using @code{:0} for X11 display name
2569 here will not work as expected.
2571 An alternate approach is specify @code{ForwardX11 yes} or
2572 @code{ForwardX11Trusted yes} in the file @file{~/.ssh/config} on the
2576 @subsection Running @code{shell} on a remote host
2579 Set @option{explicit-shell-file-name} to the appropriate shell name
2580 when using @value{tramp} between two hosts with different operating
2581 systems, such as @samp{windows-nt} and @samp{gnu/linux}. This option
2582 ensures the correct name of the remote shell program.
2585 Starting with Emacs 24, when @option{explicit-shell-file-name} is
2586 equal to @code{nil}, calling @code{shell} interactively will prompt
2591 @subsection Running @code{shell-command} on a remote host
2592 @cindex shell-command
2594 @code{shell-command} executes commands synchronously or asynchronously
2595 on remote hosts and displays output in buffers on the local
2599 @kbd{C-x C-f @trampfn{sudo,,} @key{RET}}
2600 @kbd{M-! tail -f /var/log/syslog.log & @key{RET}}
2603 @command{tail} command outputs continuously to the local buffer,
2604 @file{*Async Shell Command*}
2607 @kbd{M-x auto-revert-tail-mode} runs similarly showing continuous output.
2611 @subsection Running @code{eshell} on a remote host
2614 @value{tramp} is integrated into @file{eshell.el}, which enables
2615 interactive eshell sessions on remote hosts at the command prompt.
2616 You must add the module @code{eshell-tramp} to
2617 @code{eshell-modules-list}. Here's a sample interaction after opening
2618 @kbd{M-x eshell} on a remote host:
2621 @b{~ $} cd @trampfn{sudo,,/etc} @key{RET}
2622 @b{@trampfn{sudo,root@@host,/etc} $} hostname @key{RET}
2624 @b{@trampfn{sudo,root@@host,/etc} $} id @key{RET}
2625 uid=0(root) gid=0(root) groups=0(root)
2626 @b{@trampfn{sudo,root@@host,/etc} $} find-file shadow @key{RET}
2628 @b{@trampfn{sudo,root@@host,/etc} $}
2632 @code{eshell} in @value{emacsname} 23.2 added custom @code{su} and
2633 @code{sudo} commands that set the default directory correctly for the
2634 @file{*eshell*} buffer. @value{tramp} silently updates
2635 @code{tramp-default-proxies-alist} with an entry for this directory
2636 (@pxref{Multi-hops}):
2639 @b{~ $} cd @trampfn{ssh,user@@remotehost,/etc} @key{RET}
2640 @b{@trampfn{ssh,user@@remotehost,/etc} $} find-file shadow @key{RET}
2641 File is not readable: @trampfn{ssh,user@@remotehost,/etc/shadow}
2642 @b{@trampfn{ssh,user@@remotehost,/etc} $} sudo find-file shadow @key{RET}
2645 @b{@trampfn{ssh,user@@remotehost,/etc} $} su - @key{RET}
2646 @b{@trampfn{su,root@@remotehost,/root} $} id @key{RET}
2647 uid=0(root) gid=0(root) groups=0(root)
2648 @b{@trampfn{su,root@@remotehost,/root} $}
2653 @anchor{Running a debugger on a remote host}
2654 @subsection Running a debugger on a remote host
2659 @file{gud.el} provides a unified interface to symbolic debuggers
2662 (@ref{Debuggers, , , @value{emacsdir}}).
2665 @value{tramp} can run debug on remote hosts by calling @code{gdb}
2666 with a remote file name:
2669 @kbd{M-x gdb @key{RET}}
2670 @b{Run gdb (like this):} gdb --annotate=3 @trampfn{ssh,host,~/myprog} @key{RET}
2673 Relative file names are based on the remote default directory. When
2674 @file{myprog.pl} exists in @file{@trampfn{ssh,host,/home/user}},
2675 valid calls include:
2678 @kbd{M-x perldb @key{RET}}
2679 @b{Run perldb (like this):} perl -d myprog.pl @key{RET}
2682 Just the local part of a remote file name, such as @kbd{perl -d
2683 /home/user/myprog.pl}, is not possible.
2685 Arguments of the program to be debugged must be literal, can take
2686 relative or absolute paths, but not remote paths.
2689 @subsection Running remote processes on Windows hosts
2693 @command{winexe} runs processes on a remote Windows host, and
2694 @value{tramp} can use it for @code{process-file} and
2695 @code{start-file-process}.
2697 @code{tramp-smb-winexe-program} specifies the local @command{winexe}
2698 command. Powershell V2.0 on the remote host is required to run
2699 processes triggered from @value{tramp}.
2701 @option{explicit-shell-file-name} and @option{explicit-*-args} have to
2702 be set properly so @kbd{M-x shell} can open a proper remote shell on a
2703 Windows host. To open @command{cmd}, set it as follows:
2706 (setq explicit-shell-file-name "cmd"
2707 explicit-cmd-args '("/q"))
2711 To open @command{powershell} as a remote shell, use this:
2714 (setq explicit-shell-file-name "powershell"
2715 explicit-powershell-args '("-file" "-"))
2719 @node Cleanup remote connections
2720 @section Cleanup remote connections
2723 @value{tramp} provides several ways to flush remote connections.
2725 @deffn Command tramp-cleanup-connection vec
2726 This command flushes all connection related objects. @option{vec} is
2727 the internal representation of a remote connection. When called
2728 interactively, this command lists active remote connections in the
2729 minibuffer. Each connection is of the format
2730 @file{@trampfn{method,user@@host,}}. Flushing remote connections also
2732 cache (@pxref{Password handling}), file cache, connection cache
2733 (@pxref{Connection caching}), and connection buffers.
2736 @deffn Command tramp-cleanup-this-connection
2737 Flushes only the current buffer's remote connection objects, the same
2738 as in @code{tramp-cleanup-connection}.
2741 @deffn Command tramp-cleanup-all-connections
2742 Flushes all active remote connection objects, the same as in
2743 @code{tramp-cleanup-connection}.
2746 @deffn Command tramp-cleanup-all-buffers
2747 Just as for @code{tramp-cleanup-all-connections}, all remote
2748 connections are cleaned up in addition to killing buffers related to
2749 that remote connection.
2754 @chapter Reporting Bugs and Problems
2757 @value{tramp}'s development team is actively engaged in solving bugs
2758 and problems and looks to feature requests and suggestions.
2760 @value{tramp}'s mailing list is the place for more advice and
2761 information on working with @value{tramp}, solving problems,
2762 discussing, and general discussions about @value{tramp}.
2764 @value{tramp}'s mailing list is moderated but even non-subscribers can
2765 post for moderator approval. Sometimes this approval step may take as
2766 long as 48 hours due to public holidays.
2768 @email{tramp-devel@@gnu.org} is the mailing list. Messages sent to
2769 this address go to all the subscribers. This is @emph{not} the
2770 address to send subscription requests to.
2772 To subscribe to the mailing list, visit:
2773 @uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/, the
2774 @value{tramp} Mail Subscription Page}.
2777 @ifset installchapter
2778 Before sending a bug report, run the test suite first @ref{Testing}.
2783 Check if the bug or problem is already addressed in @xref{Frequently
2786 Run @kbd{M-x tramp-bug} to generate a buffer with details of the
2787 system along with the details of the @value{tramp}
2788 installation. Please include these details with the bug report.
2790 The bug report must describe in as excruciating detail as possible the
2791 steps required to reproduce the problem. These details must include
2792 the setup of the remote host and any special or unique conditions that
2795 Include a minimal test case that reproduces the problem. This will
2796 help the development team find the best solution and avoid unrelated
2799 To exclude cache-related problems, flush all caches before running the
2800 test, @ref{Cleanup remote connections}.
2802 When including @value{tramp}'s messages in the bug report, increase
2803 the verbosity level to 6 (@pxref{Traces and Profiles, Traces}) in the
2804 @file{~/.emacs} file before repeating steps to the bug. Include the
2805 contents of the @file{*tramp/foo*} and @file{*debug tramp/foo*}
2806 buffers with the bug report.
2808 @strong{Note} that a verbosity level greater than 6 is not necessary
2809 at this stage. Also note that a verbosity level of 6 or greater, the
2810 contents of files and directories will be included in the debug
2811 buffer. Passwords typed in @value{tramp} will never be included
2815 @node Frequently Asked Questions
2816 @chapter Frequently Asked Questions
2817 @cindex frequently asked questions
2822 Where is the latest @value{tramp}?
2824 @value{tramp} is available at the GNU URL:
2827 @uref{ftp://ftp.gnu.org/gnu/tramp/}
2830 @value{tramp}'s GNU project page is located here:
2833 @uref{http://savannah.gnu.org/projects/tramp/}
2837 Which systems does it work on?
2839 The package works successfully on Emacs 22, Emacs 23, Emacs 24, Emacs
2840 25, XEmacs 21 (starting with 21.4), and SXEmacs 22.
2842 While Unix and Unix-like systems are the primary remote targets,
2843 @value{tramp} has equal success connecting to other platforms, such as
2844 MS Windows XP/Vista/7.
2848 How to speed up @value{tramp}?
2850 @value{tramp} does many things in the background, some of which
2851 depends on network speeds, response speeds of remote hosts, and
2852 authentication delays. During these operations, @value{tramp}'s
2853 responsiveness slows down. Some suggestions within the scope of
2854 @value{tramp}'s settings include:
2856 Use an external method, such as @option{scp}, which are faster than
2859 Keep the file @code{tramp-persistency-file-name}, which is where
2860 @value{tramp} caches remote information about hosts and files. Caching
2861 is enabled by default. Don't disable it.
2863 Set @code{remote-file-name-inhibit-cache} to @code{nil} if remote
2864 files are not independently updated outside @value{tramp}'s control.
2865 That cache cleanup will be necessary if the remote directories or
2866 files are updated independent of @value{tramp}.
2868 Set @code{tramp-completion-reread-directory-timeout} to @code{nil} to
2869 speed up completions, @ref{File name completion}.
2871 Disable version control to avoid delays:
2874 (setq vc-ignore-dir-regexp
2875 (format "\\(%s\\)\\|\\(%s\\)"
2876 vc-ignore-dir-regexp
2877 tramp-file-name-regexp))
2880 Disable excessive traces. Set @code{tramp-verbose} to 3 or lower,
2881 default being 3. Increase trace levels temporarily when hunting for
2885 @value{tramp} does not connect to the remote host
2887 Three main reasons for why @value{tramp} does not connect to the remote host:
2891 Unknown characters in the prompt
2893 @value{tramp} needs a clean recognizable prompt on the remote host for
2894 accurate parsing. Shell prompts that contain escape sequences for
2895 coloring cause parsing problems. @ref{Remote shell setup} for
2896 customizing prompt detection using regular expressions.
2898 To check if the remote host's prompt is being recognized, use this
2899 test: switch to @value{tramp} connection buffer @file{*tramp/foo*},
2900 put the cursor at the top of the buffer, and then apply the following
2904 @kbd{M-: (re-search-forward (concat tramp-shell-prompt-pattern "$"))}
2907 If the cursor has not moved to the prompt at the bottom of the buffer,
2908 then @value{tramp} has failed to recognize the prompt.
2910 When using zsh on remote hosts, disable zsh line editor because zsh
2911 uses left-hand side and right-hand side prompts in parallel. Add the
2912 following line to @file{~/.zshrc}:
2915 [ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
2918 When using fish shell on remote hosts, disable fancy formatting by
2919 adding the following to @file{~/.config/fish/config.fish}:
2922 function fish_prompt
2923 if test $TERM = "dumb"
2931 When using WinSSHD on remote hosts, @value{tramp} do not recognize the
2932 strange prompt settings.
2935 Echoed characters after login
2937 @value{tramp} suppresses echos from remote hosts with the
2938 @command{stty -echo} command. But sometimes it is too late to suppress
2939 welcome messages from the remote host containing harmful control
2940 characters. Using @option{sshx} or @option{scpx} methods can avoid
2941 this problem because they allocate a pseudo tty. @xref{Inline
2945 @value{tramp} stops transferring strings longer than 500 characters
2947 Set @code{tramp-chunksize} to 500 to get around this problem, which is
2948 related to faulty implementation of @code{process-send-string} on
2949 HP-UX, FreeBSD and Tru64 Unix systems. Consult the documentation for
2950 @code{tramp-chunksize} to see when this is necessary.
2952 Set @code{file-precious-flag} to @code{t} for files accessed by
2953 @value{tramp} so the file contents are checked using checksum by
2954 first saving to a temporary file.
2956 @pxref{Saving Buffers, , , elisp}
2963 (when (file-remote-p default-directory)
2964 (set (make-local-variable 'file-precious-flag) t))))
2970 @value{tramp} does not recognize if a @command{ssh} session hangs
2972 @command{ssh} sessions on the local host hang when the network is
2973 down. @value{tramp} cannot safely detect such hangs. The network
2974 configuration for @command{ssh} can be configured to kill such hangs
2975 with the following command in the @file{~/.ssh/config}:
2979 ServerAliveInterval 5
2984 @value{tramp} does not use default @command{ssh} @code{ControlPath}
2986 @value{tramp} overwrites @code{ControlPath} settings when initiating
2987 @command{ssh} sessions. @value{tramp} does this to fend off a stall
2988 if a master session opened outside the @value{emacsname} session is no
2989 longer open. That is why @value{tramp} prompts for the password again
2990 even if there is an @command{ssh} already open.
2992 Some @command{ssh} versions support a @code{ControlPersist} option,
2993 which allows to set the @code{ControlPath} provided the variable
2994 @code{tramp-ssh-controlmaster-options} is customized as follows:
2997 (setq tramp-ssh-controlmaster-options
2999 "-o ControlPath=/tmp/ssh-ControlPath-%%r@@%%h:%%p "
3000 "-o ControlMaster=auto -o ControlPersist=yes"))
3003 Note how "%r", "%h" and "%p" must be encoded as "%%r", "%%h" and
3006 If the @file{~/.ssh/config} is configured appropriately for the above
3007 behavior, then any changes to @command{ssh} can be suppressed with
3008 this @code{nil} setting:
3011 (setq tramp-use-ssh-controlmaster-options nil)
3016 File name completion does not work with @value{tramp}
3018 @acronym{ANSI} escape sequences from the remote shell may cause errors
3019 in @value{tramp}'s parsing of remote buffers.
3021 To test if this is the case, open a remote shell and check if the output
3022 of @command{ls} is in color.
3024 To disable @acronym{ANSI} escape sequences from the remote hosts,
3025 disable @option{--color=yes} or @option{--color=auto} in the remote
3026 host's @file{.bashrc} or @file{.profile}. Turn this alias on and off
3027 to see if file name completion works.
3030 File name completion does not work in directories with large number of
3033 This may be related to globbing, which is the use of shell's ability
3034 to expand wild card specifications, such as @samp{*.c}. For
3035 directories with large number of files, globbing might exceed the
3036 shell's limit on length of command lines and hang. @value{tramp} uses
3039 To test if globbing hangs, open a shell on the remote host and then
3040 run @samp{ls -d * ..?* > /dev/null}.
3042 When testing, ensure the remote shell is the same shell
3043 (@command{/bin/sh}, @command{ksh} or @command{bash}), that
3044 @value{tramp} uses when connecting to that host.
3048 How to get notified after @value{tramp} completes file transfers?
3050 Make @value{emacsname} beep after reading from or writing to the
3051 remote host with the following code in @file{~/.emacs} file.
3054 (defadvice tramp-handle-write-region
3055 (after tramp-write-beep-advice activate)
3056 "Make tramp beep after writing a file."
3060 (defadvice tramp-handle-do-copy-or-rename-file
3061 (after tramp-copy-beep-advice activate)
3062 "Make tramp beep after copying a file."
3066 (defadvice tramp-handle-insert-file-contents
3067 (after tramp-insert-beep-advice activate)
3068 "Make tramp beep after inserting a file."
3076 How to get a Visual Warning when working with @samp{root} privileges
3078 Get a modeline indication when working with @samp{root} privileges
3079 with the following code (tested with @value{emacsname} 22.1) in
3080 @file{~/.emacs} file:
3083 (defun my-mode-line-function ()
3084 (when (string-match "^/su\\(do\\)?:" default-directory)
3085 (setq mode-line-format
3086 (format-mode-line mode-line-format 'font-lock-warning-face))))
3088 (add-hook 'find-file-hook 'my-mode-line-function)
3089 (add-hook 'dired-mode-hook 'my-mode-line-function)
3096 How to get host indication in the mode line?
3098 The following code (tested with @value{emacsname} 22.1) in
3099 @file{~/.emacs} file shows it:
3102 (defconst my-mode-line-buffer-identification
3106 (if (file-remote-p default-directory)
3107 (tramp-file-name-host
3108 (tramp-dissect-file-name default-directory))
3110 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
3111 (substring host-name 0 (match-beginning 1))
3116 mode-line-buffer-identification
3117 my-mode-line-buffer-identification)
3123 mode-line-buffer-identification
3124 my-mode-line-buffer-identification)))
3127 The mode line in @value{emacsname} 23.1 and later versions now
3128 contains an indication if @code{default-directory} for the current
3129 buffer is on a remote host. Moreover, the corresponding tool-tip
3130 shows the remote host name. The above @code{:eval} clause can also be
3131 simplified to show the host name in the mode line:
3136 (or (file-remote-p default-directory 'host)
3138 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
3139 (substring host-name 0 (match-beginning 1))
3147 Remote host does not understand default options for directory listing
3149 @value{emacsname} computes the @command{dired} options based on the
3150 local host but if the remote host cannot understand the same
3151 @command{ls} command, then set them with a hook as follows:
3155 'dired-before-readin-hook
3157 (when (file-remote-p default-directory)
3158 (setq dired-actual-switches "-al"))))
3164 Why is @file{~/.sh_history} file on the remote host growing?
3166 Due to @command{ksh} saving tilde expansions triggered by
3167 @value{tramp}, the history file is probably growing rapidly. To fix,
3168 turn off saving history by putting this shell code in the
3172 if [ -f $HOME/.sh_history ] ; then
3173 /bin/rm $HOME/.sh_history
3175 if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
3178 if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
3183 For @option{ssh}-based method, add the following line to your
3184 @file{~/.ssh/environment} file:
3192 How to shorten long file names when typing in @value{tramp}?
3194 Adapt several of these approaches to reduce typing. If the full name
3195 is @file{@trampfn{ssh,news@@news.my.domain,/opt/news/etc}}, then:
3200 Use default values for method name and user name:
3202 You can define default methods and user names for hosts,
3203 (@pxref{Default Method}, @pxref{Default User}):
3206 (setq tramp-default-method "ssh"
3207 tramp-default-user "news")
3210 The reduced typing: @kbd{C-x C-f @trampf{news.my.domain,/opt/news/etc}}.
3212 @strong{Note} that there are some useful shortcuts already. Accessing
3213 your local host as @samp{root} user, is possible just by @kbd{C-x C-f
3217 Use configuration options of the access method:
3219 Programs used for access methods already offer powerful configurations
3220 (@pxref{Customizing Completion}). For @option{ssh}, configure the
3221 file @file{~/.ssh/config}:
3225 HostName news.my.domain
3229 The reduced typing: @kbd{C-x C-f @trampfn{ssh,xy,/opt/news/etc}}.
3231 Depending on the number of files in the directories, host names
3232 completion can further reduce key strokes: @kbd{C-x C-f
3233 @value{prefix}ssh@value{postfixhop}x @key{TAB}}.
3236 Use environment variables to expand long strings
3238 For long file names, set up environment variables that are expanded in
3239 the minibuffer. Environment variables are set either outside
3240 @value{emacsname} or inside @value{emacsname} with Lisp:
3243 (setenv "xy" "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}")
3246 The reduced typing: @kbd{C-x C-f $xy @key{RET}}.
3248 @strong{Note} that file name cannot be edited here because the
3249 environment variables are not expanded during editing in the
3252 @item Define own keys:
3254 Redefine another key sequence in @value{emacsname} for @kbd{C-x C-f}:
3258 [(control x) (control y)]
3264 "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))))
3267 Simply typing @kbd{C-x C-y} would prepare minibuffer editing of file
3270 See @uref{http://www.emacswiki.org/cgi-bin/wiki/TrampMode, the Emacs
3271 Wiki} for a more comprehensive example.
3274 Define own abbreviation (1):
3276 Abbreviation list expansion can be used to reduce typing long file names:
3280 'directory-abbrev-alist
3281 '("^/xy" . "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))
3284 The reduced typing: @kbd{C-x C-f /xy @key{RET}}.
3286 @strong{Note} that file name cannot be edited here because the
3287 environment variables are not expanded during editing in the
3291 Define own abbreviation (2):
3293 The @code{abbrev-mode} gives additional flexibility for editing in the
3297 (define-abbrev-table 'my-tramp-abbrev-table
3298 '(("xy" "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}")))
3301 'minibuffer-setup-hook
3304 (setq local-abbrev-table my-tramp-abbrev-table)))
3306 (defadvice minibuffer-complete
3307 (before my-minibuffer-complete activate)
3310 ;; If you use partial-completion-mode
3311 (defadvice PC-do-completion
3312 (before my-PC-do-completion activate)
3316 The reduced typing: @kbd{C-x C-f xy @key{TAB}}.
3318 The minibuffer expands for further editing.
3320 @item Use bookmarks:
3322 Use bookmarks to save Tramp file names.
3324 @pxref{Bookmarks, , , @value{emacsdir}}.
3327 Upon visiting a location with @value{tramp}, save it as a bookmark with
3329 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{set}}.
3332 @kbd{@key{menu-bar} @key{view} @key{bookmarks} @key{set}}.
3335 To revisit that bookmark:
3337 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{jump}}.
3340 @kbd{@key{menu-bar} @key{view} @key{bookmarks} @key{jump}}.
3343 @item Use recent files:
3351 remembers visited places.
3354 @pxref{File Conveniences, , , @value{emacsdir}}.
3357 @pxref{recent-files, , , edit-utils}.
3361 Keep remote file names in the recent list without have to check for
3362 their accessibility through remote access:
3369 (recent-files-initialize)
3373 (when (file-remote-p (buffer-file-name))
3374 (recent-files-make-permanent)))
3379 Reaching recently opened files:
3381 @kbd{@key{menu-bar} @key{file} @key{Open Recent}}.
3384 @kbd{@key{menu-bar} @key{Recent Files}}.
3388 @item Use filecache:
3390 Since @file{filecache} remembers visited places, add the remote
3391 directory to the cache:
3394 (eval-after-load "filecache"
3395 '(file-cache-add-directory
3396 "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))
3399 Then use directory completion in the minibuffer with @kbd{C-x C-f
3406 @file{bbdb} has a built-in feature for @value{ftppackagename} files,
3407 which also works for @value{tramp} file names.
3409 @pxref{bbdb-ftp, Storing FTP sites in the BBDB, , bbdb}.
3412 Load @file{bbdb} in @value{emacs}:
3419 Create a BBDB entry with @kbd{M-x bbdb-create-ftp-site}. Then specify
3420 a method and user name where needed. Examples:
3423 @kbd{M-x bbdb-create-ftp-site @key{RET}}
3424 @b{Ftp Site:} news.my.domain @key{RET}
3425 @b{Ftp Directory:} /opt/news/etc/ @key{RET}
3426 @b{Ftp Username:} ssh@value{postfixhop}news @key{RET}
3427 @b{Company:} @key{RET}
3428 @b{Additional Comments:} @key{RET}
3431 In BBDB buffer, access an entry by pressing the key @key{F}.
3436 Thanks to @value{tramp} users for contributing to these recipes.
3439 Why saved multi-hop file names do not work in a new @value{emacsname}
3442 When saving ad-hoc multi-hop @value{tramp} file names (@pxref{Ad-hoc
3443 multi-hops}) via bookmarks, recent files,
3447 or another package, use the full ad-hoc file name including all hops,
3449 @file{@trampfn{ssh,bird@@bastion|ssh@value{postfixhop}news.my.domain,/opt/news/etc}}.
3451 Alternatively, when saving abbreviated multi-hop file names
3452 @file{@trampfn{ssh,news@@news.my.domain,/opt/news/etc}}, the custom
3453 option @code{tramp-save-ad-hoc-proxies} must be set non-@code{nil}
3459 How to connect to a remote @value{emacsname} session using @value{tramp}?
3461 Configure Emacs Client
3463 (@pxref{Emacs Server, , , @value{emacsdir}}).
3466 Then on the remote host, start the Emacs Server:
3470 (setq server-host (system-name)
3475 If @code{(system-name)} of the remote host cannot be resolved on the
3476 local host, use IP address instead.
3478 Copy from the remote host the resulting file
3479 @file{~/.emacs.d/server/server} to the local host, to the same
3482 Then start Emacs Client from the command line:
3485 emacsclient @trampfn{ssh,user@@host,/file/to/edit}
3488 @code{user} and @code{host} refer to the local host.
3490 To make Emacs Client an editor for other programs, use a wrapper
3491 script @file{emacsclient.sh}:
3495 emacsclient @trampfn{ssh,$(whoami)@@$(hostname --fqdn),$1}
3498 Then change the environment variable @env{EDITOR} to point to the
3502 export EDITOR=/path/to/emacsclient.sh
3508 How to disable other packages from calling @value{tramp}?
3510 There are packages that call @value{tramp} without the user ever
3511 entering a remote file name. Even without applying a remote file
3512 syntax, some packages enable @value{tramp} on their own. How can users
3513 disable such features.
3519 Disable @value{tramp} file name completion:
3522 (custom-set-variables
3523 '(ido-enable-tramp-completion nil))
3529 Disable remote directory tracking mode:
3532 (rlogin-directory-tracking-mode -1)
3538 How to disable @value{tramp}?
3543 To keep @value{ftppackagename} as default the remote files access
3544 package, set this in @file{.emacs}:
3547 (setq tramp-default-method "ftp")
3554 @value{tramp} (and @value{ftppackagename}),
3559 set @code{tramp-mode} to @code{nil} in @file{.emacs}.
3562 (setq tramp-mode nil)
3566 To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp}.
3568 Unloading @value{tramp} resets @value{ftppackagename} plugins also.
3574 @c For the developer
3575 @node Files directories and localnames
3576 @chapter How file names, directories and localnames are mangled and managed.
3579 * Localname deconstruction:: Splitting a localname into its component parts.
3581 * External packages:: Integrating with external Lisp packages.
3586 @node Localname deconstruction
3587 @section Splitting a localname into its component parts
3589 @value{tramp} package redefines lisp functions
3590 @code{file-name-directory} and @code{file-name-nondirectory} to
3591 accommodate the unique file naming syntax that @value{tramp} requires.
3593 The replacements dissect the file name, use the original handler for
3594 the localname, take that result, and then re-build the @value{tramp}
3595 file name. By relying on the original handlers for localnames,
3596 @value{tramp} benefits from platform specific hacks to the original
3601 @node External packages
3602 @section Integrating with external Lisp packages
3603 @subsection File name completion.
3605 For name completions in the minibuffer, @value{tramp} depends on the
3606 last input character to decide whether to look for method name
3607 completion or host name completion. For example, @kbd{C-x C-f
3608 @value{prefix}ssh@value{postfixhop} @key{TAB}} is not entirely clear
3609 if @option{ssh} is a method or a host name. But if the last input
3610 character was either @key{TAB}, @key{SPACE} or @kbd{?}, then
3611 @value{tramp} favors file name completion over host name completion.
3613 What about external packages using other characters to trigger file
3614 name completions? They must somehow signal this to @value{tramp}. Use
3615 the variable @code{non-essential} temporarily and bind it to
3616 non-@code{nil} value.
3619 (let ((non-essential t))
3624 @subsection File attributes cache.
3626 Keeping a local cache of remote file attributes in sync with the
3627 remote host is a time-consuming operation. Flushing and re-querying
3628 these attributes can tax @value{tramp} to a grinding halt on busy
3631 To get around these types of slow-downs in @value{tramp}'s
3632 responsiveness, set the @code{process-file-side-effects} to @code{nil}
3633 to stop @value{tramp} from flushing the cache. This is helpful in
3634 situations where callers to @code{process-file} know there are no file
3635 attribute changes. The let-bind form to accomplish this:
3638 (let (process-file-side-effects)
3642 For asynchronous processes, @value{tramp} uses a process sentinel to
3643 flush file attributes cache. When callers to @code{start-file-process}
3644 know beforehand no file attribute changes are expected, then the
3645 process sentinel should be set to the default state. In cases where
3646 the caller defines its own process sentinel, @value{tramp}'s process
3647 sentinel is overwritten. The caller can still flush the file
3648 attributes cache in its process sentinel with this code:
3651 (unless (memq (process-status proc) '(run open))
3652 (dired-uncache remote-directory))
3655 Since @value{tramp} traverses subdirectories starting with the
3656 root-directory, it is most likely sufficient to make the
3657 @code{default-directory} of the process buffer as the root directory.
3661 @node Traces and Profiles
3662 @chapter How to Customize Traces
3664 @value{tramp} messages are raised with verbosity levels ranging from 0
3665 to 10. @value{tramp} does not display all messages; only those with a
3666 verbosity level less than or equal to @code{tramp-verbose}.
3668 The verbosity levels are
3670 @w{ 0} silent (no @value{tramp} messages at all)
3671 @*@indent @w{ 1} errors
3672 @*@indent @w{ 2} warnings
3673 @*@indent @w{ 3} connection to remote hosts (default verbosity)
3674 @*@indent @w{ 4} activities
3675 @*@indent @w{ 5} internal
3676 @*@indent @w{ 6} sent and received strings
3677 @*@indent @w{ 7} file caching
3678 @*@indent @w{ 8} connection properties
3679 @*@indent @w{ 9} test commands
3680 @*@indent @w{10} traces (huge)
3682 With @code{tramp-verbose} greater than or equal to 4, messages are
3683 also written to a @value{tramp} debug buffer. Such debug buffers are
3684 essential to bug and problem analyses. For @value{tramp} bug reports,
3685 set the @code{tramp-verbose} level to 6 (@pxref{Bug Reports}).
3687 The debug buffer is in
3689 @ref{Outline Mode, , , @value{emacsdir}}.
3694 In this buffer, messages can be filtered by their level. To see
3695 messages up to verbosity level 5, enter @kbd{C-u 6 C-c C-q}.
3697 Other navigation keys are described in
3698 @ref{Outline Visibility, , , @value{emacsdir}}.
3701 @value{tramp} handles errors internally. But to get a Lisp backtrace,
3702 both the error and the signal have to be set as follows:
3705 (setq debug-on-error t
3709 To enable stepping through @value{tramp} function call traces, they
3710 have to be specifically enabled as shown in this code:
3714 (dolist (elt (all-completions "tramp-" obarray 'functionp))
3715 (trace-function-background (intern elt)))
3716 (untrace-function 'tramp-read-passwd)
3717 (untrace-function 'tramp-gw-basic-authentication)
3720 The buffer @file{*trace-output*} contains the output from the function
3721 call traces. Disable @code{tramp-read-passwd} and
3722 @code{tramp-gw-basic-authentication} to stop password strings from
3723 being written to @file{*trace-output*}.
3727 @chapter Debatable Issues and What Was Decided
3730 @item The uuencode method does not always work.
3732 @command{uudecode} on some systems cannot write to stdout, but
3733 @value{tramp} depends on encoding and decoding programs to be able to
3734 read from stdin and write to stdout.
3736 We can find ways to circumvent @command{uudecode}'s ability to write
3737 to stdout, such as writing to a temporary file and then piping that to
3740 But I have decided not to implement workarounds as they are too
3741 fragile to work reliably. Some on systems, @value{tramp} will not have
3744 @item The @value{tramp} file name syntax differs between Emacs and XEmacs.
3746 The Emacs maintainers wish to use a unified file name syntax for
3747 Ange-FTP and @value{tramp} so that users don't have to learn yet
3748 another syntax though it is okay to learn new extensions.
3750 For the XEmacs maintainers, the disruption from a unified file name
3751 syntax are not worth the gains. Firstly, the XEmacs package system
3752 relies on EFS for downloading new packages and therefore is already
3753 installed. On the other hand, @value{tramp} is not installed by
3754 default in XEmacs. Unifying will require @value{tramp} installed from
3758 @strong{Note:} To make the syntax similar to @value{ftppackagename},
3759 make this change to the init file:
3762 (setq tramp-unified-filenames t)
3766 To disable auto loading @value{emacsname} @value{tramp} package, set
3768 @file{@dots{}/xemacs-packages/lisp/tramp/auto-autoloads.el*} to
3771 When using unified file names, @value{emacsname} download sites are
3772 added to @code{tramp-default-method-alist} with default method of
3773 @option{ftp} @xref{Default Method} for proper working of the
3774 @value{emacsname} package system.
3776 The syntax for unified file names is described in the @value{tramp} manual
3777 for @value{emacsothername}.
3782 @node GNU Free Documentation License
3783 @appendix GNU Free Documentation License
3784 @include doclicense.texi
3787 @node Function Index
3788 @unnumbered Function Index
3792 @node Variable Index
3793 @unnumbered Variable Index
3798 @unnumbered Concept Index
3805 @c * Say something about the .login and .profile files of the remote
3807 @c * Explain how tramp.el works in principle: open a shell on a remote
3808 @c host and then send commands to it.
3809 @c * Consistent small or capitalized words especially in menus.
3810 @c * Make a unique declaration of @trampfn.