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 @include trampver.texi
17 @c Macro for formatting a file name according to the respective
18 @c syntax. Macro arguments should not have any leading or trailing
19 @c whitespace. Not very elegant, but I don't know it better.
21 @macro trampfn {method, userhost, localname}
23 \method\@value{postfixhop}@c
24 \userhost\@value{postfix}\localname\
27 @c Similar, but without a method prefix.
29 @macro trampf {userhost, localname}
31 \userhost\@value{postfix}\localname\
35 Copyright @copyright{} 1999--2016 Free Software Foundation, Inc.
38 Permission is granted to copy, distribute and/or modify this document
39 under the terms of the GNU Free Documentation License, Version 1.3 or
40 any later version published by the Free Software Foundation; with no
41 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
42 and with the Back-Cover Texts as in (a) below. A copy of the license
43 is included in the section entitled ``GNU Free Documentation License''.
45 (a) The FSF's Back-Cover Text is: ``You have the freedom to
46 copy and modify this GNU manual.''
50 @c Entries for @command{install-info} to use
51 @dircategory Emacs network features
53 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
54 Emacs remote file access via ssh and scp.
58 @title @value{tramp} version @value{trampver} User Manual
59 @author by Daniel Pittman
60 @author based on documentation by Kai Großjohann
66 @node Top, Overview, (dir), (dir)
67 @top @value{tramp} version @value{trampver} User Manual
69 This file documents @value{tramp} version @value{trampver}, a remote file
70 editing package for Emacs.
72 @value{tramp} stands for ``Transparent Remote (file) Access, Multiple
73 Protocol''. This package provides remote file editing, similar to
76 The difference is that Ange FTP uses FTP to transfer files between the
77 local and the remote host, whereas @value{tramp} uses a combination of
78 @command{rsh} and @command{rcp} or other work-alike programs, such as
79 @command{ssh}/@command{scp}.
81 You can find the latest version of this document on the web at
82 @uref{http://www.gnu.org/software/tramp/}.
85 The latest release of @value{tramp} is available for
86 @uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
87 @ref{Obtaining Tramp} for more details, including the Git server
90 @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
91 Savannah Project Page}.
94 There is a mailing list for @value{tramp}, available at
95 @email{tramp-devel@@gnu.org}, and archived at
96 @uref{http://lists.gnu.org/archive/html/tramp-devel/, the
97 @value{tramp} Mail Archive}.
103 * Overview:: What @value{tramp} can and cannot do.
107 * Obtaining Tramp:: How to obtain @value{tramp}.
108 * History:: History of @value{tramp}.
109 @ifset installchapter
110 * Installation:: Installing @value{tramp} with your Emacs.
112 * Configuration:: Configuring @value{tramp} for use.
113 * Usage:: An overview of the operation of @value{tramp}.
114 * Bug Reports:: Reporting Bugs and Problems.
115 * Frequently Asked Questions:: Questions and answers from the mailing list.
119 * Files directories and localnames::
120 How file names, directories and localnames
121 are mangled and managed.
122 * Traces and Profiles:: How to Customize Traces.
124 * GNU Free Documentation License:: The license for this documentation.
125 * Function Index:: @value{tramp} functions.
126 * Variable Index:: User options and variables.
127 * Concept Index:: An item for each concept.
130 --- The Detailed Node Listing ---
132 @ifset installchapter
133 Installing @value{tramp} with your Emacs
135 * Installation parameters:: Parameters in order to control installation.
136 * Load paths:: How to plug-in @value{tramp} into your environment.
140 Configuring @value{tramp} for use
142 * Connection types:: Types of connections to remote hosts.
143 * Inline methods:: Inline methods.
144 * External methods:: External methods.
145 * GVFS based methods:: GVFS based external methods.
146 * Gateway methods:: Gateway methods.
147 * Default Method:: Selecting a default method.
148 * Default User:: Selecting a default user.
149 * Default Host:: Selecting a default host.
150 * Multi-hops:: Connecting to a remote host using multiple hops.
151 * Customizing Methods:: Using Non-Standard Methods.
152 * Customizing Completion:: Selecting config files for user/host name completion.
153 * Password handling:: Reusing passwords for several connections.
154 * Connection caching:: Reusing connection related information.
155 * Predefined connection information::
156 Setting own connection related information.
157 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
158 * Remote shell setup:: Remote shell setup hints.
159 * Android shell setup:: Android shell setup hints.
160 * Auto-save and Backup:: Auto-save and Backup.
161 * Windows setup hints:: Issues with Cygwin ssh.
165 * File name Syntax:: @value{tramp} file name conventions.
166 * File name completion:: File name completion.
167 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
168 * Remote processes:: Integration with other Emacs packages.
169 * Cleanup remote connections:: Cleanup remote connections.
171 How file names, directories and localnames are mangled and managed
173 * Localname deconstruction:: Breaking a localname into its components.
174 * External packages:: Integration with external Lisp packages.
181 @chapter An overview of @value{tramp}
184 @value{tramp} is for transparently accessing remote files from within
185 Emacs. @value{tramp} enables an easy, convenient, and consistent
186 interface to remote files as if they are local files. @value{tramp}'s
187 transparency extends to editing, version control, and @code{dired}.
189 @value{tramp} can access remote hosts using any number of access
190 methods, such as @command{rsh}, @command{rlogin}, @command{telnet},
191 and related programs. If these programs can successfully pass
192 @acronym{ASCII]} characters, @value{tramp} can use them.
193 @value{tramp} does not require or mandate 8-bit clean connections.
195 @value{tramp}'s most common access method is through @command{ssh}, a
196 more secure alternative to @command{ftp} and other older access
199 @value{tramp} on Windows operating systems is integrated with the
200 PuTTY package, and uses the @command{plink} program.
202 @value{tramp} mostly operates transparently in the background using
203 the connection programs. As long as these programs enable remote login
204 and can use the terminal, @value{tramp} can adapt them for seamless
205 and transparent access.
207 @value{tramp} temporarily transfers a remote file's contents to the
208 local host editing and related operations. @value{tramp} can also
209 transfer files between hosts using standard Emacs interfaces, a
210 benefit of direct integration of @value{tramp} in Emacs.
212 @value{tramp} can transfer files using any number of available host
213 programs for remote files, such as @command{rcp}, @command{scp},
214 @command{rsync} or (under Windows) @command{pscp}. @value{tramp}
215 provides easy ways to specify these programs and customize them to
216 specific files, hosts, or access methods.
218 For faster small-size file transfers, @value{tramp} supports encoded
219 transfers directly through the shell using @command{mimencode} or
220 @command{uuencode} provided such tools are available on the remote
224 @subsubheading @value{tramp} behind the scenes
225 @cindex behind the scenes
226 @cindex details of operation
229 Accessing a remote file through @value{tramp} entails a series of
230 actions, many of which are transparent to the user. Yet some actions
231 may require user response (such as entering passwords or completing
232 file names). One typical scenario, opening a file on a remote host, is
233 presented here to illustrate the steps involved:
235 @kbd{C-x C-f} to initiate find-file, enter part of the @value{tramp}
236 file name, then hit @kbd{@key{TAB}} for completion. If this is the
237 first time connection to that host, here's what happens:
241 @value{tramp} invokes @samp{telnet @var{host}} or @samp{rsh @var{host}
242 -l @var{user}} and establishes an external process to connect to the
243 remote host. @value{tramp} communicates with the process through an
244 Emacs buffer, which also shows output from the remote host.
247 The remote host may prompt for a login name (for @command{telnet}, for
248 example) in the buffer. If on the other hand, the login name was
249 included in the file name portion, @value{tramp} sends the login name
250 followed by a newline.
253 The remote host may then prompt for a password or pass phrase (for
254 @command{rsh} or for @command{telnet}). @value{tramp} displays the
255 password prompt in the minibuffer. @value{tramp} then sends whatever
256 is entered to the remote host, followed by a newline.
259 @value{tramp} now waits for either the shell prompt or a failed login
262 If @value{tramp} does not receive any messages within a timeout period
263 (a minute, for example), then @value{tramp} responds with an error
264 message about not finding the remote shell prompt. If any messages
265 from the remote host, @value{tramp} displays them in the buffer.
267 For any @samp{login failed} message from the remote host,
268 @value{tramp} aborts the login attempt, and repeats the login steps
272 Upon successful login and @value{tramp} recognizes the shell prompt
273 from the remote host, @value{tramp} prepares the shell environment by
274 turning off echoing, setting shell prompt, and other housekeeping
277 @strong{Note} that for the remote shell, @value{tramp} invokes
278 @command{/bin/sh}. The remote host must recognize @samp{exec /bin/sh}
279 and execute the appropriate shell. This shell must support Bourne
283 @value{tramp} executes @command{cd} and @command{ls} commands to find
284 which files exist on the remote host. @value{tramp} sometimes uses
285 @command{echo} with globbing. @value{tramp} checks if a file or
286 directory is writable with @command{test}. After each command,
287 @value{tramp} parses the output from the remote host for completing
291 After remote file name completion, @value{tramp} transfers the file
292 contents from the remote host.
294 For inline transfers, @value{tramp} sends a command, such as
295 @samp{mimencode -b /path/to/remote/file}, waits until the output has
296 accumulated in the buffer, decodes that output to produce the file's
299 For external transfers, @value{tramp} sends a command as follows:
301 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
303 @value{tramp} reads the local temporary file @file{/tmp/tramp.4711}
304 into a buffer, and then deletes the temporary file.
307 Edit, modify, change the buffer contents as normal, and then save the
308 buffer wth @kbd{C-x C-s}.
311 @value{tramp} transfers the buffer contents to the remote host in
312 a reverse of the process using the appropriate inline or external
316 I hope this has provided you with a basic overview of what happens
317 behind the scenes when you open a file with @value{tramp}.
321 @node Obtaining Tramp
322 @chapter Obtaining @value{tramp}
323 @cindex obtaining Tramp
325 @value{tramp} is included as part of Emacs (since Emacs version 22.1).
327 @value{tramp} is also freely packaged for download on the Internet at
328 @uref{ftp://ftp.gnu.org/gnu/tramp/}.
330 @value{tramp} development versions are available on Git servers.
331 Development versions contain new and incomplete features.
333 One way to obtain from Git server is to visit the Savannah project
334 page at the following URL and then clicking on the Git link in the
335 navigation bar at the top.
338 @uref{http://savannah.gnu.org/projects/tramp/}
341 Another way is to follow the terminal session below:
345 ] @strong{cd ~/emacs}
346 ] @strong{git clone git://git.savannah.gnu.org/tramp.git}
351 From behind a firewall:
355 ] @strong{git config --global http.proxy http://user:pwd@@proxy.server.com:8080}
356 ] @strong{git clone http://git.savannah.gnu.org/r/tramp.git}
364 ] @strong{git clone login@@git.sv.gnu.org:/srv/git/tramp.git}
368 After one of the above commands, @file{~/emacs/tramp} will
369 containing the latest version of @value{tramp}.
372 To fetch updates from the repository, use git pull:
376 ] @strong{cd ~/emacs/tramp}
382 Run @command{autoconf} as follows to generate an up-to-date
383 @file{configure} script:
387 ] @strong{cd ~/emacs/tramp}
394 @chapter History of @value{tramp}
396 @cindex development history
398 @value{tramp} development started at the end of November 1998 as
399 @file{rssh.el}. It provided only one method of access. It used
400 @command{ssh} for login and @command{scp} to transfer file contents.
401 The name was changed to @file{rcp.el} before it got its preset name
402 @value{tramp}. New methods of remote access were added, so was support
405 April 2000 was the first time when multi-hop methods were added. In
406 July 2002, @value{tramp} unified file names with Ange-FTP@. In July
407 2004, proxy hosts replaced multi-hop methods. Running commands on
408 remote hosts was introduced in December 2005. Support for gateways
409 since April 2007. GVFS integration started in February 2009. Remote
410 commands on Windows hosts since September 2011. Ad-hoc multi-hop
411 methods (with a changed syntax) re-enabled in November 2011. In
412 November 2012, added Juergen Hoetzel's @file{tramp-adb.el}.
414 XEmacs support has been stopped in January 2016.
416 @c Installation chapter is necessary only in case of standalone
417 @c installation. Text taken from trampinst.texi.
418 @ifset installchapter
419 @include trampinst.texi
424 @chapter Configuring @value{tramp}
425 @cindex configuration
426 @cindex default configuration
428 @value{tramp} is initially configured to use the @command{scp} program
429 to connect to the remote host. Just type @kbd{C-x C-f} and then enter
430 file name @file{@trampf{user@@host,/path/to.file}}. For details,
431 @xref{Default Method}, @xref{Default User}, @xref{Default Host}.
433 For problems related to the behavior of the remote shell, @xref{Remote
436 For changing the connection type and file access method from the
437 defaults to one of several other options, @xref{Connection types}.
439 @strong{Note} that some user options described in these examples are
440 not auto loaded by Emacs. All examples require @value{tramp} is
441 installed and loaded:
445 (custom-set-variables
446 '(tramp-verbose 6 nil (tramp) "Enable remote command traces"))
452 * Connection types:: Types of connections to remote hosts.
453 * Inline methods:: Inline methods.
454 * External methods:: External methods.
455 * GVFS based methods:: GVFS based external methods.
456 * Gateway methods:: Gateway methods.
457 * Default Method:: Selecting a default method.
458 Here we also try to help those who
459 don't have the foggiest which method
461 * Default User:: Selecting a default user.
462 * Default Host:: Selecting a default host.
463 * Multi-hops:: Connecting to a remote host using multiple hops.
464 * Customizing Methods:: Using Non-Standard Methods.
465 * Customizing Completion:: Selecting config files for user/host name completion.
466 * Password handling:: Reusing passwords for several connections.
467 * Connection caching:: Reusing connection related information.
468 * Predefined connection information::
469 Setting own connection related information.
470 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
471 * Remote shell setup:: Remote shell setup hints.
472 * Android shell setup:: Android shell setup hints.
473 * Auto-save and Backup:: Auto-save and Backup.
474 * Windows setup hints:: Issues with Cygwin ssh.
478 @node Connection types
479 @section Types of connections to remote hosts
480 @cindex connection types, overview
482 @dfn{Inline method} and @dfn{external method} are the two basic types
483 of access methods. While they both use the same remote shell access
484 programs, such as @command{rsh}, @command{ssh}, or @command{telnet},
485 they differ in the file access methods. Choosing the right method
486 becomes important for editing files, transferring large files, or
487 operating on a large number of files.
489 The performance of the external methods is generally better than that
490 of the inline methods, at least for large files. This is caused by
491 the need to encode and decode the data when transferring inline.
493 The one exception to this rule are the @option{scp}-based access
494 methods. While these methods do see better performance when actually
495 transferring files, the overhead of the cryptographic negotiation at
496 startup may drown out the improvement in file transfer times.
498 External methods should be configured such a way that they don't
499 require a password (with @command{ssh-agent}, or such alike). Modern
500 @command{scp} implementations offer options to reuse existing
501 @command{ssh} connections, which will be enabled by default if
502 available. If it isn't possible, you should consider @ref{Password
503 handling}, otherwise you will be prompted for a password every copy
508 @section Inline methods
509 @cindex inline methods
510 @cindex methods, inline
512 Inline methods use the same login connection to transfer file
513 contents. Inline methods are quick and easy for small files. They
514 depend on the availability of suitable encoding and decoding programs
515 on the remote host. For local source and destination, @value{tramp}
516 may use built-in equivalents of such programs in Emacs.
518 Inline methods can work in situations where an external transfer
519 program is unavailable. Inline methods also work when transferring
520 files between different @emph{user identities} on the same host.
524 @cindex base-64 encoding
526 @value{tramp} checks the remote host for the availability and
527 usability of @command{mimencode} (part of the @command{metamail}
528 package) or @command{uuencode}. @value{tramp} uses the first reliable
529 command it finds. @value{tramp}'s search path can be customized, see
530 @ref{Remote programs}.
532 In case both @command{mimencode} and @command{uuencode} are
533 unavailable, @value{tramp} first transfers a small Perl program to the
534 remote host, and then tries that program for encoding and decoding.
536 To increase transfer speeds for large text files, use compression
537 before encoding. The user option
538 @option{tramp-inline-compress-start-size} specifies the file size for
546 @command{rsh} is an option for connecting to hosts within local
547 networks since @command{rsh} is not as secure as other methods.
553 @command{ssh} is a more secure option than others to connect to a
556 @command{ssh} can also take extra parameters as port numbers. For
557 example, a host on port 42 is specified as @file{host#42} (the real
558 host name, a hash sign, then a port number). It is the same as passing
559 @samp{-p 42} to the @command{ssh} command.
561 @item @option{telnet}
562 @cindex method telnet
563 @cindex telnet method
565 Connecting to a remote host with @command{telnet} is as insecure
566 as the @option{rsh} method.
572 Instead of connecting to a remote host, @command{su} program allows
573 editing as another user. The host can be either @samp{localhost} or
574 the host returned by the function @command{(system-name)}. See
575 @ref{Multi-hops} for an exception to this behavior.
581 Similar to @option{su} method, @option{sudo} uses @command{sudo}.
582 @command{sudo} must have sufficient rights to start a shell.
588 This method is used on OpenBSD like the @command{sudo} command.
594 The @command{sg} program allows editing as different group. The host
595 can be either @samp{localhost} or the host returned by the function
596 @command{(system-name)}. The user name must be specified, but it
597 denotes a group name. See @ref{Multi-hops} for an exception to this
604 Works like @option{ssh} but without the extra authentication prompts.
605 @option{sshx} uses @samp{ssh -t -t @var{host} -l @var{user} /bin/sh}
606 to open a connection with a ``standard'' login shell.
608 @strong{Note} that @option{sshx} does not bypass authentication
609 questions. For example, if the host key of the remote host is not
610 known, @option{sshx} will still ask ``Are you sure you want to
611 continue connecting?''. @value{tramp} cannot handle such questions.
612 Connections will have to be setup where logins can proceed without
615 @option{sshx} is useful for Windows users when @command{ssh} triggers
616 an error about allocating a pseudo tty. This happens due to missing
617 shell prompts that confuses @value{tramp}.
619 @option{sshx} supports the @samp{-p} argument.
621 @item @option{krlogin}
622 @cindex method krlogin
623 @cindex krlogin method
624 @cindex Kerberos (with krlogin method)
626 This method is also similar to @option{ssh}. It uses the
627 @command{krlogin -x} command only for remote host login.
632 @cindex Kerberos (with ksu method)
634 This is another method from the Kerberos suite. It behaves like @option{su}.
640 @option{plink} method is for Windows users with the PuTTY
641 implementation of SSH@. It uses @samp{plink -ssh} to log in to the
644 Check the @samp{Share SSH connections if possible} control for that
647 @option{plink} method supports the @samp{-P} argument.
649 @item @option{plinkx}
650 @cindex method plinkx
651 @cindex plinkx method
653 Another method using PuTTY on Windows with session names instead of
654 host names. @option{plinkx} calls @samp{plink -load @var{session} -t}.
655 User names and port numbers must be defined in the session.
657 Check the @samp{Share SSH connections if possible} control for that
663 @node External methods
664 @section External methods
665 @cindex methods, external
666 @cindex external methods
668 External methods operate over multiple channels, using the remote
669 shell connection for some actions while delegating file transfers to
670 an external transfer program.
672 External methods save on the overhead of encoding and decoding of
675 Since external methods have the overhead of opening a new channel,
676 files smaller than @var{tramp-copy-size-limit} still use inline
683 @cindex rcp (with rcp method)
684 @cindex rsh (with rcp method)
686 This method uses the @command{rsh} and @command{rcp} commands to
687 connect to the remote host and transfer files. This is the fastest
688 access method available.
690 The alternative method @option{remcp} uses the @command{remsh} and
691 @command{rcp} commands.
696 @cindex scp (with scp method)
697 @cindex ssh (with scp method)
699 Using a combination of @command{ssh} to connect and @command{scp} to
700 transfer is the most secure. While the performance is good, it is
701 slower than the inline methods for smaller files. Though there is no
702 overhead of encoding and decoding of the inline methods,
703 @command{scp}'s cryptographic handshake negates those speed gains.
705 @option{ssh}-based methods support @samp{-p} feature for specifying
706 port numbers. For example, @file{host#42} passes @samp{-p 42} in the
707 argument list to @command{ssh}, and @samp{-P 42} in the argument list
713 @cindex rsync (with rsync method)
714 @cindex ssh (with rsync method)
716 @command{ssh} command to connect in combination with @command{rsync}
717 command to transfer is similar to the @option{scp} method.
719 @command{rsync} performs much better than @command{scp} when
720 transferring files that exist on both hosts. However, this advantage
721 is lost if the file exists only on one side of the connection.
723 This method supports the @samp{-p} argument.
728 @cindex scp (with scpx method)
729 @cindex ssh (with scpx method)
731 @option{scpx} is useful to avoid login shell questions. It is similar
732 in performance to @option{scp}. @option{scpx} uses @samp{ssh -t -t
733 @var{host} -l @var{user} /bin/sh} to open a connection.
735 @option{scpx} is useful for Windows users when @command{ssh} triggers
736 an error about allocating a pseudo tty. This happens due to missing
737 shell prompts that confuses @value{tramp}.
739 This method supports the @samp{-p} argument.
745 @cindex pscp (with pscp method)
746 @cindex plink (with pscp method)
747 @cindex PuTTY (with pscp method)
750 @cindex pscp (with psftp method)
751 @cindex plink (with psftp method)
752 @cindex PuTTY (with psftp method)
754 These methods are similar to @option{scp} or @option{sftp}, but they
755 use the @command{plink} command to connect to the remote host, and
756 they use @command{pscp} or @command{psftp} for transferring the files.
757 These programs are part of PuTTY, an SSH implementation for Windows.
759 Check the @samp{Share SSH connections if possible} control for that
762 These methods support the @samp{-P} argument.
767 @cindex fsh (with fcp method)
768 @cindex fcp (with fcp method)
770 This method is similar to @option{scp}, but uses @command{fsh} to
771 connect and @command{fcp} to transfer files. @command{fsh/fcp}, a
772 front-end for @command{ssh}, reuse @command{ssh} session by
773 submitting several commands. This avoids the startup overhead due to
774 @command{scp}'s secure connection. Inline methods have similar
777 The command used for this connection is: @samp{fsh @var{host} -l
778 @var{user} /bin/sh -i}
783 @option{fsh} has no inline method since the multiplexing it offers is
784 not useful for @value{tramp}. @command{fsh} connects to remote host
785 and @value{tramp} keeps that one connection open.
790 @cindex nc (with nc method)
791 @cindex telnet (with nc method)
793 Using @command{telnet} to connect and @command{nc} to transfer files
794 is sometimes the only combination suitable for accessing routers or
795 NAS hosts. These dumb devices have severely restricted local shells,
796 such as the @command{busybox} and do not host any other encode or
803 When @value{tramp} uses @option{ftp}, it forwards requests to whatever
804 ftp program is specified by Ange FTP. This external program must be
805 capable of servicing requests from @value{tramp}.
811 This non-native @value{tramp} method connects via the Server Message
812 Block (SMB) networking protocol to hosts running file servers that are
813 typically based on @url{https://www.samba.org/,,Samba} or MS Windows.
815 Using @command{smbclient} requires a few tweaks when working with
818 The first directory in the localname must be a share name on the
821 Since SMB shares end in the @code{$} character, @value{tramp} must use
822 @code{$$} when specifying those shares to avoid environment variable
825 When @value{tramp} is not specific about the share name or uses the
826 generic remote directory @file{/}, @command{smbclient} returns all
829 Since SMB authentication is based on each SMB share, @value{tramp}
830 prompts for a password even when accessing a different share on the
831 same SMB host. This prompting can be suppressed by @ref{Password
834 To accommodate user name/domain name syntax required by MS Windows
835 authorization, @value{tramp} provides for an extended syntax in
836 @code{user%domain} format (where user is username, @code{%} is the
837 percent symbol, and domain is the windows domain name). An example:
840 @trampfn{smb,daniel%BIZARRE@@melancholia,/daniel$$/.emacs}
843 where user @code{daniel} connects as a domain user to the SMB host
844 @code{melancholia} in the windows domain @code{BIZARRE} to edit
845 @file{.emacs} located in the home directory (share @code{daniel$}).
847 Alternatively, for local WINS users (as opposed to domain users),
848 substitute the domain name with the name of the local host in
849 UPPERCASE as shown here:
852 @trampfn{smb,daniel%MELANCHOLIA@@melancholia,/daniel$$/.emacs}
855 where user @code{daniel} connects as local user to the SMB host
856 @code{melancholia} in the local domain @code{MELANCHOLIA} to edit
857 @file{.emacs} located in the home directory (share @code{daniel$}).
859 The domain name and user name are optional for @command{smbclient}
860 authentication. When user name is not specified, @command{smbclient}
861 uses the anonymous user (without prompting for password). This
862 behavior is unlike other @value{tramp} methods, where local user name
865 The @option{smb} method is unavailable if Emacs is run under a local
866 user authentication context in MS Windows. However such users can
867 still access remote files using UNC file names instead of @value{tramp}:
870 //melancholia/daniel$$/.emacs
873 UNC file name specification does not allow the specification of a
874 different user name for authentication like the @command{smbclient}
882 This method uses Android Debug Bridge program for accessing Android
883 devices. The Android Debug Bridge must be installed locally for
884 @value{tramp} to work. Some GNU/Linux distributions provide Android
885 Debug Bridge as an installation package. Alternatively, the program
886 is installed as part of the Android SDK@. @value{tramp} finds the
887 @command{adb} program either via the @env{PATH} environment variable
888 or the absolute path set in the user option @option{tramp-adb-program}.
890 @value{tramp} connects to Android devices with @option{adb} only when
891 the user option @option{tramp-adb-connect-if-not-connected} is not
892 @code{nil}. Otherwise, the connection must be established outside
895 @value{tramp} does not require a host name part of the remote file
896 name when a single Android device is connected to @command{adb}.
897 @value{tramp} instead uses @file{@trampfn{adb,,}} as the default name.
898 @command{adb devices} shows available host names.
900 @option{adb} method normally does not need user name to authenticate
901 on the Android device because it runs under the @command{adbd}
902 process. But when a user name is specified, however, @value{tramp}
903 applies an @command{su} in the syntax. When authentication does not
904 succeed, especially on un-rooted Android devices, @value{tramp}
905 displays login errors.
907 For Android devices connected through TCP/IP, a port number can be
908 specified using @file{device#42} host name syntax or @value{tramp} can
909 use the default value as declared in @command{adb} command. Port
910 numbers are not applicable to Android devices connected through USB@.
915 @node GVFS based methods
916 @section GVFS based external methods
917 @cindex methods, gvfs
918 @cindex gvfs based methods
921 GVFS is the virtual file system for the Gnome Desktop,
922 @uref{http://en.wikipedia.org/wiki/GVFS}. Remote files on GVFS are
923 mounted locally through FUSE and @value{tramp} uses this locally
924 mounted directory internally.
926 Emacs uses the D-Bus mechanism to communicate with GVFS@. Emacs must
927 have the message bus system, D-Bus integration active, @pxref{Top, ,
935 This method is for connecting to remote hosts with the Apple Filing
936 Protocol for accessing files on Mac OS X volumes. @value{tramp} access
937 syntax requires a leading volume (share) name, for example:
938 @file{@trampfn{afp,user@@host,/volume}}.
947 @option{dav} method provides access to WebDAV files and directories
948 based on standard protocols, such as HTTP@. @option{davs} does the same
949 but with SSL encryption. Both methods support the port numbers.
951 @item @option{gdrive}
952 @cindex method gdrive
953 @cindex gdrive method
956 Via the @option{gdrive} method it is possible to access your Google
957 Drive online storage. User and host name of the remote file name are
958 your email address of the Google Drive credentials, like
959 @file{@trampfn{gdrive,john.doe@@gmail.com,/}}. These credentials must
960 be populated in your @command{Online Accounts} application outside Emacs.
962 Since Google Drive uses cryptic blob file names internally,
963 @value{tramp} works with the @code{display-name} of the files. This
964 could produce unexpected behavior in case two files in the same
965 directory have the same @code{display-name}, such a situation must be avoided.
971 OBEX is an FTP-like access protocol for cell phones and similar simple
972 devices. @value{tramp} supports OBEX over Bluetooth.
978 This method uses @command{sftp} in order to securely access remote
979 hosts. @command{sftp} is a more secure option for connecting to hosts
980 that for security reasons refuse @command{ssh} connections.
986 @option{synce} method allows connecting to Windows Mobile devices. It
987 uses GVFS for mounting remote files and directories via FUSE and
988 requires the SYNCE-GVFS plugin.
992 @defopt tramp-gvfs-methods
993 This user option is a list of external methods for GVFS@. By default,
994 this list includes @option{afp}, @option{dav}, @option{davs},
995 @option{gdrive}, @option{obex}, @option{sftp} and @option{synce}.
996 Other methods to include are: @option{ftp} and @option{smb}.
1000 @node Gateway methods
1001 @section Gateway methods
1002 @cindex methods, gateway
1003 @cindex gateway methods
1005 Gateway methods are for proxy host declarations (@pxref{Multi-hops})
1006 so as to pass through firewalls and proxy servers. They are not like
1007 the other methods that declare direct connections to a remote host.
1009 A gateway method always comes with a port setting. @value{tramp}
1010 targets the port number with the gateway method
1011 @file{localhost#random_port} from where the firewall or proxy server
1014 Gateway methods support user name and password declarations for
1015 authenticating the corresponding firewall or proxy server. Such
1016 authentication can be passed through only if granted access by system
1020 @item @option{tunnel}
1021 @cindex method tunnel
1022 @cindex tunnel method
1024 This method implements an HTTP tunnel via the @command{CONNECT}
1025 command (conforming to RFC 2616, 2817 specifications). Proxy servers
1026 using HTTP version 1.1 or later protocol support this command.
1028 For authentication, this protocol uses only @option{Basic
1029 Authentication} (see RFC 2617). When no port number is specified, this
1030 protocol defaults to @option{8080}.
1032 @item @option{socks}
1033 @cindex method socks
1034 @cindex socks method
1036 The @option{socks} method connects to SOCKSv5 servers (see RFC 1928)
1037 and supports @option{Username/Password Authentication}.
1039 The default port number for the socks server is @option{1080}, if not
1040 specified otherwise.
1045 @node Default Method
1046 @section Selecting a default method
1047 @cindex default method
1049 @defopt tramp-default-method
1050 Default method is for transferring files. The user option
1051 @option{tramp-default-method} sets it. @value{tramp} uses this user
1052 option to determine the default method for remote file names that do
1053 not have one specified.
1056 (custom-set-variables '(tramp-default-method "ssh" nil (tramp)))
1060 @defopt tramp-default-method-alist
1061 Default methods for transferring files can be customized for specific
1062 user and host combinations through the user option
1063 @option{tramp-default-method-alist}.
1065 For example, the following two lines specify to use the @option{ssh}
1066 method for all user names matching @samp{john} and the @option{rsync}
1067 method for all host names matching @samp{lily}. The third line
1068 specifies to use the @option{su} method for the user @samp{root} on
1069 the host @samp{localhost}.
1073 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1074 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1075 (add-to-list 'tramp-default-method-alist
1076 '("\\`localhost\\'" "\\`root\\'" "su"))
1082 External methods performance faster for large files. @pxref{Inline
1083 methods}. @pxref{External methods}.
1085 Choosing the access method also depends on the security environment.
1086 For example, @option{rsh} and @option{telnet} methods that use clear
1087 text password transfers are inappropriate for over the Internet
1088 connections. Secure remote connections should use @option{ssh} that
1092 @subsection Which method to use?
1093 @cindex choosing the right method
1095 @value{tramp} provides maximum number of choices for maximum
1096 flexibility. Choosing which method depends on the hosts, clients,
1097 network speeds, and the security context.
1099 Start by using an inline method.
1101 External methods might be more efficient for large files, but most
1102 @value{tramp} users edit small files more often than large files.
1104 Enable compression, @var{tramp-inline-compress-start-size}, for a
1105 performance boost for large files.
1107 Since @command{ssh} has become the most common method of remote host
1108 access and it has the most reasonable security protocols, use
1109 @option{ssh} method. Typical @option{ssh} usage to edit the
1110 @file{/etc/motd} file on the otherhost:
1113 @kbd{C-x C-f @trampfn{ssh,root@@otherhost,/etc/motd} @key{RET}}
1116 If @option{ssh} is unavailable for whatever reason, look for other
1117 obvious options. For Windows, try the @option{plink} method. For
1118 Kerberos, try @option{krlogin}.
1120 For editing local files as @option{su} or @option{sudo} methods, try
1121 the shortened syntax of @samp{root}:
1124 @kbd{C-x C-f @trampfn{su,,/etc/motd} @key{RET}}
1127 For editing large files, @option{scp} is faster than @option{ssh}.
1128 @option{pscp} is faster than @option{plink}. But this speed
1129 improvement is not always true.
1133 @section Selecting a default user
1134 @cindex default user
1136 @defopt tramp-default-user
1137 @value{tramp} file name can omit the user name part since
1138 @value{tramp} substitutes the currently logged-in user name. However
1139 this substitution can be overridden with @option{tramp-default-user}.
1143 (custom-set-variables'(tramp-default-user "root" nil (tramp)))
1147 @defopt tramp-default-user-alist
1148 Instead of a single default user, @option{tramp-default-user-alist}
1149 allows multiple default user values based on access method or host
1150 name combinations. The alist can hold multiple values. For example, to
1151 use the @samp{john} as the default user for the domain
1152 @samp{somewhere.else} only:
1156 (add-to-list 'tramp-default-user-alist
1157 '("ssh" ".*\\.somewhere\\.else\\'" "john"))
1161 A Caution: @value{tramp} will override any default user specified in
1162 the configuration files outside Emacs, such as @file{~/.ssh/config}.
1163 To stop @value{tramp} from applying the default value, set the
1164 corresponding alist entry to nil:
1168 (add-to-list 'tramp-default-user-alist
1169 '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
1173 The last entry in @option{tramp-default-user-alist} should be reserved
1174 for catch-all or most often used login.
1178 (add-to-list 'tramp-default-user-alist
1179 '(nil nil "jonas") t)
1186 @section Selecting a default host
1187 @cindex default host
1189 @defopt tramp-default-host
1190 When host name is omitted, @value{tramp} substitutes the value from
1191 the @option{tramp-default-host} user option. It is initially
1192 populated with the local hostname where Emacs is running. Both the
1193 default user and default host can be overridden as follows:
1197 (custom-set-variables
1198 '(tramp-default-user "john" nil (tramp))
1199 '(tramp-default-host "target" nil (tramp)))
1203 With both defaults set, @samp{@trampfn{ssh,,}} will connect
1204 @value{tramp} to John's home directory on @code{target}.
1206 @strong{Note} @samp{/::} won't work, because @samp{/:} is the prefix
1207 for quoted file names.
1209 @pxref{Quoted File Names, , , emacs}.
1213 @defopt tramp-default-host-alist
1214 Instead of a single default host, @option{tramp-default-host-alist}
1215 allows multiple default host values based on access method or user
1216 name combinations. The alist can hold multiple values. While
1217 @option{tramp-default-host} is sufficient in most cases, some methods,
1218 like @option{adb}, require defaults overwritten.
1223 @section Connecting to a remote host using multiple hops
1227 Multi-hops are methods to reach hosts behind firewalls or to reach the
1228 outside world from inside a bastion host. With multi-hops,
1229 @value{tramp} can negotiate these hops with the appropriate user/host
1230 authentication at each hop. All methods until now have been the single
1231 hop kind, where the start and end points of the connection did not
1232 have intermediate check points.
1234 @defopt tramp-default-proxies-alist
1235 @option{tramp-default-proxies-alist} specifies proxy hosts to pass
1236 through. This user option is list of triples consisting of
1237 @code{(@var{host} @var{user} @var{proxy})}.
1239 The first match is the proxy host through which passes the file name
1240 and the target host matching @var{user}@@@var{host}. @var{host} and
1241 @var{user} are regular expressions or @code{nil}, interpreted as a
1242 regular expression which always matches.
1244 @var{proxy} is a literal @value{tramp} file name whose local name part
1245 is ignored, and the method and user name parts are optional.
1247 The method must be an inline or gateway method (@pxref{Inline
1248 methods}, @pxref{Gateway methods}).
1249 If @var{proxy} is @code{nil}, no additional hop is required reaching
1250 @var{user}@@@var{host}.
1252 For example, to pass through the host @samp{bastion.your.domain} as
1253 user @samp{bird} to reach remote hosts outside the local domain:
1257 (add-to-list 'tramp-default-proxies-alist
1258 '("\\." nil "@trampfn{ssh,bird@@bastion.your.domain,}"))
1259 (add-to-list 'tramp-default-proxies-alist
1260 '("\\.your\\.domain\\'" nil nil))
1264 @strong{Note}: @code{add-to-list} adds elements at the beginning of a
1265 list. Therefore, most relevant rules must come last in the list.
1267 Proxy hosts can be cascaded in the alist. If there is another host
1268 called @samp{jump.your.domain}, which is the only host allowed to
1269 connect to @samp{bastion.your.domain}, then:
1273 (add-to-list 'tramp-default-proxies-alist
1274 '("\\`bastion\\.your\\.domain\\'"
1276 "@trampfn{ssh,jump.your.domain,}"))
1280 @var{proxy} can take patterns @code{%h} or @code{%u} for @var{host} or
1281 @var{user} respectively.
1283 To login as @samp{root} on remote hosts in the domain
1284 @samp{your.domain}, but login as @samp{root} is disabled for non-local
1285 access, then use this alist entry:
1289 (add-to-list 'tramp-default-proxies-alist
1290 '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh,%h,}"))
1294 Opening @file{@trampfn{sudo,randomhost.your.domain,}} first connects
1295 to @samp{randomhost.your.domain} via @code{ssh} under your account
1296 name, and then perform @code{sudo -u root} on that host.
1298 It is key for the sudo method in the above example to be applied on
1299 the host after reaching it and not on the local host.
1301 @var{host}, @var{user} and @var{proxy} can also take Lisp forms. These
1302 forms when evaluated must return either a string or @code{nil}.
1304 To generalize (from the previous example): For all hosts, except my
1305 local one, first connect via @command{ssh}, and then apply
1306 @command{sudo -u root}:
1310 (add-to-list 'tramp-default-proxies-alist
1311 '(nil "\\`root\\'" "@trampfn{ssh,%h,}"))
1312 (add-to-list 'tramp-default-proxies-alist
1313 '((regexp-quote (system-name)) nil nil))
1317 The above configuration allows @value{tramp} connection as @samp{root}
1318 to remote Ubuntu hosts.
1320 @option{tramp-default-proxies-alist} is also used for passing through
1321 firewalls or proxy servers.
1323 For example, the local host @samp{proxy.your.domain} on port 3128
1324 serves as HTTP proxy to the outer world. User has access rights to
1325 another proxy server on @samp{host.other.domain}.@footnote{HTTP tunnels
1326 are intended for secure SSL/TLS communication. Therefore, many proxy
1327 servers restrict the tunnels to related target ports. You might need
1328 to run your ssh server on your target host @samp{host.other.domain} on
1329 such a port, like 443 (https). See
1330 @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall} for
1331 discussion of ethical issues.} Then the configuration is:
1335 (add-to-list 'tramp-default-proxies-alist
1336 '("\\`host\\.other\\.domain\\'" nil
1337 "@trampfn{tunnel,proxy.your.domain#3128,}"))
1341 Gateway methods in a multiple hop chain can be declared only as the first hop.
1344 Passing through hops involves dealing with restricted shells, such as
1345 @command{rbash}. If @value{tramp} is made aware, then it would use
1346 them for proxies only.
1348 @defopt tramp-restricted-shell-hosts-alist
1349 An alist of regular expressions of hosts running restricted shells,
1350 such as @command{rbash}. @value{tramp} will then use them only as
1353 To specify the bastion host from the example above as running a
1358 (add-to-list 'tramp-restricted-shell-hosts-alist
1359 "\\`bastion\\.your\\.domain\\'")
1365 @node Customizing Methods
1366 @section Using Non-Standard Methods
1367 @cindex customizing methods
1368 @cindex using non-standard methods
1369 @cindex create your own methods
1371 The @code{tramp-methods} variable currently has an exhaustive list of
1372 predefined methods. Any part of this list can be modified with more
1373 suitable settings. Refer to the Lisp documentation of that variable,
1374 accessible with @kbd{C-h v tramp-methods @key{RET}}.
1377 @node Customizing Completion
1378 @section Selecting config files for user/host name completion
1379 @cindex customizing completion
1380 @cindex selecting config files
1381 @vindex tramp-completion-function-alist
1383 @code{tramp-completion-function-alist} uses predefined files for user
1384 and host name completion (@pxref{File name completion}). For each
1385 method, it keeps a set of configuration files and a function that can
1386 parse that file. Each entry in @code{tramp-completion-function-alist}
1387 is of the form (@var{method} @var{pair1} @var{pair2} @dots{}).
1389 Each @var{pair} is composed of (@var{function} @var{file}).
1390 @var{function} is responsible for extracting user names and host names
1391 from @var{file} for completion. There are two functions which access
1394 @defun tramp-get-completion-function method
1395 This function returns the list of completion functions for @var{method}.
1400 (tramp-get-completion-function "rsh")
1402 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1403 (tramp-parse-rhosts "~/.rhosts"))
1408 @defun tramp-set-completion-function method function-list
1409 This function sets @var{function-list} as list of completion functions
1415 (tramp-set-completion-function "ssh"
1416 '((tramp-parse-sconfig "/etc/ssh_config")
1417 (tramp-parse-sconfig "~/.ssh/config")))
1419 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1420 (tramp-parse-sconfig "~/.ssh/config"))
1425 The following predefined functions parsing configuration files exist:
1428 @item @code{tramp-parse-rhosts}
1429 @findex tramp-parse-rhosts
1431 This function parses files which are syntactical equivalent to
1432 @file{~/.rhosts}. It returns both host names and user names, if
1435 @item @code{tramp-parse-shosts}
1436 @findex tramp-parse-shosts
1438 This function parses files which are syntactical equivalent to
1439 @file{~/.ssh/known_hosts}. Since there are no user names specified
1440 in such files, it can return host names only.
1442 @item @code{tramp-parse-sconfig}
1443 @findex tramp-parse-sconfig
1445 This function returns the host nicknames defined by @code{Host} entries
1446 in @file{~/.ssh/config} style files.
1448 @item @code{tramp-parse-shostkeys}
1449 @findex tramp-parse-shostkeys
1451 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1452 @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1453 @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1454 are always @code{nil}.
1456 @item @code{tramp-parse-sknownhosts}
1457 @findex tramp-parse-sknownhosts
1459 Another SSH2 style parsing of directories like
1460 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1461 case, hosts names are coded in file names
1462 @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1464 @item @code{tramp-parse-hosts}
1465 @findex tramp-parse-hosts
1467 A function dedicated to @file{/etc/hosts} for host names.
1469 @item @code{tramp-parse-passwd}
1470 @findex tramp-parse-passwd
1472 A function which parses @file{/etc/passwd} files for user names.
1474 @item @code{tramp-parse-etc-group}
1475 @findex tramp-parse-etc-group
1477 A function which parses @file{/etc/group} files for group names.
1479 @item @code{tramp-parse-netrc}
1480 @findex tramp-parse-netrc
1482 A function which parses @file{~/.netrc} and @file{~/.authinfo}-style files.
1486 To keep a custom file with custom data in a custom structure, a custom
1487 function has to be provided. This function must meet the following
1490 @defun my-tramp-parse file
1491 @var{file} must be either a file on the host, or @code{nil}. The
1492 function must return a list of (@var{user} @var{host}), which are
1493 taken as candidates for completion for user and host names.
1498 (my-tramp-parse "~/.my-tramp-hosts")
1500 @result{} ((nil "toto") ("daniel" "melancholia"))
1506 @node Password handling
1507 @section Reusing passwords for several connections
1510 To avoid repeated prompts for passwords, consider native caching
1511 mechanisms, such as @command{ssh-agent} for @option{ssh}-like
1512 methods, or @command{pageant} for @option{plink}-like methods.
1514 @value{tramp} offers alternatives when native solutions cannot meet
1518 @anchor{Using an authentication file}
1519 @subsection Using an authentication file
1520 @vindex auth-sources
1522 The package @file{auth-source.el}, originally developed for No Gnus,
1523 reads passwords from different sources, @xref{Help for users, ,
1524 auth-source, auth}. The default authentication file is
1525 @file{~/.authinfo.gpg}, but this can be changed via the variable
1526 @code{auth-sources}.
1529 A typical entry in the authentication file:
1532 machine melancholia port scp login daniel password geheim
1535 The port can take any @value{tramp} method (@pxref{Inline methods},
1536 @pxref{External methods}). Omitting port values matches all
1537 @value{tramp} methods.
1539 Setting @code{auth-source-debug} to @code{t} to debug messages.
1542 @anchor{Caching passwords}
1543 @subsection Caching passwords
1545 @value{tramp} can cache passwords as entered and reuse when needed for
1546 the same user or host name independent of the access method.
1548 @vindex password-cache-expiry
1549 @code{password-cache-expiry} sets the duration (in seconds) the
1550 passwords are remembered. Passwords are never saved permanently nor
1551 can they extend beyond the lifetime of the current Emacs session. Set
1552 @code{password-cache-expiry} to @code{nil} to disable expiration.
1554 @vindex password-cache
1555 Set @code{password-cache} to @code{nil} to disable password caching.
1558 @node Connection caching
1559 @section Reusing connection related information
1561 @vindex tramp-persistency-file-name
1563 For faster initial connection times, @value{tramp} stores previous
1564 connection properties in a file specified by the user option
1565 @option{tramp-persistency-file-name}.
1567 The default file name for @option{tramp-persistency-file-name} is
1568 @file{~/.emacs.d/tramp}.
1570 @value{tramp} reads this file during Emacs startup, and writes to it
1571 when exiting Emacs. Delete this file for @value{tramp} to recreate a
1572 new one on next Emacs startup.
1574 Set @option{tramp-persistency-file-name} to @code{nil} to disable
1575 storing connections persistently.
1577 To reuse connection information from the persistent list,
1578 @value{tramp} needs to uniquely identify every host. However in some
1579 cases, two different connections may result in the same persistent
1580 information. For example, connecting to a host using @command{ssh} and
1581 connecting to the same host through @code{sshd} on port 3001. Both
1582 access methods result in nearly identical persistent specifications
1583 @file{@trampfn{ssh,localhost,}} and @file{@trampfn{ssh,localhost#3001,}}.
1585 Changing host names could avoid duplicates. One way is to add a
1586 @option{Host} section in @file{~/.ssh/config} (@pxref{Frequently Asked
1587 Questions}). Another way is to apply multiple hops (@pxref{Multi-hops}).
1589 When @value{tramp} detects a change in the operating system version in
1590 a remote host (via the command @command{uname -sr}), it flushes all
1591 connection related information for that host and creates a new entry.
1594 @node Predefined connection information
1595 @section Setting own connection related information
1596 @vindex tramp-connection-properties
1598 For more precise customization, parameters specified by
1599 @code{tramp-methods} can be overwritten manually.
1601 Set @option{tramp-connection-properties} to manually override
1602 @code{tramp-methods}. Properties in this list are in the form
1603 @code{(@var{regexp} @var{property} @var{value})}. @var{regexp}
1604 matches remote file names. Use @code{nil} to match all.
1605 @var{property} is the property's name, and @var{value} is the
1608 @var{property} is any method specific parameter contained in
1609 @code{tramp-methods}. The parameter key in @code{tramp-methods} is a
1610 symbol name @code{tramp-<foo>}. To overwrite that property, use the
1611 string @samp{<foo>} for @var{property}. For example, this changes the
1616 (add-to-list 'tramp-connection-properties
1617 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1618 "remote-shell" "/bin/ksh"))
1622 (add-to-list 'tramp-connection-properties
1623 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1624 "remote-shell-login" '("-")))
1628 The parameters @code{tramp-remote-shell} and
1629 @code{tramp-remote-shell-login} in @code{tramp-methods} now have new
1630 values for the remote host.
1632 @var{property} could also be any property found in
1633 @option{tramp-persistency-file-name}.
1635 To get around how restricted shells randomly drop connections, set the
1636 special property @samp{busybox}. For example:
1640 (add-to-list 'tramp-connection-properties
1641 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1647 @node Remote programs
1648 @section How @value{tramp} finds and uses programs on the remote host
1650 @value{tramp} requires access to and rights to several commands on
1651 remote hosts: @command{ls}, @command{test}, @command{find} and
1654 Besides there are other required programs for @ref{Inline methods} and
1655 @ref{External methods} of connection.
1657 To improve performance and accuracy of remote file access,
1658 @value{tramp} uses @command{perl} (or @command{perl5}) and
1659 @command{grep} when available.
1661 @defopt tramp-remote-path
1662 @option{tramp-remote-path} specifies which remote directory paths
1663 @value{tramp} can search for @ref{Remote programs}.
1665 @vindex tramp-default-remote-path
1666 @value{tramp} uses standard defaults, such as @file{/bin} and
1667 @file{/usr/bin}, which are reasonable for most hosts. To accommodate
1668 differences in hosts and paths, for example, @file{/bin:/usr/bin} on
1670 @file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin} on
1671 Solaris, @value{tramp} queries the remote host with @command{getconf
1672 PATH} and updates the symbol @code{tramp-default-remote-path}.
1674 For instances where hosts keep obscure locations for paths for
1675 security reasons, manually add such paths to local @file{.emacs} as
1676 shown below for @value{tramp} to use when connecting.
1679 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1682 @vindex tramp-own-remote-path
1683 Another way to find the remote path is to use the path assigned to the
1684 remote user by the remote host. @value{tramp} does not normally retain
1685 this remote path after login. However, @code{tramp-own-remote-path}
1686 preserves the path value, which can be used to update
1687 @option{tramp-remote-path}.
1690 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1693 @strong{Note} that this works only if your remote @command{/bin/sh}
1694 shell supports the login argument @samp{-l}.
1697 When remote search paths are changed, local @value{tramp} caches must
1698 be recomputed. To force @value{tramp} to recompute afresh, exit
1699 Emacs, remove the persistent file (@pxref{Connection caching}), and
1703 @node Remote shell setup
1704 @section Remote shell setup hints
1705 @cindex remote shell setup
1706 @cindex @file{.profile} file
1707 @cindex @file{.login} file
1708 @cindex shell init files
1710 @value{tramp} checks for the availability of standard programs in the
1711 usual locations. Common tactics include successively trying
1712 @command{test -e}, @command{/usr/bin/test -e}, and @command{/bin/test
1713 -e}. @command{ls -d} is another approach. But these approaches do not
1714 help with these new login patterns.
1716 When @value{tramp} encounters two-factor logins or additional challenge
1717 questions, such as entering birth date or security code or passphrase,
1718 @value{tramp} needs a few more configuration steps to accommodate
1721 The difference between a password prompt and a passphrase prompt is
1722 that the password for completing the login while the passphrase is
1723 for authorizing access to local authentication information, such as
1726 There is no one configuration to accommodate all the variations in
1727 login security, especially not the exotic ones. However, @value{tramp}
1728 provides a few tweaks to address the most common ones.
1731 @item @option{tramp-shell-prompt-pattern}
1732 @vindex tramp-shell-prompt-pattern
1734 @option{tramp-shell-prompt-pattern} is for remote login shell prompt,
1735 which may not be the same as the local login shell prompt,
1736 @code{shell-prompt-pattern}. Since most hosts use identical prompts,
1737 @value{tramp} sets a similar default value for both prompts.
1739 @item @option{tramp-password-prompt-regexp}
1740 @item @option{tramp-wrong-passwd-regexp}
1741 @vindex tramp-password-prompt-regexp
1742 @vindex tramp-wrong-passwd-regexp
1744 @value{tramp} uses @option{tramp-password-prompt-regexp} to
1745 distinguish between prompts for passwords and prompts for passphrases.
1746 By default, @option{tramp-password-prompt-regexp} handles the
1747 detection in English language environments. See a localization
1752 (custom-set-variables
1753 '(tramp-password-prompt-regexp
1757 '("passphrase" "Passphrase"
1759 "password" "Password"
1761 "passwort" "Passwort"
1763 "mot de passe" "Mot de passe")
1770 Similar localization may be necessary for handling wrong password
1771 prompts, for which @value{tramp} uses @option{tramp-wrong-passwd-regexp}.
1773 @item @command{tset} and other questions
1774 @cindex Unix command tset
1775 @cindex tset Unix command
1776 @vindex tramp-terminal-type
1778 To suppress inappropriate prompts for terminal type, @value{tramp}
1779 sets the @env{TERM} to @code{dumb} before the remote login process
1780 begins via the user option @option{tramp-terminal-type}. This will
1781 silence common @command{tset} related prompts.
1783 @value{tramp}'s strategy for handling such prompts (commonly triggered
1784 from login scripts on remote hosts) is to set the environment
1785 variables so that no prompts interrupt the shell initialization
1788 @vindex tramp-actions-before-shell
1789 An alternative approach is to configure @value{tramp} with strings
1790 that can identify such questions using
1791 @code{tramp-actions-before-shell}. Example:
1795 (defconst my-tramp-prompt-regexp
1796 (concat (regexp-opt '("Enter the birth date of your mother:") t)
1798 "Regular expression matching my login prompt question.")
1802 (defun my-tramp-action (proc vec)
1803 "Enter \"19000101\" in order to give a correct answer."
1804 (save-window-excursion
1805 (with-current-buffer (tramp-get-connection-buffer vec)
1806 (tramp-message vec 6 "\n%s" (buffer-string))
1807 (tramp-send-string vec "19000101"))))
1811 (add-to-list 'tramp-actions-before-shell
1812 '(my-tramp-prompt-regexp my-tramp-action))
1817 @item Conflicting names for users and variables in @file{.profile}
1819 When a user name is the same as a variable name in a local file, such
1820 as @file{.profile}, then @value{tramp} may send incorrect values for
1821 environment variables. To avoid incorrect values, change the local
1822 variable name to something different from the user name. For example,
1823 if the user name is @env{FRUMPLE}, then change the variable name to
1827 @item Non-Bourne commands in @file{.profile}
1829 When the remote host's @file{.profile} is also used for shells other
1830 than Bourne shell, then some incompatible syntaxes for commands in
1831 @file{.profile} may trigger errors in Bourne shell on the host and may
1832 not complete client's @value{tramp} connections.
1834 One example of a Bourne shell incompatible syntax in @file{.profile}:
1835 using @command{export FOO=bar} instead of @command{FOO=bar; export
1836 FOO}. After remote login, @value{tramp} will trigger an error during
1837 its execution of @command{/bin/sh} on the remote host because Bourne
1838 shell does not recognize the export command as entered in
1841 Likewise, (@code{~}) character in paths will cause errors because
1842 Bourne shell does not do (@code{~}) character expansions.
1844 One approach to avoiding these incompatibilities is to make all
1845 commands in @file{~/.shrc} and @file{~/.profile} Bourne shell
1846 compatible so @value{tramp} can complete connections to that remote.
1847 To accommodate using non-Bourne shells on that remote, use other
1848 shell-specific config files. For example, bash can use
1849 @file{~/.bash_profile} and ignore @file{.profile}.
1852 @item Interactive shell prompt
1854 @value{tramp} redefines the remote shell prompt internally for robust
1855 parsing. This redefinition affects the looks of a prompt in an
1856 interactive remote shell through commands, such as @kbd{M-x
1857 shell}. Such prompts, however, can be reset to something more readable
1858 and recognizable using these @value{tramp} variables.
1860 @value{tramp} sets the @env{INSIDE_EMACS} variable in the startup
1861 script file @file{~/.emacs_SHELLNAME}.
1863 @env{SHELLNAME} is @code{bash} or equivalent shell names. Change it by
1864 setting the environment variable @env{ESHELL} in the @file{.emacs} as
1868 (setenv "ESHELL" "bash")
1871 Then re-set the prompt string in @file{~/.emacs_SHELLNAME} as follows:
1875 # Reset the prompt for remote Tramp shells.
1876 if [ "$@{INSIDE_EMACS/*tramp*/tramp@}" == "tramp" ] ; then
1883 @xref{Interactive Shell, , , emacs}.
1886 @item @command{busybox} / @command{nc}
1887 @cindex Unix command nc
1888 @cindex nc Unix command
1890 @value{tramp}'s @option{nc} method uses the @command{nc} command to
1891 install and execute a listener as follows (see @code{tramp-methods}):
1897 The above command-line syntax has changed with @command{busybox}
1898 versions. If @command{nc} refuses the @samp{-p} parameter, then
1899 overwrite as follows:
1904 'tramp-connection-properties
1905 `(,(regexp-quote "192.168.0.1")
1906 "remote-copy-args" (("-l") ("%r"))))
1911 where @samp{192.168.0.1} is the remote host IP address
1912 (@pxref{Predefined connection information}).
1917 @node Android shell setup
1918 @section Android shell setup hints
1919 @cindex android shell setup
1921 @value{tramp} uses the @option{adb} method to access Android
1922 devices. Android devices provide a restricted shell access through an
1923 USB connection. The local host must have the Android SDK installed.
1925 Applications such as @code{SSHDroid} that run @command{sshd} process
1926 on the Android device can accept any @option{ssh}-based methods
1927 provided these settings are adjusted:
1929 @command{sh} must be specified for remote shell since Android devices
1930 do not provide @command{/bin/sh}. @command{sh} will then invoke
1931 whatever shell is installed on the device with this setting:
1935 (add-to-list 'tramp-connection-properties
1936 (list (regexp-quote "192.168.0.26") "remote-shell" "sh"))
1941 where @samp{192.168.0.26} is the Android device's IP address.
1942 (@pxref{Predefined connection information}).
1944 @value{tramp} requires preserving @env{PATH} environment variable from
1945 user settings. Android devices prefer @file{/system/xbin} path over
1946 @file{/system/bin}. Both of these are set as follows:
1950 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1951 (add-to-list 'tramp-remote-path "/system/xbin")
1956 When the Android device is not @samp{rooted}, specify a writable
1957 directory for temporary files:
1960 (add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")
1964 Open a remote connection with the command @kbd{C-x C-f
1965 @trampfn{ssh,192.168.0.26#2222,}}, where @command{sshd} is listening
1966 on port @samp{2222}.
1968 To add a corresponding entry to the @file{~/.ssh/config} file
1969 (recommended), use this:
1974 HostName 192.168.0.26
1981 To use the host name @samp{android} instead of the IP address shown in
1982 the previous example, fix the connection properties as follows:
1986 (add-to-list 'tramp-connection-properties
1987 (list (regexp-quote "android") "remote-shell" "sh"))
1992 Open a remote connection with a more concise command @kbd{C-x C-f
1993 @trampfn{ssh,android,}}.
1996 @node Auto-save and Backup
1997 @section Auto-save and Backup configuration
2000 @vindex backup-directory-alist
2002 To avoid @value{tramp} from saving backup files owned by @samp{root}
2003 to locations accessible to others, default backup settings in
2004 @option{backup-directory-alist} have to be altered.
2006 Here's a scenario where files could be inadvertently exposed. Emacs
2007 by default writes backup files to the same directory as the original
2008 files unless changed to another location, such as
2009 @file{~/.emacs.d/backups/}. Such a directory will also be used by
2010 default by @value{tramp} when using, say, a restricted file
2011 @file{@trampfn{su,root@@localhost,/etc/secretfile}}. The backup file
2012 of the secretfile is now owned by the user logged in from
2013 @value{tramp} and not @samp{root}.
2015 When @option{backup-directory-alist} is @code{nil} (the default), such
2016 problems do not occur.
2018 To ``turn off'' the backup feature for @value{tramp} files and stop
2019 @value{tramp} from saving to the backup directory, use this:
2023 (add-to-list 'backup-directory-alist
2024 (cons tramp-file-name-regexp nil))
2029 Disabling backups can be targeted to just the @option{su} and
2030 @option{sudo} methods:
2034 (setq backup-enable-predicate
2036 (and (normal-backup-enable-predicate name)
2038 (let ((method (file-remote-p name 'method)))
2039 (when (stringp method)
2040 (member method '("su" "sudo"))))))))
2044 Another option is to create better backup file naming with user and
2045 host names prefixed to the file name. For example, transforming
2046 @file{/etc/secretfile} to
2047 @file{~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile}, set the
2048 @value{tramp} user option @option{tramp-backup-directory-alist} from
2049 the existing user option @option{backup-directory-alist}.
2051 Then @value{tramp} backs up to a file name that is transformed with a
2052 prefix consisting of the DIRECTORY name. This file name prefixing
2053 happens only when the DIRECTORY is an absolute local file name.
2060 (add-to-list 'backup-directory-alist
2061 (cons "." "~/.emacs.d/backups/"))
2062 (custom-set-variables
2063 '(tramp-backup-directory-alist backup-directory-alist 6 nil (tramp)))
2068 The backup file name of
2069 @file{@trampfn{su,root@@localhost,/etc/secretfile}} would be
2071 @file{@trampfn{su,root@@localhost,~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}}
2074 @file{@trampfn{su,root@@localhost,~/.emacs.d/backups/![su!root@@localhost]!etc!secretfile~}}
2077 Just as for backup files, similar issues of file naming affect
2078 auto-saving @value{tramp} files. Auto-saved files are saved in the
2079 directory specified by the user option
2080 @option{auto-save-file-name-transforms}. By default this is set to
2081 the local temporary directory. But in some versions of Debian
2082 GNU/Linux, this points to the source directory where the Emacs was
2083 compiled. Reset such values to a valid directory.
2085 Set @option{auto-save-file-name-transforms} to @code{nil} to save
2086 auto-saved files to the same directory as the original file.
2088 Alternatively, set the user option @option{tramp-auto-save-directory}
2089 to direct all auto saves to that location.
2091 @node Windows setup hints
2092 @section Issues with Cygwin ssh
2093 @cindex Cygwin, issues
2095 This section is incomplete. Please share your solutions.
2097 @cindex method sshx with Cygwin
2098 @cindex sshx method with Cygwin
2100 Cygwin's @command{ssh} works only with a Cygwin version of Emacs. To
2101 check for compatibility: type @kbd{M-x eshell}, and start @kbd{ssh
2102 test.host}. Incompatibilities trigger this message:
2105 Pseudo-terminal will not be allocated because stdin is not a terminal.
2108 Some older versions of Cygwin's @command{ssh} work with the
2109 @option{sshx} access method. Consult Cygwin's FAQ at
2110 @uref{http://cygwin.com/faq/} for details.
2112 @cindex Cygwin and fakecygpty
2113 @cindex fakecygpty and Cygwin
2115 On @uref{https://www.emacswiki.org/emacs/SshWithNTEmacs, the Emacs
2116 Wiki} it is explained how to use the helper program @code{fakecygpty}
2117 to fix this problem.
2119 @cindex method scpx with Cygwin
2120 @cindex scpx method with Cygwin
2122 When using the @option{scpx} access method, Emacs may call
2123 @command{scp} with Windows file naming, such as @code{c:/foo}. But
2124 the version of @command{scp} that is installed with Cygwin does not
2125 know about Windows file naming, which causes it to incorrectly look
2126 for a host named @code{c}.
2128 A workaround: write a wrapper script for @option{scp} to convert
2129 Windows file names to Cygwin file names.
2131 @cindex Cygwin and ssh-agent
2132 @cindex SSH_AUTH_SOCK and Emacs on Windows
2134 When using the @command{ssh-agent} on Windows for password-less
2135 interaction, @option{ssh} methods depend on the environment variable
2136 @env{SSH_AUTH_SOCK}. But this variable is not set when Emacs is
2137 started from a Desktop shortcut and authentication fails.
2139 One workaround is to use a Windows based SSH Agent, such as
2140 Pageant. It is part of the Putty Suite of tools.
2142 The fallback is to start Emacs from a shell.
2146 @chapter Using @value{tramp}
2147 @cindex using @value{tramp}
2149 @value{tramp} operates transparently, accessing remote files as if
2150 they are local. However, @value{tramp} employs a formalized remote
2151 file naming syntax to perform its functions transparently. This
2152 syntax consists of many parts specifying access methods,
2153 authentication, host names, and file names. Ange FTP uses a similar
2158 Unlike opening local files in Emacs, which are instantaneous, opening
2159 remote files in @value{tramp} is slower at first. Sometimes there is
2160 a noticeable delay before the prompts for passwords or authentication
2161 appear in the minibuffer. Hitting @kbd{@key{RET}} or other keys
2162 during this gap will be processed by Emacs. This type-ahead facility
2163 is a feature of Emacs that may cause missed prompts when using
2167 * File name Syntax:: @value{tramp} file name conventions.
2168 * File name completion:: File name completion.
2169 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
2170 * Remote processes:: Integration with other Emacs packages.
2171 * Cleanup remote connections:: Cleanup remote connections.
2175 @node File name Syntax
2176 @section @value{tramp} file name conventions
2177 @cindex file name syntax
2178 @cindex file name examples
2180 @file{@trampf{host,localfilename}} opens file @var{localfilename} on
2181 the remote host @var{host}, using the default method. @xref{Default
2185 @item @value{prefix}melancholia@value{postfix}.emacs
2186 For the file @file{.emacs} located in the home directory, on the host
2189 @item @value{prefix}melancholia.danann.net@value{postfix}.emacs
2190 For the file @file{.emacs} specified using the fully qualified domain name of
2193 @item @value{prefix}melancholia@value{postfix}~/.emacs
2194 For the file @file{.emacs} specified using the @file{~}, which is expanded.
2196 @item @value{prefix}melancholia@value{postfix}~daniel/.emacs
2197 For the file @file{.emacs} located in @code{daniel}'s home directory
2198 on the host, @code{melancholia}. The @file{~<user>} construct is
2199 expanded to the home directory of that user on the remote host.
2201 @item @value{prefix}melancholia@value{postfix}/etc/squid.conf
2202 For the file @file{/etc/squid.conf} on the host @code{melancholia}.
2206 @var{host} can take IPv4 or IPv6 address, as in
2207 @file{@trampf{127.0.0.1,.emacs}} or
2208 @file{@trampf{@value{ipv6prefix}::1@value{ipv6postfix},.emacs}}.
2210 For syntactical reasons, IPv6 addresses must be embedded in square
2211 brackets @file{@value{ipv6prefix}} and @file{@value{ipv6postfix}}.
2214 By default, @value{tramp} will use the current local user name as the
2215 remote user name for log in to the remote host. Specifying a different
2216 name using the proper syntax will override this default behavior:
2219 @trampf{user@@host,path/to.file}
2222 @file{@trampf{daniel@@melancholia,.emacs}} is for file @file{.emacs}
2223 in @code{daniel}'s home directory on the host, @code{melancholia}.
2225 Specify other file access methods (@pxref{Inline methods},
2226 @pxref{External methods}) as part of the file name.
2228 Method name comes before user name, as in
2229 @file{@value{prefix}@var{method}@value{postfixhop}} (Note the trailing
2230 colon). The syntax specifications for user, host, and file do not
2233 To connect to the host @code{melancholia} as @code{daniel}, using
2234 @option{ssh} method for @file{.emacs} in @code{daniel}'s home
2235 directory, the full specification is:
2236 @file{@trampfn{ssh,daniel@@melancholia,.emacs}}.
2238 A remote file name containing a host name, which is the same string as
2239 a method name, is not allowed.
2241 For specifying port numbers, affix @file{#<port>} to the host
2242 name. For example: @file{@trampfn{ssh,daniel@@melancholia#42,.emacs}}.
2245 @node File name completion
2246 @section File name completion
2247 @cindex file name completion
2249 @value{tramp} can complete the following @value{tramp} file name
2250 components: method names, user names, host names, and file names
2251 located on remote hosts. Enable this by activating partial completion
2254 @xref{Completion Options, , , emacs}.
2257 For example, type @kbd{C-x C-f @value{prefix}t @key{TAB}},
2258 @value{tramp} completion choices show up as
2262 @c @multitable {@trampfn{telnet,melancholia.danann.net,}} {@trampfn{telnet,192.168.0.1,}}
2263 @multitable @columnfractions .5 .5
2264 @item @value{prefixhop}telnet@value{postfixhop} @tab tmp/
2265 @item @value{prefixhop}toto@value{postfix} @tab
2270 @samp{@value{prefixhop}telnet@value{postfixhop}} is a possible
2271 completion for the respective method, @samp{tmp/} stands for the
2272 directory @file{/tmp} on your local host, and
2273 @samp{@value{prefixhop}toto@value{postfix}} might be a host
2274 @value{tramp} has detected in your @file{~/.ssh/known_hosts} file
2275 (when using @option{ssh} as default method).
2277 Type @kbd{e @key{TAB}} for the minibuffer completion to
2278 @samp{@value{prefix}telnet@value{postfixhop}}. Typing @kbd{@key{TAB}}
2279 shows host names @value{tramp} from @file{/etc/hosts} file, for example.
2283 @multitable @columnfractions .5 .5
2284 @c @multitable {@trampfn{telnet,melancholia.danann.net,}} {@trampfn{telnet,192.168.0.1,}}
2285 @item @trampfn{telnet,127.0.0.1,} @tab @trampfn{telnet,192.168.0.1,}
2286 @c @item @trampfn{telnet,@value{ipv6prefix}::1@value{ipv6postfix},} @tab @trampfn{telnet,localhost,}
2287 @item @value{prefix}telnet@value{postfixhop}@value{ipv6prefix}::1@value{ipv6postfix}@value{postfix} @tab @trampfn{telnet,localhost,}
2288 @item @trampfn{telnet,melancholia.danann.net,} @tab @trampfn{telnet,melancholia,}
2293 Choose a host from the above list and then continue to complete file
2296 When the configuration (@pxref{Customizing Completion}) includes user
2297 names, then the completion lists will account for the user names as well.
2299 Remote hosts previously visited or hosts whose connections are kept
2300 persistently (@pxref{Connection caching}) will be included in the
2303 After remote host name completion comes completion of file names on
2304 the remote host. It works the same as with local host file completion
2305 except that killing with double-slash @file{//} kills only the file
2306 name part of the @value{tramp} file name syntax. A triple-slash
2307 stands for the default behavior.
2309 @xref{Minibuffer File, , , emacs}.
2317 @kbd{C-x C-f @trampfn{telnet,melancholia,/usr/local/bin//etc} @key{TAB}}
2318 @print{} @trampfn{telnet,melancholia,/etc}
2320 @kbd{C-x C-f @trampfn{telnet,melancholia,//etc} @key{TAB}}
2323 @kbd{C-x C-f @trampfn{telnet,melancholia,/usr/local/bin///etc} @key{TAB}}
2328 During file name completion, remote directory contents are re-read
2329 regularly to account for any changes in the filesystem that may affect
2330 the completion candidates. Such re-reads can account for changes to
2331 the file system by applications outside Emacs (@pxref{Connection
2334 @defopt tramp-completion-reread-directory-timeout
2335 The timeout is number of seconds since last remote command for
2336 rereading remote directory contents. A value of 0 re-reads
2337 immediately during file name completion, @code{nil} uses cached
2342 @node Ad-hoc multi-hops
2343 @section Declaring multiple hops in the file name
2344 @cindex multi-hop, ad-hoc
2345 @cindex proxy hosts, ad-hoc
2347 @value{tramp} file name syntax can accommodate ad hoc specification of
2348 multiple proxies without using @option{tramp-default-proxies-alist}
2349 configuration setup(@pxref{Multi-hops}).
2351 Each proxy is specified using the same syntax as the remote host
2352 specification minus the file name part. Each hop is separated by a
2353 @samp{|}. Chain the proxies from the starting host to the destination
2354 remote host name and file name. For example, hopping over a single
2355 proxy @samp{bird@@bastion} to a remote file on @samp{you@@remotehost}:
2358 @c @kbd{C-x C-f @trampfn{ssh@value{postfixhop}bird@@bastion|ssh,you,remotehost,/path}}
2359 @kbd{C-x C-f @value{prefix}ssh@value{postfixhop}bird@@bastion|ssh@value{postfixhop}you@@remotehost@value{postfix}/path}
2362 Proxies can take patterns @code{%h} or @code{%u}.
2364 @value{tramp} adds the ad-hoc definitions on the fly to
2365 @option{tramp-default-proxies-alist} and is available for re-use
2366 during that Emacs session. Subsequent @value{tramp} connections to
2367 the same remote host can then use the shortcut form:
2368 @samp{@trampfn{ssh,you@@remotehost,/path}}.
2370 @defopt tramp-save-ad-hoc-proxies
2371 For ad-hoc definitions to be saved automatically in
2372 @option{tramp-default-proxies-alist} for future Emacs sessions, set
2373 @option{tramp-save-ad-hoc-proxies} to non-@code{nil}.
2376 (custom-set-variables '(tramp-save-ad-hoc-proxies t nil (tramp)))
2381 @node Remote processes
2382 @section Integration with other Emacs packages
2386 @value{tramp} supports starting new running processes on the remote
2387 host for discovering remote file names. Emacs packages on the remote
2388 host need no specific modifications for @value{tramp}'s use.
2390 This type of integration does not work with the @option{ftp} method,
2391 and does not support the pty association as specified in
2392 @code{start-file-process}.
2394 @code{process-file} and @code{start-file-process} work on the remote
2395 host when the variable @code{default-directory} is remote:
2399 (let ((default-directory "/ssh:remote.host:"))
2400 (start-file-process "grep" (get-buffer-create "*grep*")
2401 "/bin/sh" "-c" "grep -e tramp *"))
2405 Remote processes do not apply to GVFS (see @ref{GVFS based methods})
2406 because the remote file system is mounted on the local host and
2407 @value{tramp} just accesses by changing the @code{default-directory}.
2409 @value{tramp} starts a remote process when a command is executed in a
2410 remote file or directory buffer. As of now, these packages have been
2411 integrated to work with @value{tramp}: @file{compile.el} (commands
2412 like @code{compile} and @code{grep}) and @file{gud.el} (@code{gdb} or
2415 For @value{tramp} to find the command on the remote, it must be
2416 accessible through the default search path as setup by @value{tramp}
2417 upon first connection. Alternatively, use an absolute path or extend
2418 @option{tramp-remote-path} (see @ref{Remote programs}):
2422 (add-to-list 'tramp-remote-path "~/bin")
2423 (add-to-list 'tramp-remote-path "/appli/pub/bin")
2427 Customize user option @option{tramp-remote-process-environment} to
2428 suit the remote program's environment for the remote host.
2429 @option{tramp-remote-process-environment} is a list of strings
2430 structured similar to @code{process-environment}, where each element
2431 is a string of the form @samp{ENVVARNAME=VALUE}.
2433 To avoid any conflicts with local host environment variables set
2434 through local configuration files, such as @file{~/.profile}, use
2435 @samp{ENVVARNAME=} to unset them for the remote environment.
2438 Use @code{add-to-list} to add entries:
2441 (add-to-list 'tramp-remote-process-environment "JAVA_HOME=/opt/java")
2444 Modifying or deleting already existing values in the
2445 @option{tramp-remote-process-environment} list may not be feasible on
2446 restricted remote hosts. For example, some system administrators
2447 disallow changing @env{HISTORY} environment variable. To accommodate
2448 such restrictions when using @value{tramp}, fix the
2449 @option{tramp-remote-process-environment} by the following code in the
2450 local @file{.emacs} file:
2454 (let ((process-environment tramp-remote-process-environment))
2455 (setenv "HISTORY" nil)
2456 (setq tramp-remote-process-environment process-environment))
2460 Setting the @env{ENV} environment variable instructs some shells to
2461 read an initialization file. Per default, @value{tramp} has disabled
2462 this. You could overwrite this behaviour by evaluating
2466 (let ((process-environment tramp-remote-process-environment))
2467 (setenv "ENV" "$HOME/.profile")
2468 (setq tramp-remote-process-environment process-environment))
2472 @value{tramp} does not use the defaults specified in
2473 @code{process-environment} for running @code{process-file} or
2474 @code{start-file-process} on remote hosts. When values from
2475 @code{process-environment} are needed for remote processes, then set
2480 (let ((process-environment (cons "HGPLAIN=1" process-environment)))
2481 (process-file @dots{}))
2485 This works only for environment variables not already set in the
2486 @code{process-environment}.
2488 For integrating other Emacs packages so @value{tramp} can execute
2489 remotely, please file a bug report. @xref{Bug Reports}.
2492 @subsection Running remote programs that create local X11 windows
2494 To allow a remote program to create an X11 window on the local host,
2495 set the @env{DISPLAY} environment variable for the remote host as
2496 follows in the local @file{.emacs} file:
2500 (add-to-list 'tramp-remote-process-environment
2501 (format "DISPLAY=%s" (getenv "DISPLAY")))
2506 @code{(getenv "DISPLAY")} should return a recognizable name for the
2507 local host that the remote host can redirect X11 window
2508 interactions. If querying for a recognizable name is not possible for
2509 whatever reason, then replace @code{(getenv "DISPLAY")} with a
2510 hard-coded, fixed name. Note that using @code{:0} for X11 display name
2511 here will not work as expected.
2513 An alternate approach is specify @code{ForwardX11 yes} or
2514 @code{ForwardX11Trusted yes} in the file @file{~/.ssh/config} on the
2518 @subsection Running @code{shell} on a remote host
2521 Set @option{explicit-shell-file-name} to the appropriate shell name
2522 when using @value{tramp} between two hosts with different operating
2523 systems, such as @samp{windows-nt} and @samp{gnu/linux}. This option
2524 ensures the correct name of the remote shell program.
2526 Starting with Emacs 24, when @option{explicit-shell-file-name} is
2527 equal to @code{nil}, calling @code{shell} interactively will prompt
2531 @subsection Running @code{shell-command} on a remote host
2532 @cindex shell-command
2534 @code{shell-command} executes commands synchronously or asynchronously
2535 on remote hosts and displays output in buffers on the local
2540 @kbd{C-x C-f @trampfn{sudo,,} @key{RET}}
2541 @kbd{M-! tail -f /var/log/syslog.log & @key{RET}}
2545 @command{tail} command outputs continuously to the local buffer,
2546 @file{*Async Shell Command*}
2548 @kbd{M-x auto-revert-tail-mode} runs similarly showing continuous output.
2551 @subsection Running @code{eshell} on a remote host
2554 @value{tramp} is integrated into @file{eshell.el}, which enables
2555 interactive eshell sessions on remote hosts at the command prompt.
2556 You must add the module @code{eshell-tramp} to
2557 @code{eshell-modules-list}. Here's a sample interaction after opening
2558 @kbd{M-x eshell} on a remote host:
2562 @b{~ $} cd @trampfn{sudo,,/etc} @key{RET}
2563 @b{@trampfn{sudo,root@@host,/etc} $} hostname @key{RET}
2565 @b{@trampfn{sudo,root@@host,/etc} $} id @key{RET}
2566 uid=0(root) gid=0(root) groups=0(root)
2567 @b{@trampfn{sudo,root@@host,/etc} $} find-file shadow @key{RET}
2569 @b{@trampfn{sudo,root@@host,/etc} $}
2573 @code{eshell} in Emacs 23.2 added custom @code{su} and @code{sudo}
2574 commands that set the default directory correctly for the
2575 @file{*eshell*} buffer. @value{tramp} silently updates
2576 @option{tramp-default-proxies-alist} with an entry for this directory
2577 (@pxref{Multi-hops}):
2581 @b{~ $} cd @trampfn{ssh,user@@remotehost,/etc} @key{RET}
2582 @b{@trampfn{ssh,user@@remotehost,/etc} $} find-file shadow @key{RET}
2583 File is not readable: @trampfn{ssh,user@@remotehost,/etc/shadow}
2584 @b{@trampfn{ssh,user@@remotehost,/etc} $} sudo find-file shadow @key{RET}
2589 @b{@trampfn{ssh,user@@remotehost,/etc} $} su - @key{RET}
2590 @b{@trampfn{su,root@@remotehost,/root} $} id @key{RET}
2591 uid=0(root) gid=0(root) groups=0(root)
2592 @b{@trampfn{su,root@@remotehost,/root} $}
2597 @anchor{Running a debugger on a remote host}
2598 @subsection Running a debugger on a remote host
2603 @file{gud.el} provides a unified interface to symbolic debuggers
2605 (@ref{Debuggers, , , emacs}).
2607 @value{tramp} can run debug on remote hosts by calling @code{gdb}
2608 with a remote file name:
2612 @kbd{M-x gdb @key{RET}}
2613 @b{Run gdb (like this):} gdb -i=mi @trampfn{ssh,host,~/myprog} @key{RET}
2617 Since the remote @code{gdb} and @code{gdb-inferior} processes do not
2618 belong to the same process group on the remote host, there will be a
2619 warning, which can be ignored:
2622 &"warning: GDB: Failed to set controlling terminal: Operation not permitted\n"
2625 Relative file names are based on the remote default directory. When
2626 @file{myprog.pl} exists in @file{@trampfn{ssh,host,/home/user}}, valid
2631 @kbd{M-x perldb @key{RET}}
2632 @b{Run perldb (like this):} perl -d myprog.pl @key{RET}
2636 Just the local part of a remote file name, such as @kbd{perl -d
2637 /home/user/myprog.pl}, is not possible.
2639 Arguments of the program to be debugged must be literal, can take
2640 relative or absolute paths, but not remote paths.
2643 @subsection Running remote processes on Windows hosts
2647 @command{winexe} runs processes on a remote Windows host, and
2648 @value{tramp} can use it for @code{process-file} and
2649 @code{start-file-process}.
2651 @code{tramp-smb-winexe-program} specifies the local @command{winexe}
2652 command. Powershell V2.0 on the remote host is required to run
2653 processes triggered from @value{tramp}.
2655 @option{explicit-shell-file-name} and @option{explicit-*-args} have to
2656 be set properly so @kbd{M-x shell} can open a proper remote shell on a
2657 Windows host. To open @command{cmd}, set it as follows:
2661 (setq explicit-shell-file-name "cmd"
2662 explicit-cmd-args '("/q"))
2667 To open @command{powershell} as a remote shell, use this:
2671 (setq explicit-shell-file-name "powershell"
2672 explicit-powershell-args '("-file" "-"))
2677 @node Cleanup remote connections
2678 @section Cleanup remote connections
2681 @value{tramp} provides several ways to flush remote connections.
2683 @deffn Command tramp-cleanup-connection vec
2684 This command flushes all connection related objects. @option{vec} is
2685 the internal representation of a remote connection. When called
2686 interactively, this command lists active remote connections in the
2687 minibuffer. Each connection is of the format
2688 @file{@trampfn{method,user@@host,}}. Flushing remote connections also
2689 cleans the password cache (@pxref{Password handling}), file cache,
2690 connection cache (@pxref{Connection caching}), and connection buffers.
2693 @deffn Command tramp-cleanup-this-connection
2694 Flushes only the current buffer's remote connection objects, the same
2695 as in @code{tramp-cleanup-connection}.
2698 @deffn Command tramp-cleanup-all-connections
2699 Flushes all active remote connection objects, the same as in
2700 @code{tramp-cleanup-connection}.
2703 @deffn Command tramp-cleanup-all-buffers
2704 Just as for @code{tramp-cleanup-all-connections}, all remote
2705 connections are cleaned up in addition to killing buffers related to
2706 that remote connection.
2711 @chapter Reporting Bugs and Problems
2714 @value{tramp}'s development team is actively engaged in solving bugs
2715 and problems and looks to feature requests and suggestions.
2717 @value{tramp}'s mailing list is the place for more advice and
2718 information on working with @value{tramp}, solving problems,
2719 discussing, and general discussions about @value{tramp}.
2721 @value{tramp}'s mailing list is moderated but even non-subscribers can
2722 post for moderator approval. Sometimes this approval step may take as
2723 long as 48 hours due to public holidays.
2725 @email{tramp-devel@@gnu.org} is the mailing list. Messages sent to
2726 this address go to all the subscribers. This is @emph{not} the
2727 address to send subscription requests to.
2729 To subscribe to the mailing list, visit:
2730 @uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/, the
2731 @value{tramp} Mail Subscription Page}.
2733 @ifset installchapter
2734 Before sending a bug report, run the test suite first @ref{Testing}.
2738 Check if the bug or problem is already addressed in @xref{Frequently
2741 Run @kbd{M-x tramp-bug} to generate a buffer with details of the
2742 system along with the details of the @value{tramp}
2743 installation. Please include these details with the bug report.
2745 The bug report must describe in as excruciating detail as possible the
2746 steps required to reproduce the problem. These details must include
2747 the setup of the remote host and any special or unique conditions that
2750 Include a minimal test case that reproduces the problem. This will
2751 help the development team find the best solution and avoid unrelated
2754 To exclude cache-related problems, flush all caches before running the
2755 test, @ref{Cleanup remote connections}.
2757 When including @value{tramp}'s messages in the bug report, increase
2758 the verbosity level to 6 (@pxref{Traces and Profiles, Traces}) in the
2759 @file{~/.emacs} file before repeating steps to the bug. Include the
2760 contents of the @file{*tramp/foo*} and @file{*debug tramp/foo*}
2761 buffers with the bug report.
2763 @strong{Note} that a verbosity level greater than 6 is not necessary
2764 at this stage. Also note that a verbosity level of 6 or greater, the
2765 contents of files and directories will be included in the debug
2766 buffer. Passwords typed in @value{tramp} will never be included
2770 @node Frequently Asked Questions
2771 @chapter Frequently Asked Questions
2772 @cindex frequently asked questions
2777 Where is the latest @value{tramp}?
2779 @value{tramp} is available at the GNU URL:
2782 @uref{ftp://ftp.gnu.org/gnu/tramp/}
2785 @value{tramp}'s GNU project page is located here:
2788 @uref{http://savannah.gnu.org/projects/tramp/}
2792 Which systems does it work on?
2794 The package works successfully on Emacs 23, Emacs 24, and Emacs 25.
2796 While Unix and Unix-like systems are the primary remote targets,
2797 @value{tramp} has equal success connecting to other platforms, such as
2798 MS Windows XP/Vista/7.
2802 How to speed up @value{tramp}?
2804 @value{tramp} does many things in the background, some of which
2805 depends on network speeds, response speeds of remote hosts, and
2806 authentication delays. During these operations, @value{tramp}'s
2807 responsiveness slows down. Some suggestions within the scope of
2808 @value{tramp}'s settings include:
2810 Use an external method, such as @option{scp}, which are faster than
2813 Keep the file @option{tramp-persistency-file-name}, which is where
2814 @value{tramp} caches remote information about hosts and files. Caching
2815 is enabled by default. Don't disable it.
2817 Set @code{remote-file-name-inhibit-cache} to @code{nil} if remote
2818 files are not independently updated outside @value{tramp}'s control.
2819 That cache cleanup will be necessary if the remote directories or
2820 files are updated independent of @value{tramp}.
2822 Set @option{tramp-completion-reread-directory-timeout} to @code{nil} to
2823 speed up completions, @ref{File name completion}.
2825 Disable version control to avoid delays:
2829 (setq vc-ignore-dir-regexp
2830 (format "\\(%s\\)\\|\\(%s\\)"
2831 vc-ignore-dir-regexp
2832 tramp-file-name-regexp))
2836 Disable excessive traces. Set @code{tramp-verbose} to 3 or lower,
2837 default being 3. Increase trace levels temporarily when hunting for
2841 @value{tramp} does not connect to the remote host
2843 Three main reasons for why @value{tramp} does not connect to the remote host:
2847 Unknown characters in the prompt
2849 @value{tramp} needs a clean recognizable prompt on the remote host for
2850 accurate parsing. Shell prompts that contain escape sequences for
2851 coloring cause parsing problems. @ref{Remote shell setup} for
2852 customizing prompt detection using regular expressions.
2854 To check if the remote host's prompt is being recognized, use this
2855 test: switch to @value{tramp} connection buffer @file{*tramp/foo*},
2856 put the cursor at the top of the buffer, and then apply the following
2860 @kbd{M-: (re-search-forward (concat tramp-shell-prompt-pattern "$"))}
2863 If the cursor has not moved to the prompt at the bottom of the buffer,
2864 then @value{tramp} has failed to recognize the prompt.
2866 When using zsh on remote hosts, disable zsh line editor because zsh
2867 uses left-hand side and right-hand side prompts in parallel. Add the
2868 following line to @file{~/.zshrc}:
2871 [ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
2874 When using fish shell on remote hosts, disable fancy formatting by
2875 adding the following to @file{~/.config/fish/config.fish}:
2879 function fish_prompt
2880 if test $TERM = "dumb"
2889 When using WinSSHD on remote hosts, @value{tramp} does not recognize
2890 the strange prompt settings.
2892 A similar problem exist with the iTerm2 shell integration, which sends
2893 proprietary escape codes when starting a shell. This can be
2894 suppressed by changing the respective integration snippet in your
2895 @file{~/.profile} like this:
2899 [ $TERM = "dumb" ] || \
2900 test -e "$@{HOME@}/.iterm2_shell_integration.bash" && \
2901 source "$@{HOME@}/.iterm2_shell_integration.bash"
2906 Echoed characters after login
2908 @value{tramp} suppresses echos from remote hosts with the
2909 @command{stty -echo} command. But sometimes it is too late to suppress
2910 welcome messages from the remote host containing harmful control
2911 characters. Using @option{sshx} or @option{scpx} methods can avoid
2912 this problem because they allocate a pseudo tty. @xref{Inline
2916 @value{tramp} stops transferring strings longer than 500 characters
2918 Set @code{tramp-chunksize} to 500 to get around this problem, which is
2919 related to faulty implementation of @code{process-send-string} on
2920 HP-UX, FreeBSD and Tru64 Unix systems. Consult the documentation for
2921 @code{tramp-chunksize} to see when this is necessary.
2923 Set @code{file-precious-flag} to @code{t} for files accessed by
2924 @value{tramp} so the file contents are checked using checksum by
2925 first saving to a temporary file.
2927 @pxref{Saving Buffers, , , elisp}
2935 (when (file-remote-p default-directory)
2936 (set (make-local-variable 'file-precious-flag) t))))
2943 @value{tramp} does not recognize if a @command{ssh} session hangs
2945 @command{ssh} sessions on the local host hang when the network is
2946 down. @value{tramp} cannot safely detect such hangs. The network
2947 configuration for @command{ssh} can be configured to kill such hangs
2948 with the following command in the @file{~/.ssh/config}:
2953 ServerAliveInterval 5
2959 @value{tramp} does not use default @command{ssh} @code{ControlPath}
2961 @value{tramp} overwrites @code{ControlPath} settings when initiating
2962 @command{ssh} sessions. @value{tramp} does this to fend off a stall
2963 if a master session opened outside the Emacs session is no longer
2964 open. That is why @value{tramp} prompts for the password again even
2965 if there is an @command{ssh} already open.
2967 @vindex tramp-ssh-controlmaster-options
2968 Some @command{ssh} versions support a @code{ControlPersist} option,
2969 which allows you to set the @code{ControlPath} provided the variable
2970 @code{tramp-ssh-controlmaster-options} is customized as follows:
2974 (setq tramp-ssh-controlmaster-options
2976 "-o ControlPath=/tmp/ssh-ControlPath-%%r@@%%h:%%p "
2977 "-o ControlMaster=auto -o ControlPersist=yes"))
2981 Note how "%r", "%h" and "%p" must be encoded as "%%r", "%%h" and
2984 @vindex tramp-use-ssh-controlmaster-options
2985 If the @file{~/.ssh/config} is configured appropriately for the above
2986 behavior, then any changes to @command{ssh} can be suppressed with
2987 this @code{nil} setting:
2991 (custom-set-variables
2992 '(tramp-use-ssh-controlmaster-options nil nil (tramp)))
2998 File name completion does not work with @value{tramp}
3000 @acronym{ANSI} escape sequences from the remote shell may cause errors
3001 in @value{tramp}'s parsing of remote buffers.
3003 To test if this is the case, open a remote shell and check if the output
3004 of @command{ls} is in color.
3006 To disable @acronym{ANSI} escape sequences from the remote hosts,
3007 disable @samp{--color=yes} or @samp{--color=auto} in the remote host's
3008 @file{.bashrc} or @file{.profile}. Turn this alias on and off to see
3009 if file name completion works.
3012 File name completion does not work in directories with large number of
3015 This may be related to globbing, which is the use of shell's ability
3016 to expand wild card specifications, such as @samp{*.c}. For
3017 directories with large number of files, globbing might exceed the
3018 shell's limit on length of command lines and hang. @value{tramp} uses
3021 To test if globbing hangs, open a shell on the remote host and then
3022 run @command{ls -d * ..?* > /dev/null}.
3024 When testing, ensure the remote shell is the same shell
3025 (@command{/bin/sh}, @command{ksh} or @command{bash}), that
3026 @value{tramp} uses when connecting to that host.
3030 How to get notified after @value{tramp} completes file transfers?
3032 Make Emacs beep after reading from or writing to the remote host with
3033 the following code in @file{~/.emacs} file.
3037 (defadvice tramp-handle-write-region
3038 (after tramp-write-beep-advice activate)
3039 "Make tramp beep after writing a file."
3045 (defadvice tramp-handle-do-copy-or-rename-file
3046 (after tramp-copy-beep-advice activate)
3047 "Make tramp beep after copying a file."
3053 (defadvice tramp-handle-insert-file-contents
3054 (after tramp-insert-beep-advice activate)
3055 "Make tramp beep after inserting a file."
3063 How to get a Visual Warning when working with @samp{root} privileges?
3064 Host indication in the mode line?
3066 Install @file{tramp-theme} from GNU ELPA via Emacs' Package Manager.
3067 Enable it via @kbd{M-x load-theme @key{RET} tramp}. Further
3068 customization is explained in user option
3069 @option{tramp-theme-face-remapping-alist}.
3073 Remote host does not understand default options for directory listing
3075 Emacs computes the @command{dired} options based on the local host but
3076 if the remote host cannot understand the same @command{ls} command,
3077 then set them with a hook as follows:
3082 'dired-before-readin-hook
3084 (when (file-remote-p default-directory)
3085 (setq dired-actual-switches "-al"))))
3091 Why is @file{~/.sh_history} file on the remote host growing?
3093 Due to @command{ksh} saving tilde expansions triggered by
3094 @value{tramp}, the history file is probably growing rapidly. To fix,
3095 turn off saving history by putting this shell code in the
3100 if [ -f $HOME/.sh_history ] ; then
3101 /bin/rm $HOME/.sh_history
3103 if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
3106 if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
3112 For @option{ssh}-based method, add the following line to your
3113 @file{~/.ssh/environment} file:
3121 How to shorten long file names when typing in @value{tramp}?
3123 Adapt several of these approaches to reduce typing. If the full name
3124 is @file{@trampfn{ssh,news@@news.my.domain,/opt/news/etc}}, then:
3129 Use default values for method name and user name:
3131 You can define default methods and user names for hosts,
3132 (@pxref{Default Method}, @pxref{Default User}):
3136 (custom-set-variables
3137 '(tramp-default-method "ssh" nil (tramp))
3138 '(tramp-default-user "news" nil (tramp)))
3142 The reduced typing: @kbd{C-x C-f @trampf{news.my.domain,/opt/news/etc}}.
3144 @strong{Note} that there are some useful shortcuts already. Accessing
3145 your local host as @samp{root} user, is possible just by @kbd{C-x C-f
3149 Use configuration options of the access method:
3151 Programs used for access methods already offer powerful configurations
3152 (@pxref{Customizing Completion}). For @option{ssh}, configure the
3153 file @file{~/.ssh/config}:
3158 HostName news.my.domain
3163 The reduced typing: @kbd{C-x C-f @trampfn{ssh,xy,/opt/news/etc}}.
3165 Depending on the number of files in the directories, host names
3166 completion can further reduce key strokes: @kbd{C-x C-f
3167 @value{prefix}ssh@value{postfixhop}x @key{TAB}}.
3170 Use environment variables to expand long strings
3172 For long file names, set up environment variables that are expanded in
3173 the minibuffer. Environment variables are set either outside Emacs or
3174 inside Emacs with Lisp:
3177 (setenv "xy" "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}")
3180 The reduced typing: @kbd{C-x C-f $xy @key{RET}}.
3182 @strong{Note} that file name cannot be edited here because the
3183 environment variables are not expanded during editing in the
3186 @item Define own keys:
3188 Redefine another key sequence in Emacs for @kbd{C-x C-f}:
3193 [(control x) (control y)]
3199 "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))))
3203 Simply typing @kbd{C-x C-y} would prepare minibuffer editing of file
3206 See @uref{https://www.emacswiki.org/emacs/TrampMode, the Emacs Wiki}
3207 for a more comprehensive example.
3210 Define own abbreviation (1):
3212 Abbreviation list expansion can be used to reduce typing long file names:
3217 'directory-abbrev-alist
3218 '("^/xy" . "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))
3222 The reduced typing: @kbd{C-x C-f /xy @key{RET}}.
3224 @strong{Note} that file name cannot be edited here because the
3225 environment variables are not expanded during editing in the
3229 Define own abbreviation (2):
3231 The @code{abbrev-mode} gives additional flexibility for editing in the
3236 (define-abbrev-table 'my-tramp-abbrev-table
3237 '(("xy" "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}")))
3242 'minibuffer-setup-hook
3245 (setq local-abbrev-table my-tramp-abbrev-table)))
3249 (defadvice minibuffer-complete
3250 (before my-minibuffer-complete activate)
3255 ;; If you use partial-completion-mode
3256 (defadvice PC-do-completion
3257 (before my-PC-do-completion activate)
3262 The reduced typing: @kbd{C-x C-f xy @key{TAB}}.
3264 The minibuffer expands for further editing.
3266 @item Use bookmarks:
3268 Use bookmarks to save Tramp file names.
3270 @pxref{Bookmarks, , , emacs}.
3273 Upon visiting a location with @value{tramp}, save it as a bookmark with
3274 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{set}}.
3276 To revisit that bookmark:
3277 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{jump}}.
3279 @item Use recent files:
3281 @file{recentf} remembers visited places.
3283 @pxref{File Conveniences, , , emacs}.
3286 Keep remote file names in the recent list without have to check for
3287 their accessibility through remote access:
3293 Reaching recently opened files: @kbd{@key{menu-bar} @key{file}
3296 @item Use filecache:
3298 Since @file{filecache} remembers visited places, add the remote
3299 directory to the cache:
3303 @c `with-eval-after-load' has been introduced with Emacs 24.4. Shall
3304 @c be used when appropriate.
3305 (eval-after-load "filecache"
3306 '(file-cache-add-directory
3307 "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))
3311 Then use directory completion in the minibuffer with @kbd{C-x C-f
3316 @file{bbdb} has a built-in feature for Ange FTP files, which also
3317 works for @value{tramp} file names.
3319 @pxref{bbdb-ftp, Storing FTP sites in the BBDB, , bbdb}.
3322 Load @file{bbdb} in Emacs:
3331 Create a BBDB entry with @kbd{M-x bbdb-create-ftp-site}. Then specify
3332 a method and user name where needed. Examples:
3336 @kbd{M-x bbdb-create-ftp-site @key{RET}}
3337 @b{Ftp Site:} news.my.domain @key{RET}
3338 @b{Ftp Directory:} /opt/news/etc/ @key{RET}
3339 @b{Ftp Username:} ssh@value{postfixhop}news @key{RET}
3340 @b{Company:} @key{RET}
3341 @b{Additional Comments:} @key{RET}
3345 In BBDB buffer, access an entry by pressing the key @key{F}.
3349 Thanks to @value{tramp} users for contributing to these recipes.
3352 Why saved multi-hop file names do not work in a new Emacs session?
3354 When saving ad-hoc multi-hop @value{tramp} file names (@pxref{Ad-hoc
3355 multi-hops}) via bookmarks, recent files, filecache, bbdb, or another
3356 package, use the full ad-hoc file name including all hops, like
3357 @file{@trampfn{ssh,bird@@bastion|ssh@value{postfixhop}news.my.domain,/opt/news/etc}}.
3359 Alternatively, when saving abbreviated multi-hop file names
3360 @file{@trampfn{ssh,news@@news.my.domain,/opt/news/etc}}, the user
3361 option @option{tramp-save-ad-hoc-proxies} must be set non-@code{nil}
3366 How to connect to a remote Emacs session using @value{tramp}?
3368 Configure Emacs Client
3370 (@pxref{Emacs Server, , , emacs}).
3373 Then on the remote host, start the Emacs Server:
3378 (setq server-host (system-name)
3384 If @code{(system-name)} of the remote host cannot be resolved on the
3385 local host, use IP address instead.
3387 Copy from the remote host the resulting file
3388 @file{~/.emacs.d/server/server} to the local host, to the same
3391 Then start Emacs Client from the command line:
3394 emacsclient @trampfn{ssh,user@@host,/file/to/edit}
3397 @code{user} and @code{host} refer to the local host.
3399 To make Emacs Client an editor for other programs, use a wrapper
3400 script @file{emacsclient.sh}:
3405 emacsclient @trampfn{ssh,$(whoami)@@$(hostname --fqdn),$1}
3409 Then change the environment variable @env{EDITOR} to point to the
3413 export EDITOR=/path/to/emacsclient.sh
3418 How to disable other packages from calling @value{tramp}?
3420 There are packages that call @value{tramp} without the user ever
3421 entering a remote file name. Even without applying a remote file
3422 syntax, some packages enable @value{tramp} on their own. How can users
3423 disable such features.
3429 Disable @value{tramp} file name completion:
3432 (custom-set-variables '(ido-enable-tramp-completion nil))
3438 Disable remote directory tracking mode:
3441 (rlogin-directory-tracking-mode -1)
3447 How to disable @value{tramp}?
3451 To keep Ange FTP as default the remote files access package, set this
3455 (custom-set-variables '(tramp-default-method "ftp" nil (tramp)))
3459 To disable both @value{tramp} (and Ange FTP), set @code{tramp-mode} to
3460 @code{nil} in @file{.emacs}.
3463 (custom-set-variables '(tramp-mode nil nil (tramp)))
3467 To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp}. Unloading
3468 @value{tramp} resets Ange FTP plugins also.
3473 @c For the developer
3474 @node Files directories and localnames
3475 @chapter How file names, directories and localnames are mangled and managed.
3478 * Localname deconstruction:: Splitting a localname into its component parts.
3479 * External packages:: Integrating with external Lisp packages.
3483 @node Localname deconstruction
3484 @section Splitting a localname into its component parts
3486 @value{tramp} package redefines lisp functions
3487 @code{file-name-directory} and @code{file-name-nondirectory} to
3488 accommodate the unique file naming syntax that @value{tramp} requires.
3490 The replacements dissect the file name, use the original handler for
3491 the localname, take that result, and then re-build the @value{tramp}
3492 file name. By relying on the original handlers for localnames,
3493 @value{tramp} benefits from platform specific hacks to the original
3497 @node External packages
3498 @section Integrating with external Lisp packages
3499 @subsection File name completion.
3501 For name completions in the minibuffer, @value{tramp} depends on the
3502 last input character to decide whether to look for method name
3503 completion or host name completion. For example, @kbd{C-x C-f
3504 @value{prefix}ssh@value{postfixhop} @key{TAB}} is not entirely clear
3505 if @option{ssh} is a method or a host name. But if the last input
3506 character was either @key{TAB}, @key{SPACE} or @kbd{?}, then
3507 @value{tramp} favors file name completion over host name completion.
3509 What about external packages using other characters to trigger file
3510 name completions? They must somehow signal this to @value{tramp}. Use
3511 the variable @code{non-essential} temporarily and bind it to
3512 non-@code{nil} value.
3516 (let ((non-essential t))
3522 @subsection File attributes cache.
3524 Keeping a local cache of remote file attributes in sync with the
3525 remote host is a time-consuming operation. Flushing and re-querying
3526 these attributes can tax @value{tramp} to a grinding halt on busy
3529 To get around these types of slow-downs in @value{tramp}'s
3530 responsiveness, set the @code{process-file-side-effects} to @code{nil}
3531 to stop @value{tramp} from flushing the cache. This is helpful in
3532 situations where callers to @code{process-file} know there are no file
3533 attribute changes. The let-bind form to accomplish this:
3537 (let (process-file-side-effects)
3542 For asynchronous processes, @value{tramp} uses a process sentinel to
3543 flush file attributes cache. When callers to @code{start-file-process}
3544 know beforehand no file attribute changes are expected, then the
3545 process sentinel should be set to the default state. In cases where
3546 the caller defines its own process sentinel, @value{tramp}'s process
3547 sentinel is overwritten. The caller can still flush the file
3548 attributes cache in its process sentinel with this code:
3552 (unless (memq (process-status proc) '(run open))
3553 (dired-uncache remote-directory))
3557 Since @value{tramp} traverses subdirectories starting with the
3558 root-directory, it is most likely sufficient to make the
3559 @code{default-directory} of the process buffer as the root directory.
3562 @node Traces and Profiles
3563 @chapter How to Customize Traces
3565 @value{tramp} messages are raised with verbosity levels ranging from 0
3566 to 10. @value{tramp} does not display all messages; only those with a
3567 verbosity level less than or equal to @code{tramp-verbose}.
3569 The verbosity levels are
3571 @w{ 0} silent (no @value{tramp} messages at all)
3572 @*@indent @w{ 1} errors
3573 @*@indent @w{ 2} warnings
3574 @*@indent @w{ 3} connection to remote hosts (default verbosity)
3575 @*@indent @w{ 4} activities
3576 @*@indent @w{ 5} internal
3577 @*@indent @w{ 6} sent and received strings
3578 @*@indent @w{ 7} file caching
3579 @*@indent @w{ 8} connection properties
3580 @*@indent @w{ 9} test commands
3581 @*@indent @w{10} traces (huge)
3583 With @code{tramp-verbose} greater than or equal to 4, messages are
3584 also written to a @value{tramp} debug buffer. Such debug buffers are
3585 essential to bug and problem analyses. For @value{tramp} bug reports,
3586 set the @code{tramp-verbose} level to 6 (@pxref{Bug Reports}).
3588 The debug buffer is in
3590 @ref{Outline Mode, , , emacs}.
3595 In this buffer, messages can be filtered by their level. To see
3596 messages up to verbosity level 5, enter @kbd{C-u 6 C-c C-q}.
3598 Other navigation keys are described in
3599 @ref{Outline Visibility, , , emacs}.
3602 @value{tramp} handles errors internally. But to get a Lisp backtrace,
3603 both the error and the signal have to be set as follows:
3607 (setq debug-on-error t
3612 To enable stepping through @value{tramp} function call traces, they
3613 have to be specifically enabled as shown in this code:
3618 (dolist (elt (all-completions "tramp-" obarray 'functionp))
3619 (trace-function-background (intern elt)))
3620 (untrace-function 'tramp-read-passwd)
3621 (untrace-function 'tramp-gw-basic-authentication)
3625 The buffer @file{*trace-output*} contains the output from the function
3626 call traces. Disable @code{tramp-read-passwd} and
3627 @code{tramp-gw-basic-authentication} to stop password strings from
3628 being written to @file{*trace-output*}.
3631 @node GNU Free Documentation License
3632 @appendix GNU Free Documentation License
3633 @include doclicense.texi
3636 @node Function Index
3637 @unnumbered Function Index
3641 @node Variable Index
3642 @unnumbered Variable Index
3647 @unnumbered Concept Index
3654 @c * Say something about the .login and .profile files of the remote
3656 @c * Explain how tramp.el works in principle: open a shell on a remote
3657 @c host and then send commands to it.
3658 @c * Consistent small or capitalized words especially in menus.
3659 @c * Make a unique declaration of @trampfn.