1 \input texinfo @c -*- mode: texinfo; coding: utf-8 -*-
2 @setfilename ../../info/tramp.info
4 @settitle TRAMP User Manual
8 @c This is *so* much nicer :)
11 @c In the Tramp repository, the version number is auto-frobbed from
12 @c configure.ac, so you should edit that file and run
13 @c "autoconf && ./configure" to change the version number.
15 @c Additionally, flags are set with respect to the Emacs flavor; and
16 @c depending whether Tramp is packaged into (X)Emacs, or standalone.
18 @include trampver.texi
20 @c Macro for formatting a file name according to the respective syntax.
21 @c Macro arguments should not have any leading or
22 @c trailing whitespace. Not very elegant, but I don't know it better.
24 @macro trampfn {method, userhost, localname}
26 \method\@value{postfixhop}@c
27 \userhost\@value{postfix}\localname\
30 @c Similar, but without a method prefix.
32 @macro trampf {userhost, localname}
34 \userhost\@value{postfix}\localname\
38 Copyright @copyright{} 1999--2016 Free Software Foundation, Inc.
41 Permission is granted to copy, distribute and/or modify this document
42 under the terms of the GNU Free Documentation License, Version 1.3 or
43 any later version published by the Free Software Foundation; with no
44 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
45 and with the Back-Cover Texts as in (a) below. A copy of the license
46 is included in the section entitled ``GNU Free Documentation License''.
48 (a) The FSF's Back-Cover Text is: ``You have the freedom to
49 copy and modify this GNU manual.''
53 @c Entries for @command{install-info} to use
54 @dircategory Emacs network features
56 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
57 Emacs remote file access via ssh and scp.
61 @title @value{tramp} version @value{trampver} User Manual
62 @author by Daniel Pittman
63 @author based on documentation by Kai Großjohann
72 @node Top, Overview, (dir), (dir)
73 @top @value{tramp} version @value{trampver} User Manual
75 This file documents @value{tramp} version @value{trampver}, a remote file
76 editing package for Emacs.
78 @value{tramp} stands for ``Transparent Remote (file) Access, Multiple
79 Protocol''. This package provides remote file editing, similar to
82 The difference is that Ange FTP uses FTP to transfer files between the
83 local and the remote host, whereas @value{tramp} uses a combination of
84 @command{rsh} and @command{rcp} or other work-alike programs, such as
85 @command{ssh}/@command{scp}.
87 You can find the latest version of this document on the web at
88 @uref{http://www.gnu.org/software/tramp/}.
91 The latest release of @value{tramp} is available for
92 @uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
93 @ref{Obtaining Tramp} for more details, including the Git server
96 @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
97 Savannah Project Page}.
100 There is a mailing list for @value{tramp}, available at
101 @email{tramp-devel@@gnu.org}, and archived at
102 @uref{http://lists.gnu.org/archive/html/tramp-devel/, the
103 @value{tramp} Mail Archive}.
105 Older archives are located at
106 @uref{http://sourceforge.net/mailarchive/forum.php?forum=tramp-devel,
107 SourceForge Mail Archive} and
108 @uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/,
110 @c in HTML output, there's no new paragraph.
119 * Overview:: What @value{tramp} can and cannot do.
123 * Obtaining Tramp:: How to obtain @value{tramp}.
124 * History:: History of @value{tramp}.
125 @ifset installchapter
126 * Installation:: Installing @value{tramp} with your Emacs.
128 * Configuration:: Configuring @value{tramp} for use.
129 * Usage:: An overview of the operation of @value{tramp}.
130 * Bug Reports:: Reporting Bugs and Problems.
131 * Frequently Asked Questions:: Questions and answers from the mailing list.
135 * Files directories and localnames::
136 How file names, directories and localnames
137 are mangled and managed.
138 * Traces and Profiles:: How to Customize Traces.
140 * GNU Free Documentation License:: The license for this documentation.
141 * Function Index:: @value{tramp} functions.
142 * Variable Index:: User options and variables.
143 * Concept Index:: An item for each concept.
146 --- The Detailed Node Listing ---
148 @ifset installchapter
149 Installing @value{tramp} with your Emacs
151 * Installation parameters:: Parameters in order to control installation.
152 * Load paths:: How to plug-in @value{tramp} into your environment.
156 Configuring @value{tramp} for use
158 * Connection types:: Types of connections to remote hosts.
159 * Inline methods:: Inline methods.
160 * External methods:: External methods.
161 * GVFS based methods:: GVFS based external methods.
162 * Gateway methods:: Gateway methods.
163 * Default Method:: Selecting a default method.
164 * Default User:: Selecting a default user.
165 * Default Host:: Selecting a default host.
166 * Multi-hops:: Connecting to a remote host using multiple hops.
167 * Customizing Methods:: Using Non-Standard Methods.
168 * Customizing Completion:: Selecting config files for user/host name completion.
169 * Password handling:: Reusing passwords for several connections.
170 * Connection caching:: Reusing connection related information.
171 * Predefined connection information::
172 Setting own connection related information.
173 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
174 * Remote shell setup:: Remote shell setup hints.
175 * Android shell setup:: Android shell setup hints.
176 * Auto-save and Backup:: Auto-save and Backup.
177 * Windows setup hints:: Issues with Cygwin ssh.
181 * File name Syntax:: @value{tramp} file name conventions.
182 * File name completion:: File name completion.
183 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
184 * Remote processes:: Integration with other Emacs packages.
185 * Cleanup remote connections:: Cleanup remote connections.
187 How file names, directories and localnames are mangled and managed
189 * Localname deconstruction:: Breaking a localname into its components.
190 * External packages:: Integration with external Lisp packages.
197 @chapter An overview of @value{tramp}
200 @value{tramp} is for transparently accessing remote files from within
201 Emacs. @value{tramp} enables an easy, convenient, and consistent
202 interface to remote files as if they are local files. @value{tramp}'s
203 transparency extends to editing, version control, and @code{dired}.
205 @value{tramp} can access remote hosts using any number of access
206 methods, such as @command{rsh}, @command{rlogin}, @command{telnet},
207 and related programs. If these programs can successfully pass
208 @acronym{ASCII]} characters, @value{tramp} can use them.
209 @value{tramp} does not require or mandate 8-bit clean connections.
211 @value{tramp}'s most common access method is through @command{ssh}, a
212 more secure alternative to @command{ftp} and other older access
215 @value{tramp} on Windows operating systems is integrated with the
216 PuTTY package, and uses the @command{plink} program.
218 @value{tramp} mostly operates transparently in the background using
219 the connection programs. As long as these programs enable remote login
220 and can use the terminal, @value{tramp} can adapt them for seamless
221 and transparent access.
223 @value{tramp} temporarily transfers a remote file's contents to the
224 local host editing and related operations. @value{tramp} can also
225 transfer files between hosts using standard Emacs interfaces, a
226 benefit of direct integration of @value{tramp} in Emacs.
228 @value{tramp} can transfer files using any number of available host
229 programs for remote files, such as @command{rcp}, @command{scp},
230 @command{rsync} or (under Windows) @command{pscp}. @value{tramp}
231 provides easy ways to specify these programs and customize them to
232 specific files, hosts, or access methods.
234 For faster small-size file transfers, @value{tramp} supports encoded
235 transfers directly through the shell using @command{mimencode} or
236 @command{uuencode} provided such tools are available on the remote
240 @subsubheading @value{tramp} behind the scenes
241 @cindex behind the scenes
242 @cindex details of operation
245 Accessing a remote file through @value{tramp} entails a series of
246 actions, many of which are transparent to the user. Yet some actions
247 may require user response (such as entering passwords or completing
248 file names). One typical scenario, opening a file on a remote host, is
249 presented here to illustrate the steps involved:
251 @kbd{C-x C-f} to initiate find-file, enter part of the @value{tramp}
252 file name, then hit @kbd{@key{TAB}} for completion. If this is the
253 first time connection to that host, here's what happens:
257 @value{tramp} invokes @samp{telnet @var{host}} or @samp{rsh @var{host}
258 -l @var{user}} and establishes an external process to connect to the
259 remote host. @value{tramp} communicates with the process through an
260 Emacs buffer, which also shows output from the remote host.
263 The remote host may prompt for a login name (for @command{telnet}, for
264 example) in the buffer. If on the other hand, the login name was
265 included in the file name portion, @value{tramp} sends the login name
266 followed by a newline.
269 The remote host may then prompt for a password or pass phrase (for
270 @command{rsh} or for @command{telnet}). @value{tramp} displays the
271 password prompt in the minibuffer. @value{tramp} then sends whatever
272 is entered to the remote host, followed by a newline.
275 @value{tramp} now waits for either the shell prompt or a failed login
278 If @value{tramp} does not receive any messages within a timeout period
279 (a minute, for example), then @value{tramp} responds with an error
280 message about not finding the remote shell prompt. If any messages
281 from the remote host, @value{tramp} displays them in the buffer.
283 For any @samp{login failed} message from the remote host,
284 @value{tramp} aborts the login attempt, and repeats the login steps
288 Upon successful login and @value{tramp} recognizes the shell prompt
289 from the remote host, @value{tramp} prepares the shell environment by
290 turning off echoing, setting shell prompt, and other housekeeping
293 @strong{Note} that for the remote shell, @value{tramp} invokes
294 @command{/bin/sh}. The remote host must recognize @samp{exec /bin/sh}
295 and execute the appropriate shell. This shell must support Bourne
299 @value{tramp} executes @command{cd} and @command{ls} commands to find
300 which files exist on the remote host. @value{tramp} sometimes uses
301 @command{echo} with globbing. @value{tramp} checks if a file or
302 directory is writable with @command{test}. After each command,
303 @value{tramp} parses the output from the remote host for completing
307 After remote file name completion, @value{tramp} transfers the file
308 contents from the remote host.
310 For inline transfers, @value{tramp} sends a command, such as
311 @samp{mimencode -b /path/to/remote/file}, waits until the output has
312 accumulated in the buffer, decodes that output to produce the file's
315 For external transfers, @value{tramp} sends a command as follows:
317 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
319 @value{tramp} reads the local temporary file @file{/tmp/tramp.4711}
320 into a buffer, and then deletes the temporary file.
323 Edit, modify, change the buffer contents as normal, and then save the
324 buffer wth @kbd{C-x C-s}.
327 @value{tramp} transfers the buffer contents to the remote host in
328 a reverse of the process using the appropriate inline or external
332 I hope this has provided you with a basic overview of what happens
333 behind the scenes when you open a file with @value{tramp}.
337 @node Obtaining Tramp
338 @chapter Obtaining @value{tramp}
339 @cindex obtaining Tramp
341 @value{tramp} is included as part of Emacs (since Emacs version 22.1).
343 @value{tramp} is also freely packaged for download on the Internet at
344 @uref{ftp://ftp.gnu.org/gnu/tramp/}.
346 @value{tramp} development versions are available on Git servers.
347 Development versions contain new and incomplete features.
349 One way to obtain from Git server is to visit the Savannah project
350 page at the following URL and then clicking on the Git link in the
351 navigation bar at the top.
354 @uref{http://savannah.gnu.org/projects/tramp/}
357 Another way is to follow the terminal session below:
360 ] @strong{cd ~/emacs}
361 ] @strong{git clone git://git.savannah.gnu.org/tramp.git}
365 From behind a firewall:
368 ] @strong{git config --global http.proxy http://user:pwd@@proxy.server.com:8080}
369 ] @strong{git clone http://git.savannah.gnu.org/r/tramp.git}
376 ] @strong{git clone login@@git.sv.gnu.org:/srv/git/tramp.git}
380 After one of the above commands, @file{~/emacs/tramp} will
381 containing the latest version of @value{tramp}.
384 To fetch updates from the repository, use git pull:
387 ] @strong{cd ~/emacs/tramp}
392 Run @command{autoconf} as follows to generate an up-to-date
393 @file{configure} script:
396 ] @strong{cd ~/emacs/tramp}
402 @chapter History of @value{tramp}
404 @cindex development history
406 @value{tramp} development started at the end of November 1998 as
407 @file{rssh.el}. It provided only one method of access. It used
408 @command{ssh} for login and @command{scp} to transfer file contents.
409 The name was changed to @file{rcp.el} before it got its preset name
410 @value{tramp}. New methods of remote access were added, so was support
413 April 2000 was the first time when multi-hop methods were added. In
414 July 2002, @value{tramp} unified file names with Ange-FTP@. In July
415 2004, proxy hosts replaced multi-hop methods. Running commands on
416 remote hosts was introduced in December 2005. Support for gateways
419 GVFS integration started in February 2009.
421 Remote commands on Windows hosts since September 2011. Ad-hoc
422 multi-hop methods (with a changed syntax) re-enabled in November 2011.
424 In November 2012, added Juergen Hoetzel's @file{tramp-adb.el}.
427 @c Installation chapter is necessary only in case of standalone
428 @c installation. Text taken from trampinst.texi.
429 @ifset installchapter
430 @include trampinst.texi
435 @chapter Configuring @value{tramp}
436 @cindex configuration
437 @cindex default configuration
439 @value{tramp} is initially configured to use the @command{scp} program
440 to connect to the remote host. Just type @kbd{C-x C-f} and then enter
441 file name @file{@trampf{user@@host,/path/to.file}}. For details,
442 see @xref{Default Method}.
444 For problems related to the behavior of remote shell, see @ref{Remote
445 shell setup} for details.
447 For changing the connection type and file access method from the
448 defaults to one of several other options, see (@pxref{Connection
451 @strong{Note} that some user options and variables described in these
452 examples are not auto loaded by Emacs. All examples require
453 @value{tramp} is installed and loaded:
461 * Connection types:: Types of connections to remote hosts.
462 * Inline methods:: Inline methods.
463 * External methods:: External methods.
464 * GVFS based methods:: GVFS based external methods.
465 * Gateway methods:: Gateway methods.
466 * Default Method:: Selecting a default method.
467 Here we also try to help those who
468 don't have the foggiest which method
470 * Default User:: Selecting a default user.
471 * Default Host:: Selecting a default host.
472 * Multi-hops:: Connecting to a remote host using multiple hops.
473 * Customizing Methods:: Using Non-Standard Methods.
474 * Customizing Completion:: Selecting config files for user/host name completion.
475 * Password handling:: Reusing passwords for several connections.
476 * Connection caching:: Reusing connection related information.
477 * Predefined connection information::
478 Setting own connection related information.
479 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
480 * Remote shell setup:: Remote shell setup hints.
481 * Android shell setup:: Android shell setup hints.
482 * Auto-save and Backup:: Auto-save and Backup.
483 * Windows setup hints:: Issues with Cygwin ssh.
487 @node Connection types
488 @section Types of connections to remote hosts
489 @cindex connection types, overview
491 @dfn{Inline method} and @dfn{external method} are the two basic types
492 of access methods. While they both use the same remote shell access
493 programs, such as @command{rsh}, @command{ssh}, or @command{telnet},
494 they differ in the file access methods. Choosing the right method
495 becomes important for editing files, transferring large files, or
496 operating on a large number of files.
498 @cindex inline methods
499 @cindex external methods
500 @cindex methods, inline
501 @cindex methods, external
503 The performance of the external methods is generally better than that
504 of the inline methods, at least for large files. This is caused by
505 the need to encode and decode the data when transferring inline.
507 The one exception to this rule are the @option{scp}-based access
508 methods. While these methods do see better performance when actually
509 transferring files, the overhead of the cryptographic negotiation at
510 startup may drown out the improvement in file transfer times.
512 External methods should be configured such a way that they don't
513 require a password (with @command{ssh-agent}, or such alike). Modern
514 @command{scp} implementations offer options to reuse existing
515 @command{ssh} connections, which will be enabled by default if
516 available. If it isn't possible, you should consider @ref{Password
517 handling}, otherwise you will be prompted for a password every copy
522 @section Inline methods
523 @cindex inline methods
524 @cindex methods, inline
526 Inline methods use the same login connection to transfer file
527 contents. Inline methods are quick and easy for small files. They
528 depend on the availability of suitable encoding and decoding programs
529 on the remote host. For local source and destination, @value{tramp}
530 may use built-in equivalents of such programs in Emacs.
532 Inline methods can work in situations where an external transfer
533 program is unavailable. Inline methods also work when transferring
534 files between different @emph{user identities} on the same host.
538 @cindex base-64 encoding
540 @value{tramp} checks the remote host for the availability and
541 usability of @command{mimencode} (part of the @command{metamail}
542 package) or @command{uuencode}. @value{tramp} uses the first reliable
543 command it finds. @value{tramp}'s search path can be customized, see
544 @ref{Remote programs}.
546 In case both @command{mimencode} and @command{uuencode} are
547 unavailable, @value{tramp} first transfers a small Perl program to the
548 remote host, and then tries that program for encoding and decoding.
550 To increase transfer speeds for large text files, use compression
551 before encoding. The variable @var{tramp-inline-compress-start-size}
552 specifies the file size for such optimization.
559 @command{rsh} is an option for connecting to hosts within local
560 networks since @command{rsh} is not as secure as other methods.
566 @command{ssh} is a more secure option than others to connect to a
569 @command{ssh} can also take extra parameters as port numbers. For
570 example, a host on port 42 is specified as @file{host#42} (the real
571 host name, a hash sign, then a port number). It is the same as passing
572 @code{-p 42} to the @command{ssh} command.
574 @item @option{telnet}
575 @cindex method telnet
576 @cindex telnet method
578 Connecting to a remote host with @command{telnet} is as insecure
579 as the @option{rsh} method.
585 Instead of connecting to a remote host, @command{su} program allows
586 editing as another user. The host can be either @samp{localhost} or
587 the host returned by the function @command{(system-name)}. See
588 @ref{Multi-hops} for an exception to this behavior.
594 Similar to @option{su} method, @option{sudo} uses @command{sudo}.
595 @command{sudo} must have sufficient rights to start a shell.
601 The @command{sg} program allows editing as different group. The host
602 can be either @samp{localhost} or the host returned by the function
603 @command{(system-name)}. The user name must be specified, but it
604 denotes a group name. See @ref{Multi-hops} for an exception to this
611 Works like @option{ssh} but without the extra authentication prompts.
612 @option{sshx} uses @samp{ssh -t -t @var{host} -l @var{user} /bin/sh}
613 to open a connection with a ``standard'' login shell.
615 @strong{Note} that @option{sshx} does not bypass authentication
616 questions. For example, if the host key of the remote host is not
617 known, @option{sshx} will still ask ``Are you sure you want to
618 continue connecting?''. @value{tramp} cannot handle such questions.
619 Connections will have to be setup where logins can proceed without
622 @option{sshx} is useful for Windows users when @command{ssh} triggers
623 an error about allocating a pseudo tty. This happens due to missing
624 shell prompts that confuses @value{tramp}.
626 @option{sshx} supports the @samp{-p} argument.
628 @item @option{krlogin}
629 @cindex method krlogin
630 @cindex krlogin method
631 @cindex Kerberos (with krlogin method)
633 This method is also similar to @option{ssh}. It uses the
634 @command{krlogin -x} command only for remote host login.
639 @cindex Kerberos (with ksu method)
641 This is another method from the Kerberos suite. It behaves like @option{su}.
647 @option{plink} method is for Windows users with the PuTTY
648 implementation of SSH@. It uses @samp{plink -ssh} to log in to the
651 Check the @samp{Share SSH connections if possible} control for that
654 @option{plink} method supports the @samp{-P} argument.
656 @item @option{plinkx}
657 @cindex method plinkx
658 @cindex plinkx method
660 Another method using PuTTY on Windows with session names instead of
661 host names. @option{plinkx} calls @samp{plink -load @var{session} -t}.
662 User names and port numbers must be defined in the session.
664 Check the @samp{Share SSH connections if possible} control for that
670 @node External methods
671 @section External methods
672 @cindex methods, external
673 @cindex external methods
675 External methods operate over multiple channels, using the remote
676 shell connection for some actions while delegating file transfers to
677 an external transfer program.
679 External methods save on the overhead of encoding and decoding of
682 Since external methods have the overhead of opening a new channel,
683 files smaller than @var{tramp-copy-size-limit} still use inline
687 @item @option{rcp}---@command{rsh} and @command{rcp}
690 @cindex rcp (with rcp method)
691 @cindex rsh (with rcp method)
693 This method uses the @command{rsh} and @command{rcp} commands to
694 connect to the remote host and transfer files. This is the fastest
695 access method available.
697 The alternative method @option{remcp} uses the @command{remsh} and
698 @command{rcp} commands.
700 @item @option{scp}---@command{ssh} and @command{scp}
703 @cindex scp (with scp method)
704 @cindex ssh (with scp method)
706 Using a combination of @command{ssh} to connect and @command{scp} to
707 transfer is the most secure. While the performance is good, it is
708 slower than the inline methods for smaller files. Though there is no
709 overhead of encoding and decoding of the inline methods,
710 @command{scp}'s cryptographic handshake negates those speed gains.
712 @option{ssh}-based methods support @samp{-p} feature for specifying
713 port numbers. For example, @file{host#42} passes @samp{-p 42} in the
714 argument list to @command{ssh}, and @samp{-P 42} in the argument list
717 @item @option{rsync}---@command{ssh} and @command{rsync}
720 @cindex rsync (with rsync method)
721 @cindex ssh (with rsync method)
723 @command{ssh} command to connect in combination with @command{rsync}
724 command to transfer is similar to the @option{scp} method.
726 @command{rsync} performs much better than @command{scp} when
727 transferring files that exist on both hosts. However, this advantage
728 is lost if the file exists only on one side of the connection.
730 This method supports the @samp{-p} argument.
732 @item @option{scpx}---@command{ssh} and @command{scp}
735 @cindex scp (with scpx method)
736 @cindex ssh (with scpx method)
738 @option{scpx} is useful to avoid login shell questions. It is similar
739 in performance to @option{scp}. @option{scpx} uses @samp{ssh -t -t
740 @var{host} -l @var{user} /bin/sh} to open a connection.
742 @option{sshx} is useful for Windows users when @command{ssh} triggers
743 an error about allocating a pseudo tty. This happens due to missing
744 shell prompts that confuses @value{tramp}.
746 This method supports the @samp{-p} argument.
748 @item @option{pscp}---@command{plink} and @command{pscp}
749 @item @option{psftp}---@command{plink} and @command{psftp}
752 @cindex pscp (with pscp method)
753 @cindex plink (with pscp method)
754 @cindex PuTTY (with pscp method)
757 @cindex pscp (with psftp method)
758 @cindex plink (with psftp method)
759 @cindex PuTTY (with psftp method)
761 These methods are similar to @option{scp} or @option{sftp}, but they
762 use the @command{plink} command to connect to the remote host, and
763 they use @command{pscp} or @command{psftp} for transferring the files.
764 These programs are part of PuTTY, an SSH implementation for Windows.
766 Check the @samp{Share SSH connections if possible} control for that
769 These methods support the @samp{-P} argument.
771 @item @option{fcp}---@command{fsh} and @command{fcp}
774 @cindex fsh (with fcp method)
775 @cindex fcp (with fcp method)
777 This method is similar to @option{scp}, but uses @command{fsh} to
778 connect and @command{fcp} to transfer files. @command{fsh/fcp}, a
779 front-end for @command{ssh}, reuse @command{ssh} session by
780 submitting several commands. This avoids the startup overhead due to
781 @command{scp}'s secure connection. Inline methods have similar
784 The command used for this connection is: @samp{fsh @var{host} -l
785 @var{user} /bin/sh -i}
790 @option{fsh} has no inline method since the multiplexing it offers is
791 not useful for @value{tramp}. @command{fsh} connects to remote host
792 and @value{tramp} keeps that one connection open.
794 @item @option{nc}---@command{telnet} and @command{nc}
797 @cindex nc (with nc method)
798 @cindex telnet (with nc method)
800 Using @command{telnet} to connect and @command{nc} to transfer files
801 is sometimes the only combination suitable for accessing routers or
802 NAS hosts. These dumb devices have severely restricted local shells,
803 such as the @command{busybox} and do not host any other encode or
810 When @value{tramp} uses @option{ftp}, it forwards requests to whatever
811 ftp program is specified by Ange FTP. This external program must be
812 capable of servicing requests from @value{tramp}.
814 @item @option{smb}---@command{smbclient}
818 This is another non-native @value{tramp} method. @command{smbclient}
819 connects to any host with SMB/CIFS protocol, such as MS Windows and
820 Samba Servers running on Unixes. Tests show this @value{tramp} method
821 works with MS Windows NT, MS Windows 2000, MS Windows XP, MS Windows
822 Vista, and MS Windows 7.
824 Using @command{smbclient} requires a few tweaks when working with
827 The first directory in the localname must be a share name on the
830 Since smb shares end in the @code{$} character, @value{tramp} must use
831 @code{$$} when specifying those shares to avoid environment variable
834 When @value{tramp} is not specific about the share name or uses the
835 generic remote directory @code{/}, @command{smbclient} returns all
838 Since SMB authentication is based on each SMB share, @value{tramp}
839 prompts for a password even when accessing a different share on the
840 same SMB host. This prompting can be suppressed by @ref{Password
843 To accommodate user name/domain name syntax required by MS Windows
844 authorization, @value{tramp} provides for an extended syntax in
845 @code{user%domain} format (where user is username, @code{%} is the
846 percent symbol, and domain is the windows domain name). An example:
849 @trampfn{smb,daniel%BIZARRE@@melancholia,/daniel$$/.emacs}
852 where user @code{daniel} connects as a domain user to the SMB host
853 @code{melancholia} in the windows domain @code{BIZARRE} to edit
854 @file{.emacs} located in the home directory (share @code{daniel$}).
856 Alternatively, for local WINS users (as opposed to domain users),
857 substitute the domain name with the name of the local host in
858 UPPERCASE as shown here:
861 @trampfn{smb,daniel%MELANCHOLIA@@melancholia,/daniel$$/.emacs}
864 where user @code{daniel} connects as local user to the SMB host
865 @code{melancholia} in the local domain @code{MELANCHOLIA} to edit
866 @file{.emacs} located in the home directory (share @code{daniel$}).
868 The domain name and user name are optional for @command{smbclient}
869 authentication. When user name is not specified, @command{smbclient}
870 uses the anonymous user (without prompting for password). This
871 behavior is unlike other @value{tramp} methods, where local user name
874 @option{smb} method is unavailable if Emacs is run under a local user
875 authentication context in MS Windows. However such users can still
876 access remote files using UNC file names instead of @value{tramp}:
879 //melancholia/daniel$$/.emacs
882 UNC file name specification does not allow to specify a different user
883 name for authentication like the @command{smbclient} can.
889 This method uses Android Debug Bridge program for accessing Android
890 devices. The Android Debug Bridge must be installed locally for
891 @value{tramp} to work. Some GNU/Linux distributions provide Android
892 Debug Bridge as an installation package. Alternatively, the program is
893 installed as part of the Android SDK@. @value{tramp} finds the
894 @command{adb} program either via the @env{PATH} environment variable
895 or the absolute path set in the variable @var{tramp-adb-program}.
897 @value{tramp} connects to Android devices with @option{adb} only when
898 the custom option @option{tramp-adb-connect-if-not-connected} is not
899 @code{nil}. Otherwise, the connection must be established outside
902 @value{tramp} does not require a host name part of the remote file
903 name when a single Android device is connected to @command{adb}.
904 @value{tramp} instead uses @file{@trampfn{adb,,}} as the default
905 name. @command{adb devices} shows available host names.
907 @option{adb} method normally does not need user name to authenticate
908 on the Andriod device because it runs under the @command{adbd}
909 process. But when a user name is specified, however, @value{tramp}
910 applies an @command{su} in the syntax. When authentication does not
911 succeed, especially on un-rooted Android devices, @value{tramp}
912 displays login errors.
914 For Andriod devices connected through TCP/IP, a port number can be
915 specified using @file{device#42} host name syntax or @value{tramp} can
916 use the default value as declared in @command{adb} command. Port
917 numbers are not applicable to Android devices connected through USB@.
923 @node GVFS based methods
924 @section GVFS based external methods
925 @cindex methods, gvfs
926 @cindex gvfs based methods
929 GVFS is the virtual file system for the Gnome Desktop,
930 @uref{http://en.wikipedia.org/wiki/GVFS}. Remote files on GVFS are
931 mounted locally through FUSE and @value{tramp} uses this locally
932 mounted directory internally.
934 Emacs uses the D-Bus mechanism to communicate with GVFS@. Emacs must
935 have the message bus system, D-Bus integration active, @pxref{Top, ,
943 This method is for connecting to remote hosts with the Apple Filing
944 Protocol for accessing files on Mac OS X volumes. @value{tramp} access
945 syntax requires a leading volume (share) name, for example:
946 @file{@trampfn{afp,user@@host,/volume}}.
955 @option{dav} method provides access to WebDAV files and directories
956 based on standard protocols, such as HTTP@. @option{davs} does the same
957 but with SSL encryption. Both methods support the port numbers.
963 OBEX is an FTP-like access protocol for cell phones and similar simple
964 devices. @value{tramp} supports OBEX over Bluetooth.
970 This method uses @command{sftp} in order to securely access remote
971 hosts. @command{sftp} is a more secure option for connecting to hosts
972 that for security reasons refuse @command{ssh} connections.
978 @option{synce} method allows connecting to Windows Mobile devices. It
979 uses GVFS for mounting remote files and directories via FUSE and
980 requires the SYNCE-GVFS plugin.
984 @defopt tramp-gvfs-methods
985 @vindex tramp-gvfs-methods
986 This custom option is a list of external methods for GVFS@. By
987 default, this list includes @option{afp}, @option{dav}, @option{davs},
988 @option{obex}, @option{sftp} and @option{synce}. Other methods to
989 include are: @option{ftp} and @option{smb}.
994 @node Gateway methods
995 @section Gateway methods
996 @cindex methods, gateway
997 @cindex gateway methods
999 Gateway methods are for proxy host declarations (@pxref{Multi-hops})
1000 so as to pass through firewalls and proxy servers. They are not like
1001 the other methods that declare direct connections to a remote host.
1003 A gateway method always comes with a port setting. @value{tramp}
1004 targets the port number with the gateway method
1005 @file{localhost#random_port} from where the firewall or proxy server
1008 Gateway methods support user name and password declarations for
1009 authenticating the corresponding firewall or proxy server. Such
1010 authentication can be passed through only if granted access by system
1014 @item @option{tunnel}
1015 @cindex method tunnel
1016 @cindex tunnel method
1018 This method implements an HTTP tunnel via the @command{CONNECT}
1019 command (conforming to RFC 2616, 2817 specifications). Proxy servers
1020 using HTTP version 1.1 or later protocol support this command.
1022 For authentication, this protocol uses only @option{Basic
1023 Authentication} (see RFC 2617). When no port number is specified, this
1024 protocol defaults to @option{8080}.
1026 @item @option{socks}
1027 @cindex method socks
1028 @cindex socks method
1030 The @option{socks} method connects to SOCKSv5 servers (see RFC 1928)
1031 and supports @option{Username/Password Authentication}.
1033 The default port number for the socks server is @option{1080}, if not
1034 specified otherwise.
1039 @node Default Method
1040 @section Selecting a default method
1041 @cindex default method
1042 @vindex tramp-default-method
1043 @vindex tramp-default-method-alist
1045 Default method is for transferring files. The variable
1046 @code{tramp-default-method} sets it. @value{tramp} uses this variable
1047 to determine the default method for tramp file names that do not have
1051 (setq tramp-default-method "ssh")
1054 Default methods for transferring files can be customized for specific
1055 user and host combinations through the alist variable
1056 @code{tramp-default-method-alist}.
1058 For example, the following two lines specify to use the @option{ssh}
1059 method for all user names matching @samp{john} and the @option{rsync}
1060 method for all host names matching @samp{lily}. The third line
1061 specifies to use the @option{su} method for the user @samp{root} on
1062 the host @samp{localhost}.
1065 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1066 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1067 (add-to-list 'tramp-default-method-alist
1068 '("\\`localhost\\'" "\\`root\\'" "su"))
1072 See the documentation for the variable
1073 @code{tramp-default-method-alist} for details.
1076 External methods performance faster for large files.
1079 @xref{Inline methods}.
1080 @xref{External methods}.
1082 Choosing the access method also depends on the security environment.
1083 For example, @option{rsh} and @option{telnet} methods that use clear
1084 text password transfers are inappropriate for over the Internet
1085 connections. Secure remote connections should use @option{ssh} that
1089 @subsection Which method to use?
1090 @cindex choosing the right method
1092 @value{tramp} provides maximum number of choices for maximum
1093 flexibility. Choosing which method depends on the hosts, clients,
1094 network speeds, and the security context.
1096 Start by using an inline method.
1098 External methods might be more efficient for large files, but most
1099 @value{tramp} users edit small files more often than large files.
1101 Enable compression, @var{tramp-inline-compress-start-size}, for a
1102 performance boost for large files.
1104 Since @command{ssh} has become the most common method of remote host
1105 access and it has the most reasonable security protocols, use
1106 @option{ssh} method. Typical @option{ssh} usage to edit the
1107 @file{/etc/motd} file on the otherhost:
1110 @kbd{C-x C-f @trampfn{ssh,root@@otherhost,/etc/motd} @key{RET}}
1113 If @option{ssh} is unavailable for whatever reason, look for other
1114 obvious options. For Windows, try the @option{plink} method. For
1115 Kerberos, try @option{krlogin}.
1117 For editing local files as @option{su} or @option{sudo} methods, try
1118 the shortened syntax of @samp{root}:
1121 @kbd{C-x C-f @trampfn{su,,/etc/motd} @key{RET}}
1124 For editing large files, @option{scp} is faster than @option{ssh}.
1125 @option{pscp} is faster than @option{plink}. But this speed
1126 improvement is not always true.
1130 @section Selecting a default user
1131 @cindex default user
1132 @vindex tramp-default-user
1133 @vindex tramp-default-user-alist
1135 @value{tramp} file name can omit the user name part since
1136 @value{tramp} substitutes the currently logged-in user name. However
1137 this substitution can be overridden with @code{tramp-default-user}.
1141 (setq tramp-default-user "root")
1144 Instead of a single default user, @code{tramp-default-user-alist}
1145 allows multiple default user values based on access method or host
1146 name combinations. The alist can hold multiple values. For example, to
1147 use the @samp{john} as the default user for the domain
1148 @samp{somewhere.else} only:
1151 (add-to-list 'tramp-default-user-alist
1152 '("ssh" ".*\\.somewhere\\.else\\'" "john"))
1156 See the documentation for the variable @code{tramp-default-user-alist}
1159 A Caution: @value{tramp} will override any default user specified in
1160 the configuration files outside Emacs, such as @file{~/.ssh/config}.
1161 To stop @value{tramp} from applying the default value, set the
1162 corresponding alist entry to nil:
1165 (add-to-list 'tramp-default-user-alist
1166 '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
1169 The last entry in @code{tramp-default-user-alist} should be reserved
1170 for catch-all or most often used login.
1173 (add-to-list 'tramp-default-user-alist
1174 '(nil nil "jonas") t)
1179 @section Selecting a default host
1180 @cindex default host
1181 @vindex tramp-default-host
1182 @vindex tramp-default-host-alist
1184 When host name is omitted, @value{tramp} substitutes the value from
1185 the @code{tramp-default-host} variable. It is initially populated
1186 with the local hostname where Emacs is running. Both the default user
1187 and default host can be overridden as follows:
1190 (setq tramp-default-user "john"
1191 tramp-default-host "target")
1194 With both defaults set, @samp{@trampfn{ssh,,}} will connect
1195 @value{tramp} to John's home directory on target.
1197 @strong{Note} @samp{/::} won't work, because @samp{/:} is the prefix
1198 for quoted file names.
1200 Instead of a single default host, @code{tramp-default-host-alist}
1201 allows multiple default host values based on access method or user
1202 name combinations. The alist can hold multiple values. While
1203 @code{tramp-default-host} is sufficient in most cases, some methods,
1204 like @option{adb}, require defaults overwritten.
1207 See the documentation for the variable @code{tramp-default-host-alist}
1212 @section Connecting to a remote host using multiple hops
1216 Multi-hops are methods to reach hosts behind firewalls or to reach the
1217 outside world from inside a bastion host. With multi-hops,
1218 @value{tramp} can negotiate these hops with the appropriate user/host
1219 authentication at each hop. All methods until now have been the single
1220 hop kind, where the start and end points of the connection did not
1221 have intermediate check points.
1223 @defopt tramp-default-proxies-alist
1224 @vindex tramp-default-proxies-alist
1225 @option{tramp-default-proxies-alist} specifies proxy hosts to pass
1226 through. This variable is list of triples consisting of (@var{host}
1227 @var{user} @var{proxy}).
1229 The first match is the proxy host through which passes the file name
1230 and the target host matching @var{user}@@@var{host}. @var{host} and
1231 @var{user} are regular expressions or @code{nil}, interpreted as a
1232 regular expression which always matches.
1234 @var{proxy} is a literal @value{tramp} file name whose local name part
1235 is ignored, and the method and user name parts are optional.
1237 The method must be an inline or gateway method (@pxref{Inline
1238 methods}, @pxref{Gateway methods}).
1239 If @var{proxy} is @code{nil}, no additional hop is required reaching
1240 @var{user}@@@var{host}.
1242 For example, to pass through the host @samp{bastion.your.domain} as
1243 user @samp{bird} to reach remote hosts outside the local domain:
1246 (add-to-list 'tramp-default-proxies-alist
1247 '("\\." nil "@trampfn{ssh,bird@@bastion.your.domain,}"))
1248 (add-to-list 'tramp-default-proxies-alist
1249 '("\\.your\\.domain\\'" nil nil))
1252 @strong{Note}: @code{add-to-list} adds elements at the beginning of a
1253 list. Therefore, most relevant rules must come last in the list.
1255 Proxy hosts can be cascaded in the alist. If there is another host
1256 called @samp{jump.your.domain}, which is the only host allowed to
1257 connect to @samp{bastion.your.domain}, then:
1260 (add-to-list 'tramp-default-proxies-alist
1261 '("\\`bastion\\.your\\.domain\\'"
1263 "@trampfn{ssh,jump.your.domain,}"))
1266 @var{proxy} can take patterns @code{%h} or @code{%u} for @var{host} or
1267 @var{user} respectively.
1269 To login as @samp{root} on remote hosts in the domain
1270 @samp{your.domain}, but login as @samp{root} is disabled for non-local
1271 access, then use this alist entry:
1274 (add-to-list 'tramp-default-proxies-alist
1275 '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh,%h,}"))
1278 Opening @file{@trampfn{sudo,randomhost.your.domain,}} first
1279 connects to @samp{randomhost.your.domain} via @code{ssh} under your
1280 account name, and then perform @code{sudo -u root} on that host.
1282 It is key for the sudo method in the above example to be applied on
1283 the host after reaching it and not on the local host.
1285 @var{host}, @var{user} and @var{proxy} can also take Lisp forms. These
1286 forms when evaluated must return either a string or @code{nil}.
1288 To generalize (from the previous example): For all hosts, except my
1289 local one, first connect via @command{ssh}, and then apply
1290 @command{sudo -u root}:
1293 (add-to-list 'tramp-default-proxies-alist
1294 '(nil "\\`root\\'" "@trampfn{ssh,%h,}"))
1295 (add-to-list 'tramp-default-proxies-alist
1296 '((regexp-quote (system-name)) nil nil))
1299 The above configuration allows @value{tramp} connection as @samp{root}
1300 to remote Ubuntu hosts.
1302 @code{tramp-default-proxies-alist} is also used for passing through
1303 firewalls or proxy servers.
1305 For example, the local host @samp{proxy.your.domain} on port 3128
1306 serves as HTTP proxy to the outer world. User has access rights to
1307 another proxy server on @samp{host.other.domain}.@footnote{HTTP tunnels
1308 are intended for secure SSL/TLS communication. Therefore, many proxy
1309 servers restrict the tunnels to related target ports. You might need
1310 to run your ssh server on your target host @samp{host.other.domain} on
1311 such a port, like 443 (https). See
1312 @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall} for
1313 discussion of ethical issues.} Then the configuration is:
1316 (add-to-list 'tramp-default-proxies-alist
1317 '("\\`host\\.other\\.domain\\'" nil
1318 "@trampfn{tunnel,proxy.your.domain#3128,}"))
1321 Gateway methods in a multiple hop chain can be declared only as the first hop.
1324 Passing through hops involves dealing with restricted shells, such as
1325 @command{rbash}. If @value{tramp} is made aware, then it would use
1326 them for proxies only.
1328 @defopt tramp-restricted-shell-hosts-alist
1329 @vindex tramp-restricted-shell-hosts-alist
1330 An alist of regular expressions of hosts running restricted shells,
1331 such as @command{rbash}. @value{tramp} will then use them only as
1334 To specify the bastion host from the example above as running a
1338 (add-to-list 'tramp-restricted-shell-hosts-alist
1339 "\\`bastion\\.your\\.domain\\'")
1344 @node Customizing Methods
1345 @section Using Non-Standard Methods
1346 @cindex customizing methods
1347 @cindex using non-standard methods
1348 @cindex create your own methods
1350 The @code{tramp-methods} variable currently has an exhaustive list of
1351 predefined methods. Any part of this list can be modified with more
1352 suitable settings. Refer to the Lisp documentation of that variable,
1353 accessible with @kbd{C-h v tramp-methods @key{RET}}.
1356 @node Customizing Completion
1357 @section Selecting config files for user/host name completion
1358 @cindex customizing completion
1359 @cindex selecting config files
1360 @vindex tramp-completion-function-alist
1362 @code{tramp-completion-function-alist} uses predefined files for user
1363 and host name completion (@pxref{File name completion}). For each
1364 method, it keeps a set of configuration files and a function that can
1365 parse that file. Each entry in @code{tramp-completion-function-alist}
1366 is of the form (@var{method} @var{pair1} @var{pair2} @dots{}).
1368 Each @var{pair} is composed of (@var{function} @var{file}).
1369 @var{function} is responsible for extracting user names and host names
1370 from @var{file} for completion. There are two functions which access
1373 @defun tramp-get-completion-function method
1374 This function returns the list of completion functions for @var{method}.
1378 (tramp-get-completion-function "rsh")
1380 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1381 (tramp-parse-rhosts "~/.rhosts"))
1385 @defun tramp-set-completion-function method function-list
1386 This function sets @var{function-list} as list of completion functions
1391 (tramp-set-completion-function "ssh"
1392 '((tramp-parse-sconfig "/etc/ssh_config")
1393 (tramp-parse-sconfig "~/.ssh/config")))
1395 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1396 (tramp-parse-sconfig "~/.ssh/config"))
1400 The following predefined functions parsing configuration files exist:
1403 @item @code{tramp-parse-rhosts}
1404 @findex tramp-parse-rhosts
1406 This function parses files which are syntactical equivalent to
1407 @file{~/.rhosts}. It returns both host names and user names, if
1410 @item @code{tramp-parse-shosts}
1411 @findex tramp-parse-shosts
1413 This function parses files which are syntactical equivalent to
1414 @file{~/.ssh/known_hosts}. Since there are no user names specified
1415 in such files, it can return host names only.
1417 @item @code{tramp-parse-sconfig}
1418 @findex tramp-parse-shosts
1420 This function returns the host nicknames defined by @code{Host} entries
1421 in @file{~/.ssh/config} style files.
1423 @item @code{tramp-parse-shostkeys}
1424 @findex tramp-parse-shostkeys
1426 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1427 @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1428 @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1429 are always @code{nil}.
1431 @item @code{tramp-parse-sknownhosts}
1432 @findex tramp-parse-shostkeys
1434 Another SSH2 style parsing of directories like
1435 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1436 case, hosts names are coded in file names
1437 @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1439 @item @code{tramp-parse-hosts}
1440 @findex tramp-parse-hosts
1442 A function dedicated to @file{/etc/hosts} for host names.
1444 @item @code{tramp-parse-passwd}
1445 @findex tramp-parse-passwd
1447 A function which parses @file{/etc/passwd} files for user names.
1449 @item @code{tramp-parse-etc-group}
1450 @findex tramp-parse-etc-group
1452 A function which parses @file{/etc/group} files for group names.
1454 @item @code{tramp-parse-netrc}
1455 @findex tramp-parse-netrc
1457 A function which parses @file{~/.netrc} and @file{~/.authinfo}-style files.
1461 To keep a custom file with custom data in a custom structure, a custom
1462 function has to be provided. This function must meet the following
1465 @defun my-tramp-parse file
1466 @var{file} must be either a file on the host, or @code{nil}. The
1467 function must return a list of (@var{user} @var{host}), which are
1468 taken as candidates for completion for user and host names.
1472 (my-tramp-parse "~/.my-tramp-hosts")
1474 @result{} ((nil "toto") ("daniel" "melancholia"))
1479 @node Password handling
1480 @section Reusing passwords for several connections
1483 To avoid repeated prompts for passwords, consider native caching
1484 mechanisms, such as @command{ssh-agent} for @option{ssh}-like
1485 methods, or @command{pageant} for @option{plink}-like methods.
1487 @value{tramp} offers alternatives when native solutions cannot meet
1491 @anchor{Using an authentication file}
1492 @subsection Using an authentication file
1493 @vindex auth-sources
1495 The package @file{auth-source.el}, originally developed for No Gnus,
1496 reads passwords from different sources, @xref{Help for users, ,
1497 auth-source, auth}. The default authentication file is
1498 @file{~/.authinfo.gpg}, but this can be changed via the variable
1499 @code{auth-sources}.
1502 A typical entry in the authentication file:
1505 machine melancholia port scp login daniel password geheim
1508 The port can take any @value{tramp} method (@pxref{Inline methods},
1509 @pxref{External methods}). Omitting port values matches all
1510 @value{tramp} methods.
1512 Setting @code{auth-source-debug} to @code{t} to debug messages.
1515 @anchor{Caching passwords}
1516 @subsection Caching passwords
1518 @value{tramp} can cache passwords as entered and reuse when needed for
1519 the same user or host name independent of the access method.
1521 @vindex password-cache-expiry
1523 @code{password-cache-expiry} sets the duration (in seconds) the
1524 passwords are remembered. Passwords are never saved permanently nor
1525 can they extend beyond the lifetime of the current Emacs session. Set
1526 @code{password-cache-expiry} to @code{nil} to disable expiration.
1528 @vindex password-cache
1530 Set @code{password-cache} to @code{nil} to disable password caching.
1532 @strong{Implementation Note}: password caching depends on
1533 @file{password-cache.el} package. @value{tramp} activates password
1534 caching only if @value{tramp} can discover, while Emacs is loading,
1535 the package through @code{load-path}.
1537 @ifset installchapter
1538 @file{password.el} is available from No Gnus or from the @value{tramp}
1539 @file{contrib} directory, see @ref{Installation parameters}.
1543 @node Connection caching
1544 @section Reusing connection related information
1546 @vindex tramp-persistency-file-name
1548 For faster initial connection times, @value{tramp} stores previous
1549 connection properties in a file specified by the variable
1550 @code{tramp-persistency-file-name}.
1552 The default file name for @code{tramp-persistency-file-name} is
1553 @file{~/.emacs.d/tramp}.
1555 @value{tramp} reads this file during Emacs startup, and writes to it
1556 when exiting Emacs. Delete this file for @value{tramp} to recreate a
1557 new one on next Emacs startup.
1559 Set @code{tramp-persistency-file-name} to @code{nil} to disable
1560 storing connections persistently.
1562 To reuse connection information from the persistent list,
1563 @value{tramp} needs to uniquely identify every host. However in some
1564 cases, two different connections may result in the same persistent
1565 information. For example, connecting to a host using @command{ssh} and
1566 connecting to the same host through @code{sshd} on port 3001. Both
1567 access methods result in nearly identical persistent specifications
1568 @file{@trampfn{ssh,localhost,}} and @file{@trampfn{ssh,localhost#3001,}}.
1570 Changing host names could avoid duplicates. One way is to add a
1571 @option{Host} section in @file{~/.ssh/config} (@pxref{Frequently Asked
1572 Questions}). Another way is to apply multiple hops (@pxref{Multi-hops}).
1574 When @value{tramp} detects a change in the operating system version in
1575 a remote host (via the command @command{uname -sr}), it flushes all
1576 connection related information for that host and creates a new entry.
1579 @node Predefined connection information
1580 @section Setting own connection related information
1581 @vindex tramp-connection-properties
1583 For more precise customization, parameters specified by
1584 @code{tramp-methods} can be overwritten manually.
1586 Set @code{tramp-connection-properties} to manually override
1587 @code{tramp-methods}. Properties in this list are in the form
1588 @code{(@var{regexp} @var{property} @var{value})}. @var{regexp} matches
1589 remote file names. Use @code{nil} to match all. @var{property} is the
1590 property's name, and @var{value} is the property's value.
1592 @var{property} is any method specific parameter contained in
1593 @code{tramp-methods}. The parameter key in @code{tramp-methods} is a
1594 symbol name @code{tramp-<foo>}. To overwrite that property, use the
1595 string @samp{<foo>} for @var{property}. For example, this changes the
1599 (add-to-list 'tramp-connection-properties
1600 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1601 "remote-shell" "/bin/ksh"))
1602 (add-to-list 'tramp-connection-properties
1603 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1604 "remote-shell-login" '("-")))
1607 The parameters @code{tramp-remote-shell} and
1608 @code{tramp-remote-shell-login} in @code{tramp-methods} now have new
1609 values for the remote host.
1611 @var{property} could also be any property found in
1612 @code{tramp-persistency-file-name}.
1614 To get around how restricted shells randomly drop connections, set the
1615 special property @samp{busybox}. For example:
1618 (add-to-list 'tramp-connection-properties
1619 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1624 @node Remote programs
1625 @section How @value{tramp} finds and uses programs on the remote host
1627 @value{tramp} requires access to and rights to several commands on
1628 remote hosts: @command{ls}, @command{test}, @command{find} and
1631 Besides there are other required programs for @ref{Inline methods} and
1632 @ref{External methods} of connection.
1634 To improve performance and accuracy of remote file access,
1635 @value{tramp} uses @command{perl} (or @command{perl5}) and
1636 @command{grep} when available.
1638 @defopt tramp-remote-path
1639 @vindex tramp-remote-path
1640 @vindex tramp-default-remote-path
1641 @vindex tramp-own-remote-path
1642 @option{tramp-remote-path} specifies which remote directory paths
1643 @value{tramp} can search for @ref{Remote programs}.
1645 @value{tramp} uses standard defaults, such as @file{/bin} and
1646 @file{/usr/bin}, which are reasonable for most hosts. To accommodate
1647 differences in hosts and paths, for example, @file{/bin:/usr/bin} on
1649 @file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin} on
1650 Solaris, @value{tramp} queries the remote host with @command{getconf
1651 PATH} and updates the symbol @code{tramp-default-remote-path}.
1653 For instances where hosts keep obscure locations for paths for
1654 security reasons, manually add such paths to local @file{.emacs} as
1655 shown below for @value{tramp} to use when connecting.
1658 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1661 Another way to find the remote path is to use the path assigned to the
1662 remote user by the remote host. @value{tramp} does not normally retain
1663 this remote path after logging. However, @code{tramp-own-remote-path}
1664 preserves the path value, which can be used to update
1665 @code{tramp-remote-path}.
1668 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1672 When remote search paths are changed, local @value{tramp} caches must
1673 be recomputed. To force @value{tramp} to recompute afresh, exit
1674 Emacs, remove the persistent file (@pxref{Connection caching}), and
1678 @node Remote shell setup
1679 @section Remote shell setup hints
1680 @cindex remote shell setup
1681 @cindex @file{.profile} file
1682 @cindex @file{.login} file
1683 @cindex shell init files
1685 @value{tramp} checks for the availability of standard programs in the
1686 usual locations. Common tactics include successively trying
1687 @command{test -e}, @command{/usr/bin/test -e}, and @command{/bin/test
1688 -e}. @command{ls -d} is another approach. But these approaches do not
1689 help with these new login patterns.
1691 When @value{tramp} encounters two-factor logins or additional challenge
1692 questions, such as entering birth date or security code or passphrase,
1693 @value{tramp} needs a few more configuration steps to accommodate
1696 The difference between a password prompt and a passphrase prompt is
1697 that the password for completing the login while the passphrase is
1698 for authorizing access to local authentication information, such as
1701 There is no one configuration to accommodate all the variations in
1702 login security, especially not the exotic ones. However, @value{tramp}
1703 provides a few tweaks to address the most common ones.
1706 @item @var{tramp-shell-prompt-pattern}
1707 @vindex tramp-shell-prompt-pattern
1709 @code{tramp-shell-prompt-pattern} is for remote login shell prompt,
1710 which may not be the same as the local login shell prompt,
1711 @code{shell-prompt-pattern}. Since most hosts use identical prompts,
1712 @value{tramp} sets a similar default value for both prompts.
1714 @item @var{tramp-password-prompt-regexp}
1715 @item @var{tramp-wrong-passwd-regexp}
1716 @vindex tramp-password-prompt-regexp
1717 @vindex tramp-wrong-passwd-regexp
1719 @value{tramp} uses @var{tramp-password-prompt-regexp} to distinguish
1720 between prompts for passwords and prompts for passphrases. By default,
1721 @var{tramp-password-prompt-regexp} handles the detection in English
1722 language environments. See a localization example below:
1726 tramp-password-prompt-regexp
1730 '("passphrase" "Passphrase"
1732 "password" "Password"
1734 "passwort" "Passwort"
1736 "mot de passe" "Mot de passe") t)
1740 Similar localization may be necessary for handling wrong password
1741 prompts, for which @value{tramp} uses @var{tramp-wrong-passwd-regexp}.
1743 @item @command{tset} and other questions
1744 @cindex Unix command tset
1745 @cindex tset Unix command
1746 @vindex tramp-terminal-type
1748 To suppress inappropriate prompts for terminal type, @value{tramp}
1749 sets the @env{TERM} to @code{dumb} before the remote login process
1750 begins via the variable @code{tramp-terminal-type}. This will silence
1751 common @command{tset} related prompts.
1753 @value{tramp}'s strategy for handling such prompts (commonly triggered
1754 from login scripts on remote hosts) is to set the environment
1755 variables so that no prompts interrupt the shell initialization
1758 @vindex tramp-actions-before-shell
1760 An alternative approach is to configure @value{tramp} with strings
1761 that can identify such questions using
1762 @code{tramp-actions-before-shell}. Example:
1765 (defconst my-tramp-prompt-regexp
1766 (concat (regexp-opt '("Enter the birth date of your mother:") t)
1768 "Regular expression matching my login prompt question.")
1770 (defun my-tramp-action (proc vec)
1771 "Enter \"19000101\" in order to give a correct answer."
1772 (save-window-excursion
1773 (with-current-buffer (tramp-get-connection-buffer vec)
1774 (tramp-message vec 6 "\n%s" (buffer-string))
1775 (tramp-send-string vec "19000101"))))
1777 (add-to-list 'tramp-actions-before-shell
1778 '(my-tramp-prompt-regexp my-tramp-action))
1782 @item Conflicting names for users and variables in @file{.profile}
1784 When a user name is the same as a variable name in a local file, such
1785 as @file{.profile}, then @value{tramp} may send incorrect values for
1786 environment variables. To avoid incorrect values, change the local
1787 variable name to something different from the user name. For example,
1788 if the user name is @env{FRUMPLE}, then change the variable name to
1792 @item Non-Bourne commands in @file{.profile}
1794 When the remote host's @file{.profile} is also used for shells other
1795 than Bourne shell, then some incompatible syntaxes for commands in
1796 @file{.profile} may trigger errors in Bourne shell on the host and may
1797 not complete client's @value{tramp} connections.
1799 One example of a Bourne shell incompatible syntax in @file{.profile}:
1800 using @command{export FOO=bar} instead of @command{FOO=bar; export
1801 FOO}. After remote login, @value{tramp} will trigger an error during
1802 its execution of @command{/bin/sh} on the remote host because Bourne
1803 shell does not recognize the export command as entered in
1806 Likewise, (@code{~}) character in paths will cause errors because
1807 Bourne shell does not do (@code{~}) character expansions.
1809 One approach to avoiding these incompatibilities is to make all
1810 commands in @file{~/.shrc} and @file{~/.profile} Bourne shell
1811 compatible so @value{tramp} can complete connections to that remote.
1812 To accommodate using non-Bourne shells on that remote, use other
1813 shell-specific config files. For example, bash can use
1814 @file{~/.bash_profile} and ignore @file{.profile}.
1817 @item Interactive shell prompt
1819 @value{tramp} redefines the remote shell prompt internally for robust
1820 parsing. This redefinition affects the looks of a prompt in an
1821 interactive remote shell through commands, such as @kbd{M-x
1822 shell}. Such prompts, however, can be reset to something more readable
1823 and recognizable using these @value{tramp} variables.
1825 @value{tramp} sets the @env{INSIDE_EMACS} variable in the startup
1826 script file @file{~/.emacs_SHELLNAME}.
1828 @env{SHELLNAME} is @code{bash} or equivalent shell names. Change it by
1829 setting the environment variable @env{ESHELL} in the @file{.emacs} as
1833 (setenv "ESHELL" "bash")
1836 Then re-set the prompt string in @file{~/.emacs_SHELLNAME} as follows:
1839 # Reset the prompt for remote Tramp shells.
1840 if [ "$@{INSIDE_EMACS/*tramp*/tramp@}" == "tramp" ] ; then
1846 @xref{Interactive Shell, , , emacs}.
1849 @item @command{busybox} / @command{nc}
1850 @cindex Unix command nc
1851 @cindex nc Unix command
1853 @value{tramp}'s @option{nc} method uses the @command{nc} command to
1854 install and execute a listener as follows (see @code{tramp-methods}):
1860 The above command-line syntax has changed with @command{busybox}
1861 versions. If @command{nc} refuses the @command{-p} parameter, then
1862 overwrite as follows:
1866 'tramp-connection-properties
1867 `(,(regexp-quote "192.168.0.1") "remote-copy-args" (("-l") ("%r"))))
1871 where @samp{192.168.0.1} is the remote host IP address
1872 (@pxref{Predefined connection information}).
1877 @node Android shell setup
1878 @section Android shell setup hints
1879 @cindex android shell setup
1881 @value{tramp} uses the @option{adb} method to access Android
1882 devices. Android devices provide a restricted shell access through an
1883 USB connection. The local host must have Andriod SDK installed.
1885 Applications such as @code{SSHDroid} that run @command{sshd} process
1886 on the Android device can accept any @option{ssh}-based methods
1887 provided these settings are adjusted:
1889 @code{sh} must be specified for remote shell since Android devices do
1890 not provide @code{/bin/sh}. @code{sh} will then invoke whatever shell is
1891 installed on the device with this setting:
1894 (add-to-list 'tramp-connection-properties
1895 (list (regexp-quote "192.168.0.26") "remote-shell" "sh"))
1899 where @samp{192.168.0.26} is the Android device's IP address.
1900 (@pxref{Predefined connection information}).
1902 @value{tramp} requires preserving @env{PATH} environment variable from
1903 user settings. Android devices prefer @file{/system/xbin} path over
1904 @file{/system/bin}. Both of these are set as follows:
1907 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1908 (add-to-list 'tramp-remote-path "/system/xbin")
1912 When the Android device is not @samp{rooted}, specify a writable
1913 directory for temporary files:
1916 (add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")
1920 Open a remote connection with the command @kbd{C-x C-f
1921 @trampfn{ssh,192.168.0.26#2222,}}, where @command{sshd} is listening on port
1924 To add a corresponding entry to the @file{~/.ssh/config} file
1925 (recommended), use this:
1929 HostName 192.168.0.26
1935 To use the host name @samp{android} instead of the IP address shown in
1936 the previous example, fix the connection properties as follows:
1939 (add-to-list 'tramp-connection-properties
1940 (list (regexp-quote "android") "remote-shell" "sh"))
1944 Open a remote connection with a more concise command @kbd{C-x C-f
1945 @trampfn{ssh,android,}}.
1948 @node Auto-save and Backup
1949 @section Auto-save and Backup configuration
1952 @vindex backup-directory-alist
1954 To avoid @value{tramp} from saving backup files owned by root to
1955 locations accessible to others, default backup settings in
1956 @code{backup-directory-alist} have to be altered.
1958 Here's a scenario where files could be inadvertently exposed. Emacs
1959 by default writes backup files to the same directory as the original
1960 files unless changed to another location, such as
1961 @file{~/.emacs.d/backups/}. Such a directory will also be used by
1962 default by @value{tramp} when using, say, a restricted file
1963 @file{@trampfn{su,root@@localhost,/etc/secretfile}}. The backup
1964 file of the secretfile is now owned by the user logged in from tramp
1967 When @code{backup-directory-alist} is @code{nil} (the default), such
1968 problems do not occur.
1970 To ``turns off'' the backup feature for @value{tramp} files and stop
1971 @value{tramp} from saving to the backup directory, use this:
1974 (add-to-list 'backup-directory-alist
1975 (cons tramp-file-name-regexp nil))
1979 Disabling backups can be targetted to just @option{su} and
1980 @option{sudo} methods:
1983 (setq backup-enable-predicate
1985 (and (normal-backup-enable-predicate name)
1987 (let ((method (file-remote-p name 'method)))
1988 (when (stringp method)
1989 (member method '("su" "sudo"))))))))
1992 Another option is to create better backup file naming with user and
1993 host names prefixed to the file name. For example, transforming
1994 @file{/etc/secretfile} to
1995 @file{~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile}, set the
1996 @value{tramp} variable @code{tramp-backup-directory-alist} from the
1997 existing variable @code{backup-directory-alist}.
1999 Then @value{tramp} backs up to a file name that is transformed with a
2000 prefix consisting of the DIRECTORY name. This file name prefixing
2001 happens only when the DIRECTORY is an absolute local file name.
2007 (add-to-list 'backup-directory-alist
2008 (cons "." "~/.emacs.d/backups/"))
2009 (setq tramp-backup-directory-alist backup-directory-alist)
2013 The backup file name of
2014 @file{@trampfn{su,root@@localhost,/etc/secretfile}} would be
2015 @file{@trampfn{su,root@@localhost,~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}}.
2017 Just as for backup files, similar issues of file naming affect
2018 auto-saving @value{tramp} files. Auto-saved files are saved in the
2019 directory specified by the variable
2020 @code{auto-save-file-name-transforms}. By default this is set to the
2021 local temporary directory. But in some versions of Debian GNU/Linux,
2022 this points to the source directory where the Emacs was compiled.
2023 Reset such values to a valid directory.
2025 Set @code{auto-save-file-name-transforms} to @code{nil} to save
2026 auto-saved files to the same directory as the original file.
2028 Alternatively, set the variable @code{tramp-auto-save-directory} to
2029 direct all auto saves to that location.
2031 @node Windows setup hints
2032 @section Issues with Cygwin ssh
2033 @cindex Cygwin, issues
2035 This section is incomplete. Please share your solutions.
2037 @cindex method sshx with Cygwin
2038 @cindex sshx method with Cygwin
2040 Cygwin's @command{ssh} works only with a Cygwin version of Emacs. To
2041 check for compatibility: type @kbd{M-x eshell}, and start @kbd{ssh
2042 test.host}. Incompatbilities trigger this message:
2045 Pseudo-terminal will not be allocated because stdin is not a terminal.
2048 Some older versions of Cygwin's @command{ssh} work with the
2049 @option{sshx} access method. Consult Cygwin's FAQ at
2050 @uref{http://cygwin.com/faq/} for details.
2053 @cindex method scpx with Cygwin
2054 @cindex scpx method with Cygwin
2056 When using the @option{scpx} access method, Emacs may call
2057 @command{scp} with Windows file naming, such as @code{c:/foo}. But
2058 the version of @command{scp} that is installed with Cygwin does not
2059 know about Windows file naming, which causes it to incorrectly look
2060 for a host named @code{c}.
2062 A workaround: write a wrapper script for @option{scp} to convert
2063 Windows file names to Cygwin file names.
2065 @cindex Cygwin and ssh-agent
2066 @cindex SSH_AUTH_SOCK and Emacs on Windows
2068 When using the @command{ssh-agent} on Windows for password-less
2069 interaction, @option{ssh} methods depend on the environment variable
2070 @env{SSH_AUTH_SOCK}. But this variable is not set when Emacs is
2071 started from a Desktop shortcut and authentication fails.
2073 One workaround is to use a Windows based SSH Agent, such as
2074 Pageant. It is part of the Putty Suite of tools.
2076 The fallback is to start Emacs from a shell.
2080 @chapter Using @value{tramp}
2081 @cindex using @value{tramp}
2083 @value{tramp} operates transparently, accessing remote files as if
2084 they are local. However, @value{tramp} employs a formalized remote
2085 file naming syntax to perform its functions transparently. This
2086 syntax consists of many parts specifying access methods,
2087 authentication, host names, and file names. Ange FTP uses a similar
2092 Unlike opening local files in Emacs, which are instantaneous, opening
2093 remote files in @value{tramp} is slower at first. Sometimes there is
2094 a noticable delay before the prompts for passwords or authentication
2095 appear in the minibuffer. Hitting @kbd{@key{RET}} or other keys
2096 during this gap will be processed by Emacs. This type-ahead facility
2097 is a feature of Emacs that may cause missed prompts when using
2101 * File name Syntax:: @value{tramp} file name conventions.
2102 * File name completion:: File name completion.
2103 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
2104 * Remote processes:: Integration with other Emacs packages.
2105 * Cleanup remote connections:: Cleanup remote connections.
2109 @node File name Syntax
2110 @section @value{tramp} file name conventions
2111 @cindex file name syntax
2112 @cindex file name examples
2114 @file{@trampf{host,localfilename}}
2115 opens file @var{localfilename} on the remote host @var{host}, using
2116 the default method. @xref{Default Method}.
2119 @item @value{prefix}melancholia@value{postfix}.emacs
2120 For the file @file{.emacs} located in the home directory, on the host
2123 @item @value{prefix}melancholia.danann.net@value{postfix}.emacs
2124 For the file @file{.emacs} specified using the fully qualified domain name of
2127 @item @value{prefix}melancholia@value{postfix}~/.emacs
2128 For the file @file{.emacs} specified using the @file{~}, which is expanded.
2130 @item @value{prefix}melancholia@value{postfix}~daniel/.emacs
2131 For the file @file{.emacs} located in @code{daniel}'s home directory
2132 on the host, @code{melancholia}. The @file{~<user>} construct is
2133 expanded to the home directory of that user on the remote host.
2135 @item @value{prefix}melancholia@value{postfix}/etc/squid.conf
2136 For the file @file{/etc/squid.conf} on the host @code{melancholia}.
2140 @var{host} can take IPv4 or IPv6 address, as in
2141 @file{@trampf{127.0.0.1,.emacs}} or
2142 @file{@trampf{@value{ipv6prefix}::1@value{ipv6postfix},.emacs}}.
2143 For syntactical reasons, IPv6 addresses must be embedded in square
2144 brackets @file{@value{ipv6prefix}} and @file{@value{ipv6postfix}}.
2146 By default, @value{tramp} will use the current local user name as the
2147 remote user name for log in to the remote host. Specifying a different
2148 name using the proper syntax will override this default behavior:
2151 @trampf{user@@host,path/to.file}
2154 @file{@trampf{daniel@@melancholia,.emacs}} is for file
2155 @file{.emacs} in @code{daniel}'s home directory on the host,
2158 Specify other file access methods (@pxref{Inline methods},
2159 @pxref{External methods}) as part of the file name.
2161 Method name comes before user name, as in
2162 @file{@value{prefix}@var{method}@value{postfixhop}} (Note the trailing
2163 colon). The syntax specificaton for user, host, and file do not
2166 To connect to the host @code{melancholia} as @code{daniel}, using
2167 @option{ssh} method for @file{.emacs} in @code{daniel}'s home
2168 directory, the full specification is:
2169 @file{@trampfn{ssh,daniel@@melancholia,.emacs}}.
2171 A remote file name containing a host name, which is the same string as
2172 a method name, is not allowed.
2174 For specifying port numbers, affix @file{#<port>} to the host
2175 name. For example: @file{@trampfn{ssh,daniel@@melancholia#42,.emacs}}.
2178 @node File name completion
2179 @section File name completion
2180 @cindex file name completion
2182 @value{tramp} can complete the following @value{tramp} file name
2183 components: method names, user names, host names, and file names
2184 located on remote hosts. Enable this by activating partial completion
2187 @xref{Completion Options, , , emacs}.
2190 For example, type @kbd{C-x C-f @value{prefix}t @key{TAB}},
2191 @value{tramp} completion choices show up as
2194 @c @multitable {@trampfn{telnet,melancholia.danann.net,}} {@trampfn{telnet,192.168.0.1,}}
2195 @multitable @columnfractions .5 .5
2196 @item @value{prefixhop}telnet@value{postfixhop} @tab tmp/
2197 @item @value{prefixhop}toto@value{postfix} @tab
2201 @samp{@value{prefixhop}telnet@value{postfixhop}} is a possible
2202 completion for the respective method, @samp{tmp/} stands for the
2203 directory @file{/tmp} on your local host, and
2204 @samp{@value{prefixhop}toto@value{postfix}} might be a host
2205 @value{tramp} has detected in your @file{~/.ssh/known_hosts} file
2206 (when using @option{ssh} as default method).
2208 Type @kbd{e @key{TAB}} for the minibuffer completion to
2209 @samp{@value{prefix}telnet@value{postfixhop}}. Typing @kbd{@key{TAB}}
2210 shows host names @value{tramp} from @file{/etc/hosts} file, for example.
2213 @multitable @columnfractions .5 .5
2214 @c @multitable {@trampfn{telnet,melancholia.danann.net,}} {@trampfn{telnet,192.168.0.1,}}
2215 @item @trampfn{telnet,127.0.0.1,} @tab @trampfn{telnet,192.168.0.1,}
2216 @c @item @trampfn{telnet,@value{ipv6prefix}::1@value{ipv6postfix},} @tab @trampfn{telnet,localhost,}
2217 @item @value{prefix}telnet@value{postfixhop}@value{ipv6prefix}::1@value{ipv6postfix}@value{postfix} @tab @trampfn{telnet,localhost,}
2218 @item @trampfn{telnet,melancholia.danann.net,} @tab @trampfn{telnet,melancholia,}
2222 Choose a host from the above list and then continue to complete file
2225 When the configuration (@pxref{Customizing Completion}) includes user
2226 names, then the completion lists will account for the user names as well.
2228 Remote hosts previously visited or hosts whose connections are kept
2229 persistently (@pxref{Connection caching}) will be included in the
2232 After remote host name completion comes completion of file names on
2233 the remote host. It works the same as on loal host file completion
2234 except when killing with double-slash @file{//} kills only the file
2235 name part of the @value{tramp} file name syntax. A triple-slash
2236 stands for the default behavior.
2238 @xref{Minibuffer File, , , emacs}.
2245 @kbd{C-x C-f @trampfn{telnet,melancholia,/usr/local/bin//etc} @key{TAB}}
2246 @print{} @trampfn{telnet,melancholia,/etc}
2248 @kbd{C-x C-f @trampfn{telnet,melancholia,//etc} @key{TAB}}
2251 @kbd{C-x C-f @trampfn{telnet,melancholia,/usr/local/bin///etc} @key{TAB}}
2255 During file name completion, remote directory contents are re-read
2256 regularly to account for any changes in the filesystem that may affect
2257 the completion candidates. Such re-reads can account for changes to
2258 the file system by applications outside Emacs (@pxref{Connection
2261 @defopt tramp-completion-reread-directory-timeout
2262 @vindex tramp-completion-reread-directory-timeout
2263 The timeout is number of seconds since last remote command for
2264 rereading remote directory contents. 0 re-reads immediately during
2265 file name completion, @code{nil} uses cached directory contents.
2269 @node Ad-hoc multi-hops
2270 @section Declaring multiple hops in the file name
2271 @cindex multi-hop, ad-hoc
2272 @cindex proxy hosts, ad-hoc
2274 @value{tramp} file name syntax can accommodate ad hoc specification of
2275 multiple proxies without using @code{tramp-default-proxies-alist}
2276 configuration setup(@pxref{Multi-hops}).
2278 Each proxy is specified using the same syntax as the remote host
2279 specification minus the file name part. Each hop is separated by a
2280 @samp{|}. Chain the proxies from the starting host to the destination
2281 remote host name and file name. For example, hopping over a single
2282 proxy @samp{bird@@bastion} to a remote file on @samp{you@@remotehost}:
2285 @c @kbd{C-x C-f @trampfn{ssh@value{postfixhop}bird@@bastion|ssh,you,remotehost,/path}}
2286 @kbd{C-x C-f @value{prefix}ssh@value{postfixhop}bird@@bastion|ssh@value{postfixhop}you@@remotehost@value{postfix}/path}
2289 Proxies can take patterns @code{%h} or @code{%u}.
2291 @value{tramp} adds the ad-hoc definitions on the fly to
2292 @code{tramp-default-proxies-alist} and is available for re-use during
2293 that Emacs session. Subsequent @value{tramp} connections to the same
2294 remote host can then use the shortcut form:
2295 @samp{@trampfn{ssh,you@@remotehost,/path}}.
2297 @defopt tramp-save-ad-hoc-proxies
2298 @vindex tramp-save-ad-hoc-proxies
2299 For ad-hoc definitions to be saved automatically in
2300 @option{tramp-default-proxies-alist} for future Emacs sessions, set
2301 @option{tramp-save-ad-hoc-proxies}.
2304 (setq tramp-save-ad-hoc-proxies t)
2309 @node Remote processes
2310 @section Integration with other Emacs packages
2314 @value{tramp} supports starting new running processes on the remote
2315 host for discovering remote file names. Emacs packages on the remote
2316 host need no specific modifications for @value{tramp}'s use.
2318 This type of integration does not work with the @option{ftp} method,
2319 and does not support the pty association as specified in
2320 @code{start-file-process}.
2322 @code{process-file} and @code{start-file-process} work on the remote
2323 host when the variable @code{default-directory} is remote:
2326 (let ((default-directory "/ssh:remote.host:"))
2327 (start-file-process "grep" (get-buffer-create "*grep*")
2328 "/bin/sh" "-c" "grep -e tramp *"))
2333 Remote processes do not apply to GVFS (see @ref{GVFS based methods})
2334 because the remote file system is mounted on the local host and
2335 @value{tramp} just accesses by changing the @code{default-directory}.
2338 @value{tramp} starts a remote process when a command is executed in a
2339 remote file or directory buffer. As of now, these packages have been
2340 integrated to work with @value{tramp}: @file{compile.el} (commands
2341 like @code{compile} and @code{grep}) and @file{gud.el} (@code{gdb} or
2344 For @value{tramp} to find the command on the remote, it must be
2345 accessible through the default search path as setup by @value{tramp}
2346 upon first connection. Alternatively, use an absolute path or extend
2347 @code{tramp-remote-path} (see @ref{Remote programs}):
2350 (add-to-list 'tramp-remote-path "~/bin")
2351 (add-to-list 'tramp-remote-path "/appli/pub/bin")
2354 Customize @code{tramp-remote-process-environment} to suit the remote
2355 program's environment for the remote host.
2356 @code{tramp-remote-process-environment} is a list of strings
2357 structured similar to @code{process-environment}, where each element
2358 is a string of the form @samp{ENVVARNAME=VALUE}.
2360 To avoid any conflicts with local host variables set through local
2361 configuration files, such as @file{~/.profile}, use @samp{ENVVARNAME=}
2362 to unset them for the remote environment.
2365 Use @code{add-to-list} to add entries:
2368 (add-to-list 'tramp-remote-process-environment "JAVA_HOME=/opt/java")
2371 Modifying or deleting already existing values in the
2372 @code{tramp-remote-process-environment} list may not be feasible on
2373 restricted remote hosts. For example, some system administrators
2374 disallow changing @env{HISTORY} variable. To accommodate such
2375 restrictions when using @value{tramp}, fix the
2376 @code{tramp-remote-process-environment} by the following code in the
2377 local @file{.emacs} file:
2380 (let ((process-environment tramp-remote-process-environment))
2381 (setenv "HISTORY" nil)
2382 (setq tramp-remote-process-environment process-environment))
2385 @value{tramp} does not use the defaults specified in
2386 @code{process-environment} for running @code{process-file} or
2387 @code{start-file-process} on remote hosts. When values from
2388 @code{process-environment} are needed for remote processes, then set
2392 (let ((process-environment (cons "HGPLAIN=1" process-environment)))
2393 (process-file @dots{}))
2396 This works only for environment variables not already set in the
2397 @code{process-environment}.
2399 For integrating other Emacs packages so @value{tramp} can execute
2400 remotely, please file a bug report. @xref{Bug Reports}.
2403 @subsection Running remote programs that create local X11 windows
2405 To allow a remote program to create an X11 window on the local host,
2406 set the @env{DISPLAY} environment variable for the remote host as
2407 follows in the local @file{.emacs} file:
2410 (add-to-list 'tramp-remote-process-environment
2411 (format "DISPLAY=%s" (getenv "DISPLAY")))
2415 @code{(getenv "DISPLAY")} should return a recognizable name for the
2416 local host that the remote host can redirect X11 window
2417 interactions. If querying for a recognizable name is not possible for
2418 whatever reason, then replace @code{(getenv "DISPLAY")} with a
2419 hard-coded, fixed name. Note that using @code{:0} for X11 display name
2420 here will not work as expected.
2422 An alternate approach is specify @code{ForwardX11 yes} or
2423 @code{ForwardX11Trusted yes} in the file @file{~/.ssh/config} on the
2427 @subsection Running @code{shell} on a remote host
2430 Set @option{explicit-shell-file-name} to the appropriate shell name
2431 when using @value{tramp} between two hosts with different operating
2432 systems, such as @samp{windows-nt} and @samp{gnu/linux}. This option
2433 ensures the correct name of the remote shell program.
2435 Starting with Emacs 24, when @option{explicit-shell-file-name} is
2436 equal to @code{nil}, calling @code{shell} interactively will prompt
2440 @subsection Running @code{shell-command} on a remote host
2441 @cindex shell-command
2443 @code{shell-command} executes commands synchronously or asynchronously
2444 on remote hosts and displays output in buffers on the local
2448 @kbd{C-x C-f @trampfn{sudo,,} @key{RET}}
2449 @kbd{M-! tail -f /var/log/syslog.log & @key{RET}}
2452 @command{tail} command outputs continuously to the local buffer,
2453 @file{*Async Shell Command*}
2455 @kbd{M-x auto-revert-tail-mode} runs similarly showing continuous output.
2458 @subsection Running @code{eshell} on a remote host
2461 @value{tramp} is integrated into @file{eshell.el}, which enables
2462 interactive eshell sessions on remote hosts at the command prompt.
2463 You must add the module @code{eshell-tramp} to
2464 @code{eshell-modules-list}. Here's a sample interaction after opening
2465 @kbd{M-x eshell} on a remote host:
2468 @b{~ $} cd @trampfn{sudo,,/etc} @key{RET}
2469 @b{@trampfn{sudo,root@@host,/etc} $} hostname @key{RET}
2471 @b{@trampfn{sudo,root@@host,/etc} $} id @key{RET}
2472 uid=0(root) gid=0(root) groups=0(root)
2473 @b{@trampfn{sudo,root@@host,/etc} $} find-file shadow @key{RET}
2475 @b{@trampfn{sudo,root@@host,/etc} $}
2478 @code{eshell} in Emacs 23.2 added custom @code{su} and @code{sudo}
2479 commands that set the default directory correctly for the
2480 @file{*eshell*} buffer. @value{tramp} silently updates
2481 @code{tramp-default-proxies-alist} with an entry for this directory
2482 (@pxref{Multi-hops}):
2485 @b{~ $} cd @trampfn{ssh,user@@remotehost,/etc} @key{RET}
2486 @b{@trampfn{ssh,user@@remotehost,/etc} $} find-file shadow @key{RET}
2487 File is not readable: @trampfn{ssh,user@@remotehost,/etc/shadow}
2488 @b{@trampfn{ssh,user@@remotehost,/etc} $} sudo find-file shadow @key{RET}
2491 @b{@trampfn{ssh,user@@remotehost,/etc} $} su - @key{RET}
2492 @b{@trampfn{su,root@@remotehost,/root} $} id @key{RET}
2493 uid=0(root) gid=0(root) groups=0(root)
2494 @b{@trampfn{su,root@@remotehost,/root} $}
2498 @anchor{Running a debugger on a remote host}
2499 @subsection Running a debugger on a remote host
2504 @file{gud.el} provides a unified interface to symbolic debuggers
2506 (@ref{Debuggers, , , emacs}).
2508 @value{tramp} can run debug on remote hosts by calling @code{gdb}
2509 with a remote file name:
2512 @kbd{M-x gdb @key{RET}}
2513 @b{Run gdb (like this):} gdb --annotate=3 @trampfn{ssh,host,~/myprog} @key{RET}
2516 Relative file names are based on the remote default directory. When
2517 @file{myprog.pl} exists in @file{@trampfn{ssh,host,/home/user}},
2518 valid calls include:
2521 @kbd{M-x perldb @key{RET}}
2522 @b{Run perldb (like this):} perl -d myprog.pl @key{RET}
2525 Just the local part of a remote file name, such as @kbd{perl -d
2526 /home/user/myprog.pl}, is not possible.
2528 Arguments of the program to be debugged must be literal, can take
2529 relative or absolute paths, but not remote paths.
2532 @subsection Running remote processes on Windows hosts
2536 @command{winexe} runs processes on a remote Windows host, and
2537 @value{tramp} can use it for @code{process-file} and
2538 @code{start-file-process}.
2540 @code{tramp-smb-winexe-program} specifies the local @command{winexe}
2541 command. Powershell V2.0 on the remote host is required to run
2542 processes triggered from @value{tramp}.
2544 @option{explicit-shell-file-name} and @option{explicit-*-args} have to
2545 be set properly so @kbd{M-x shell} can open a proper remote shell on a
2546 Windows host. To open @command{cmd}, set it as follows:
2549 (setq explicit-shell-file-name "cmd"
2550 explicit-cmd-args '("/q"))
2554 To open @command{powershell} as a remote shell, use this:
2557 (setq explicit-shell-file-name "powershell"
2558 explicit-powershell-args '("-file" "-"))
2562 @node Cleanup remote connections
2563 @section Cleanup remote connections
2566 @value{tramp} provides several ways to flush remote connections.
2568 @deffn Command tramp-cleanup-connection vec
2569 This command flushes all connection related objects. @option{vec} is
2570 the internal representation of a remote connection. When called
2571 interactively, this command lists active remote connections in the
2572 minibuffer. Each connection is of the format
2573 @file{@trampfn{method,user@@host,}}. Flushing remote connections also
2575 cache (@pxref{Password handling}), file cache, connection cache
2576 (@pxref{Connection caching}), and connection buffers.
2579 @deffn Command tramp-cleanup-this-connection
2580 Flushes only the current buffer's remote connection objects, the same
2581 as in @code{tramp-cleanup-connection}.
2584 @deffn Command tramp-cleanup-all-connections
2585 Flushes all active remote connection objects, the same as in
2586 @code{tramp-cleanup-connection}.
2589 @deffn Command tramp-cleanup-all-buffers
2590 Just as for @code{tramp-cleanup-all-connections}, all remote
2591 connections are cleaned up in addition to killing buffers related to
2592 that remote connection.
2597 @chapter Reporting Bugs and Problems
2600 @value{tramp}'s development team is actively engaged in solving bugs
2601 and problems and looks to feature requests and suggestions.
2603 @value{tramp}'s mailing list is the place for more advice and
2604 information on working with @value{tramp}, solving problems,
2605 discussing, and general discussions about @value{tramp}.
2607 @value{tramp}'s mailing list is moderated but even non-subscribers can
2608 post for moderator approval. Sometimes this approval step may take as
2609 long as 48 hours due to public holidays.
2611 @email{tramp-devel@@gnu.org} is the mailing list. Messages sent to
2612 this address go to all the subscribers. This is @emph{not} the
2613 address to send subscription requests to.
2615 To subscribe to the mailing list, visit:
2616 @uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/, the
2617 @value{tramp} Mail Subscription Page}.
2619 @ifset installchapter
2620 Before sending a bug report, run the test suite first @ref{Testing}.
2624 Check if the bug or problem is already addressed in @xref{Frequently
2627 Run @kbd{M-x tramp-bug} to generate a buffer with details of the
2628 system along with the details of the @value{tramp}
2629 installation. Please include these details with the bug report.
2631 The bug report must describe in as excruciating detail as possible the
2632 steps required to reproduce the problem. These details must include
2633 the setup of the remote host and any special or unique conditions that
2636 Include a minimal test case that reproduces the problem. This will
2637 help the development team find the best solution and avoid unrelated
2640 To exclude cache-related problems, flush all caches before running the
2641 test, @ref{Cleanup remote connections}.
2643 When including @value{tramp}'s messages in the bug report, increase
2644 the verbosity level to 6 (@pxref{Traces and Profiles, Traces}) in the
2645 @file{~/.emacs} file before repeating steps to the bug. Include the
2646 contents of the @file{*tramp/foo*} and @file{*debug tramp/foo*}
2647 buffers with the bug report.
2649 @strong{Note} that a verbosity level greater than 6 is not necessary
2650 at this stage. Also note that a verbosity level of 6 or greater, the
2651 contents of files and directories will be included in the debug
2652 buffer. Passwords typed in @value{tramp} will never be included
2656 @node Frequently Asked Questions
2657 @chapter Frequently Asked Questions
2658 @cindex frequently asked questions
2663 Where is the latest @value{tramp}?
2665 @value{tramp} is available at the GNU URL:
2668 @uref{ftp://ftp.gnu.org/gnu/tramp/}
2671 @value{tramp}'s GNU project page is located here:
2674 @uref{http://savannah.gnu.org/projects/tramp/}
2678 Which systems does it work on?
2680 The package works successfully on Emacs 23, Emacs 24, and Emacs 25.
2682 While Unix and Unix-like systems are the primary remote targets,
2683 @value{tramp} has equal success connecting to other platforms, such as
2684 MS Windows XP/Vista/7.
2688 How to speed up @value{tramp}?
2690 @value{tramp} does many things in the background, some of which
2691 depends on network speeds, response speeds of remote hosts, and
2692 authentication delays. During these operations, @value{tramp}'s
2693 responsiveness slows down. Some suggestions within the scope of
2694 @value{tramp}'s settings include:
2696 Use an external method, such as @option{scp}, which are faster than
2699 Keep the file @code{tramp-persistency-file-name}, which is where
2700 @value{tramp} caches remote information about hosts and files. Caching
2701 is enabled by default. Don't disable it.
2703 Set @code{remote-file-name-inhibit-cache} to @code{nil} if remote
2704 files are not independently updated outside @value{tramp}'s control.
2705 That cache cleanup will be necessary if the remote directories or
2706 files are updated independent of @value{tramp}.
2708 Set @code{tramp-completion-reread-directory-timeout} to @code{nil} to
2709 speed up completions, @ref{File name completion}.
2711 Disable version control to avoid delays:
2714 (setq vc-ignore-dir-regexp
2715 (format "\\(%s\\)\\|\\(%s\\)"
2716 vc-ignore-dir-regexp
2717 tramp-file-name-regexp))
2720 Disable excessive traces. Set @code{tramp-verbose} to 3 or lower,
2721 default being 3. Increase trace levels temporarily when hunting for
2725 @value{tramp} does not connect to the remote host
2727 Three main reasons for why @value{tramp} does not connect to the remote host:
2731 Unknown characters in the prompt
2733 @value{tramp} needs a clean recognizable prompt on the remote host for
2734 accurate parsing. Shell prompts that contain escape sequences for
2735 coloring cause parsing problems. @ref{Remote shell setup} for
2736 customizing prompt detection using regular expressions.
2738 To check if the remote host's prompt is being recognized, use this
2739 test: switch to @value{tramp} connection buffer @file{*tramp/foo*},
2740 put the cursor at the top of the buffer, and then apply the following
2744 @kbd{M-: (re-search-forward (concat tramp-shell-prompt-pattern "$"))}
2747 If the cursor has not moved to the prompt at the bottom of the buffer,
2748 then @value{tramp} has failed to recognize the prompt.
2750 When using zsh on remote hosts, disable zsh line editor because zsh
2751 uses left-hand side and right-hand side prompts in parallel. Add the
2752 following line to @file{~/.zshrc}:
2755 [ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
2758 When using fish shell on remote hosts, disable fancy formatting by
2759 adding the following to @file{~/.config/fish/config.fish}:
2762 function fish_prompt
2763 if test $TERM = "dumb"
2771 When using WinSSHD on remote hosts, @value{tramp} do not recognize the
2772 strange prompt settings.
2775 Echoed characters after login
2777 @value{tramp} suppresses echos from remote hosts with the
2778 @command{stty -echo} command. But sometimes it is too late to suppress
2779 welcome messages from the remote host containing harmful control
2780 characters. Using @option{sshx} or @option{scpx} methods can avoid
2781 this problem because they allocate a pseudo tty. @xref{Inline
2785 @value{tramp} stops transferring strings longer than 500 characters
2787 Set @code{tramp-chunksize} to 500 to get around this problem, which is
2788 related to faulty implementation of @code{process-send-string} on
2789 HP-UX, FreeBSD and Tru64 Unix systems. Consult the documentation for
2790 @code{tramp-chunksize} to see when this is necessary.
2792 Set @code{file-precious-flag} to @code{t} for files accessed by
2793 @value{tramp} so the file contents are checked using checksum by
2794 first saving to a temporary file.
2796 @pxref{Saving Buffers, , , elisp}
2803 (when (file-remote-p default-directory)
2804 (set (make-local-variable 'file-precious-flag) t))))
2810 @value{tramp} does not recognize if a @command{ssh} session hangs
2812 @command{ssh} sessions on the local host hang when the network is
2813 down. @value{tramp} cannot safely detect such hangs. The network
2814 configuration for @command{ssh} can be configured to kill such hangs
2815 with the following command in the @file{~/.ssh/config}:
2819 ServerAliveInterval 5
2824 @value{tramp} does not use default @command{ssh} @code{ControlPath}
2826 @value{tramp} overwrites @code{ControlPath} settings when initiating
2827 @command{ssh} sessions. @value{tramp} does this to fend off a stall
2828 if a master session opened outside the Emacs session is no longer
2829 open. That is why @value{tramp} prompts for the password again even
2830 if there is an @command{ssh} already open.
2832 Some @command{ssh} versions support a @code{ControlPersist} option,
2833 which allows to set the @code{ControlPath} provided the variable
2834 @code{tramp-ssh-controlmaster-options} is customized as follows:
2837 (setq tramp-ssh-controlmaster-options
2839 "-o ControlPath=/tmp/ssh-ControlPath-%%r@@%%h:%%p "
2840 "-o ControlMaster=auto -o ControlPersist=yes"))
2843 Note how "%r", "%h" and "%p" must be encoded as "%%r", "%%h" and
2846 If the @file{~/.ssh/config} is configured appropriately for the above
2847 behavior, then any changes to @command{ssh} can be suppressed with
2848 this @code{nil} setting:
2851 (setq tramp-use-ssh-controlmaster-options nil)
2856 File name completion does not work with @value{tramp}
2858 @acronym{ANSI} escape sequences from the remote shell may cause errors
2859 in @value{tramp}'s parsing of remote buffers.
2861 To test if this is the case, open a remote shell and check if the output
2862 of @command{ls} is in color.
2864 To disable @acronym{ANSI} escape sequences from the remote hosts,
2865 disable @option{--color=yes} or @option{--color=auto} in the remote
2866 host's @file{.bashrc} or @file{.profile}. Turn this alias on and off
2867 to see if file name completion works.
2870 File name completion does not work in directories with large number of
2873 This may be related to globbing, which is the use of shell's ability
2874 to expand wild card specifications, such as @samp{*.c}. For
2875 directories with large number of files, globbing might exceed the
2876 shell's limit on length of command lines and hang. @value{tramp} uses
2879 To test if globbing hangs, open a shell on the remote host and then
2880 run @samp{ls -d * ..?* > /dev/null}.
2882 When testing, ensure the remote shell is the same shell
2883 (@command{/bin/sh}, @command{ksh} or @command{bash}), that
2884 @value{tramp} uses when connecting to that host.
2888 How to get notified after @value{tramp} completes file transfers?
2890 Make Emacs beep after reading from or writing to the remote host with
2891 the following code in @file{~/.emacs} file.
2894 (defadvice tramp-handle-write-region
2895 (after tramp-write-beep-advice activate)
2896 "Make tramp beep after writing a file."
2900 (defadvice tramp-handle-do-copy-or-rename-file
2901 (after tramp-copy-beep-advice activate)
2902 "Make tramp beep after copying a file."
2906 (defadvice tramp-handle-insert-file-contents
2907 (after tramp-insert-beep-advice activate)
2908 "Make tramp beep after inserting a file."
2915 How to get a Visual Warning when working with @samp{root} privileges
2917 Get a modeline indication when working with @samp{root} privileges
2918 with the following code (tested with Emacs 22.1) in @file{~/.emacs}
2922 (defun my-mode-line-function ()
2923 (when (string-match "^/su\\(do\\)?:" default-directory)
2924 (setq mode-line-format
2925 (format-mode-line mode-line-format 'font-lock-warning-face))))
2927 (add-hook 'find-file-hook 'my-mode-line-function)
2928 (add-hook 'dired-mode-hook 'my-mode-line-function)
2933 How to get host indication in the mode line?
2935 The following code (tested with Emacs 22.1) in @file{~/.emacs} file
2939 (defconst my-mode-line-buffer-identification
2943 (if (file-remote-p default-directory)
2944 (tramp-file-name-host
2945 (tramp-dissect-file-name default-directory))
2947 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
2948 (substring host-name 0 (match-beginning 1))
2953 mode-line-buffer-identification
2954 my-mode-line-buffer-identification)
2960 mode-line-buffer-identification
2961 my-mode-line-buffer-identification)))
2964 The mode line in Emacs 23.1 and later versions now contains an
2965 indication if @code{default-directory} for the current buffer is on a
2966 remote host. Moreover, the corresponding tool-tip shows the remote
2967 host name. The above @code{:eval} clause can also be simplified to
2968 show the host name in the mode line:
2973 (or (file-remote-p default-directory 'host)
2975 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
2976 (substring host-name 0 (match-beginning 1))
2982 Remote host does not understand default options for directory listing
2984 Emacs computes the @command{dired} options based on the local host but
2985 if the remote host cannot understand the same @command{ls} command,
2986 then set them with a hook as follows:
2990 'dired-before-readin-hook
2992 (when (file-remote-p default-directory)
2993 (setq dired-actual-switches "-al"))))
2998 Why is @file{~/.sh_history} file on the remote host growing?
3000 Due to @command{ksh} saving tilde expansions triggered by
3001 @value{tramp}, the history file is probably growing rapidly. To fix,
3002 turn off saving history by putting this shell code in the
3006 if [ -f $HOME/.sh_history ] ; then
3007 /bin/rm $HOME/.sh_history
3009 if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
3012 if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
3017 For @option{ssh}-based method, add the following line to your
3018 @file{~/.ssh/environment} file:
3026 How to shorten long file names when typing in @value{tramp}?
3028 Adapt several of these approaches to reduce typing. If the full name
3029 is @file{@trampfn{ssh,news@@news.my.domain,/opt/news/etc}}, then:
3034 Use default values for method name and user name:
3036 You can define default methods and user names for hosts,
3037 (@pxref{Default Method}, @pxref{Default User}):
3040 (setq tramp-default-method "ssh"
3041 tramp-default-user "news")
3044 The reduced typing: @kbd{C-x C-f @trampf{news.my.domain,/opt/news/etc}}.
3046 @strong{Note} that there are some useful shortcuts already. Accessing
3047 your local host as @samp{root} user, is possible just by @kbd{C-x C-f
3051 Use configuration options of the access method:
3053 Programs used for access methods already offer powerful configurations
3054 (@pxref{Customizing Completion}). For @option{ssh}, configure the
3055 file @file{~/.ssh/config}:
3059 HostName news.my.domain
3063 The reduced typing: @kbd{C-x C-f @trampfn{ssh,xy,/opt/news/etc}}.
3065 Depending on the number of files in the directories, host names
3066 completion can further reduce key strokes: @kbd{C-x C-f
3067 @value{prefix}ssh@value{postfixhop}x @key{TAB}}.
3070 Use environment variables to expand long strings
3072 For long file names, set up environment variables that are expanded in
3073 the minibuffer. Environment variables are set either outside Emacs or
3074 inside Emacs with Lisp:
3077 (setenv "xy" "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}")
3080 The reduced typing: @kbd{C-x C-f $xy @key{RET}}.
3082 @strong{Note} that file name cannot be edited here because the
3083 environment variables are not expanded during editing in the
3086 @item Define own keys:
3088 Redefine another key sequence in Emacs for @kbd{C-x C-f}:
3092 [(control x) (control y)]
3098 "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))))
3101 Simply typing @kbd{C-x C-y} would prepare minibuffer editing of file
3104 See @uref{http://www.emacswiki.org/cgi-bin/wiki/TrampMode, the Emacs
3105 Wiki} for a more comprehensive example.
3108 Define own abbreviation (1):
3110 Abbreviation list expansion can be used to reduce typing long file names:
3114 'directory-abbrev-alist
3115 '("^/xy" . "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))
3118 The reduced typing: @kbd{C-x C-f /xy @key{RET}}.
3120 @strong{Note} that file name cannot be edited here because the
3121 environment variables are not expanded during editing in the
3125 Define own abbreviation (2):
3127 The @code{abbrev-mode} gives additional flexibility for editing in the
3131 (define-abbrev-table 'my-tramp-abbrev-table
3132 '(("xy" "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}")))
3135 'minibuffer-setup-hook
3138 (setq local-abbrev-table my-tramp-abbrev-table)))
3140 (defadvice minibuffer-complete
3141 (before my-minibuffer-complete activate)
3144 ;; If you use partial-completion-mode
3145 (defadvice PC-do-completion
3146 (before my-PC-do-completion activate)
3150 The reduced typing: @kbd{C-x C-f xy @key{TAB}}.
3152 The minibuffer expands for further editing.
3154 @item Use bookmarks:
3156 Use bookmarks to save Tramp file names.
3158 @pxref{Bookmarks, , , emacs}.
3161 Upon visiting a location with @value{tramp}, save it as a bookmark with
3162 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{set}}.
3164 To revisit that bookmark:
3165 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{jump}}.
3167 @item Use recent files:
3169 @file{recentf} remembers visited places.
3171 @pxref{File Conveniences, , , emacs}.
3174 Keep remote file names in the recent list without have to check for
3175 their accessibility through remote access:
3181 Reaching recently opened files: @kbd{@key{menu-bar} @key{file}
3184 @item Use filecache:
3186 Since @file{filecache} remembers visited places, add the remote
3187 directory to the cache:
3190 (eval-after-load "filecache"
3191 '(file-cache-add-directory
3192 "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))
3195 Then use directory completion in the minibuffer with @kbd{C-x C-f
3200 @file{bbdb} has a built-in feature for Ange FTP files, which also
3201 works for @value{tramp} file names.
3203 @pxref{bbdb-ftp, Storing FTP sites in the BBDB, , bbdb}.
3206 Load @file{bbdb} in Emacs:
3213 Create a BBDB entry with @kbd{M-x bbdb-create-ftp-site}. Then specify
3214 a method and user name where needed. Examples:
3217 @kbd{M-x bbdb-create-ftp-site @key{RET}}
3218 @b{Ftp Site:} news.my.domain @key{RET}
3219 @b{Ftp Directory:} /opt/news/etc/ @key{RET}
3220 @b{Ftp Username:} ssh@value{postfixhop}news @key{RET}
3221 @b{Company:} @key{RET}
3222 @b{Additional Comments:} @key{RET}
3225 In BBDB buffer, access an entry by pressing the key @key{F}.
3229 Thanks to @value{tramp} users for contributing to these recipes.
3232 Why saved multi-hop file names do not work in a new Emacs session?
3234 When saving ad-hoc multi-hop @value{tramp} file names (@pxref{Ad-hoc
3235 multi-hops}) via bookmarks, recent files, filecache, bbdb, or another
3236 package, use the full ad-hoc file name including all hops, like
3237 @file{@trampfn{ssh,bird@@bastion|ssh@value{postfixhop}news.my.domain,/opt/news/etc}}.
3239 Alternatively, when saving abbreviated multi-hop file names
3240 @file{@trampfn{ssh,news@@news.my.domain,/opt/news/etc}}, the custom
3241 option @code{tramp-save-ad-hoc-proxies} must be set non-@code{nil}
3246 How to connect to a remote Emacs session using @value{tramp}?
3248 Configure Emacs Client
3250 (@pxref{Emacs Server, , , emacs}).
3253 Then on the remote host, start the Emacs Server:
3257 (setq server-host (system-name)
3262 If @code{(system-name)} of the remote host cannot be resolved on the
3263 local host, use IP address instead.
3265 Copy from the remote host the resulting file
3266 @file{~/.emacs.d/server/server} to the local host, to the same
3269 Then start Emacs Client from the command line:
3272 emacsclient @trampfn{ssh,user@@host,/file/to/edit}
3275 @code{user} and @code{host} refer to the local host.
3277 To make Emacs Client an editor for other programs, use a wrapper
3278 script @file{emacsclient.sh}:
3282 emacsclient @trampfn{ssh,$(whoami)@@$(hostname --fqdn),$1}
3285 Then change the environment variable @env{EDITOR} to point to the
3289 export EDITOR=/path/to/emacsclient.sh
3294 How to disable other packages from calling @value{tramp}?
3296 There are packages that call @value{tramp} without the user ever
3297 entering a remote file name. Even without applying a remote file
3298 syntax, some packages enable @value{tramp} on their own. How can users
3299 disable such features.
3305 Disable @value{tramp} file name completion:
3308 (custom-set-variables
3309 '(ido-enable-tramp-completion nil))
3315 Disable remote directory tracking mode:
3318 (rlogin-directory-tracking-mode -1)
3324 How to disable @value{tramp}?
3328 To keep Ange FTP as default the remote files access package, set this
3332 (setq tramp-default-method "ftp")
3336 To disable both @value{tramp} (and Ange FTP), set @code{tramp-mode} to
3337 @code{nil} in @file{.emacs}.
3340 (setq tramp-mode nil)
3344 To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp}. Unloading
3345 @value{tramp} resets Ange FTP plugins also.
3350 @c For the developer
3351 @node Files directories and localnames
3352 @chapter How file names, directories and localnames are mangled and managed.
3355 * Localname deconstruction:: Splitting a localname into its component parts.
3356 * External packages:: Integrating with external Lisp packages.
3360 @node Localname deconstruction
3361 @section Splitting a localname into its component parts
3363 @value{tramp} package redefines lisp functions
3364 @code{file-name-directory} and @code{file-name-nondirectory} to
3365 accommodate the unique file naming syntax that @value{tramp} requires.
3367 The replacements dissect the file name, use the original handler for
3368 the localname, take that result, and then re-build the @value{tramp}
3369 file name. By relying on the original handlers for localnames,
3370 @value{tramp} benefits from platform specific hacks to the original
3374 @node External packages
3375 @section Integrating with external Lisp packages
3376 @subsection File name completion.
3378 For name completions in the minibuffer, @value{tramp} depends on the
3379 last input character to decide whether to look for method name
3380 completion or host name completion. For example, @kbd{C-x C-f
3381 @value{prefix}ssh@value{postfixhop} @key{TAB}} is not entirely clear
3382 if @option{ssh} is a method or a host name. But if the last input
3383 character was either @key{TAB}, @key{SPACE} or @kbd{?}, then
3384 @value{tramp} favors file name completion over host name completion.
3386 What about external packages using other characters to trigger file
3387 name completions? They must somehow signal this to @value{tramp}. Use
3388 the variable @code{non-essential} temporarily and bind it to
3389 non-@code{nil} value.
3392 (let ((non-essential t))
3397 @subsection File attributes cache.
3399 Keeping a local cache of remote file attributes in sync with the
3400 remote host is a time-consuming operation. Flushing and re-querying
3401 these attributes can tax @value{tramp} to a grinding halt on busy
3404 To get around these types of slow-downs in @value{tramp}'s
3405 responsiveness, set the @code{process-file-side-effects} to @code{nil}
3406 to stop @value{tramp} from flushing the cache. This is helpful in
3407 situations where callers to @code{process-file} know there are no file
3408 attribute changes. The let-bind form to accomplish this:
3411 (let (process-file-side-effects)
3415 For asynchronous processes, @value{tramp} uses a process sentinel to
3416 flush file attributes cache. When callers to @code{start-file-process}
3417 know beforehand no file attribute changes are expected, then the
3418 process sentinel should be set to the default state. In cases where
3419 the caller defines its own process sentinel, @value{tramp}'s process
3420 sentinel is overwritten. The caller can still flush the file
3421 attributes cache in its process sentinel with this code:
3424 (unless (memq (process-status proc) '(run open))
3425 (dired-uncache remote-directory))
3428 Since @value{tramp} traverses subdirectories starting with the
3429 root-directory, it is most likely sufficient to make the
3430 @code{default-directory} of the process buffer as the root directory.
3433 @node Traces and Profiles
3434 @chapter How to Customize Traces
3436 @value{tramp} messages are raised with verbosity levels ranging from 0
3437 to 10. @value{tramp} does not display all messages; only those with a
3438 verbosity level less than or equal to @code{tramp-verbose}.
3440 The verbosity levels are
3442 @w{ 0} silent (no @value{tramp} messages at all)
3443 @*@indent @w{ 1} errors
3444 @*@indent @w{ 2} warnings
3445 @*@indent @w{ 3} connection to remote hosts (default verbosity)
3446 @*@indent @w{ 4} activities
3447 @*@indent @w{ 5} internal
3448 @*@indent @w{ 6} sent and received strings
3449 @*@indent @w{ 7} file caching
3450 @*@indent @w{ 8} connection properties
3451 @*@indent @w{ 9} test commands
3452 @*@indent @w{10} traces (huge)
3454 With @code{tramp-verbose} greater than or equal to 4, messages are
3455 also written to a @value{tramp} debug buffer. Such debug buffers are
3456 essential to bug and problem analyses. For @value{tramp} bug reports,
3457 set the @code{tramp-verbose} level to 6 (@pxref{Bug Reports}).
3459 The debug buffer is in
3461 @ref{Outline Mode, , , emacs}.
3466 In this buffer, messages can be filtered by their level. To see
3467 messages up to verbosity level 5, enter @kbd{C-u 6 C-c C-q}.
3469 Other navigation keys are described in
3470 @ref{Outline Visibility, , , emacs}.
3473 @value{tramp} handles errors internally. But to get a Lisp backtrace,
3474 both the error and the signal have to be set as follows:
3477 (setq debug-on-error t
3481 To enable stepping through @value{tramp} function call traces, they
3482 have to be specifically enabled as shown in this code:
3486 (dolist (elt (all-completions "tramp-" obarray 'functionp))
3487 (trace-function-background (intern elt)))
3488 (untrace-function 'tramp-read-passwd)
3489 (untrace-function 'tramp-gw-basic-authentication)
3492 The buffer @file{*trace-output*} contains the output from the function
3493 call traces. Disable @code{tramp-read-passwd} and
3494 @code{tramp-gw-basic-authentication} to stop password strings from
3495 being written to @file{*trace-output*}.
3498 @node GNU Free Documentation License
3499 @appendix GNU Free Documentation License
3500 @include doclicense.texi
3503 @node Function Index
3504 @unnumbered Function Index
3508 @node Variable Index
3509 @unnumbered Variable Index
3514 @unnumbered Concept Index
3521 @c * Say something about the .login and .profile files of the remote
3523 @c * Explain how tramp.el works in principle: open a shell on a remote
3524 @c host and then send commands to it.
3525 @c * Consistent small or capitalized words especially in menus.
3526 @c * Make a unique declaration of @trampfn.