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 xxx and yyy are auxiliary macros in order to omit leading and
22 @c trailing whitespace. Not very elegant, but I don't know it better.
24 @c There are subtle differences between texinfo 4.13 and 5.0. We must
25 @c declare two versions of the macro. This will be improved, hopefully.
28 @ifset txicommandconditionals
41 @macro trampfn {method, user, host, localname}
43 @yyy{\method\,@value{postfixhop}}@c
45 \host\@value{postfix}\localname\
50 @ifclear txicommandconditionals
55 @macro yyy {one, two}@c
63 @macro trampfn {method, user, host, localname}@c
64 @value{prefix}@yyy{\method\,@value{postfixhop}}@yyy{\user\,@@}\host\@value{postfix}\localname\@c
69 Copyright @copyright{} 1999--2016 Free Software Foundation, Inc.
72 Permission is granted to copy, distribute and/or modify this document
73 under the terms of the GNU Free Documentation License, Version 1.3 or
74 any later version published by the Free Software Foundation; with no
75 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
76 and with the Back-Cover Texts as in (a) below. A copy of the license
77 is included in the section entitled ``GNU Free Documentation License''.
79 (a) The FSF's Back-Cover Text is: ``You have the freedom to
80 copy and modify this GNU manual.''
84 @c Entries for @command{install-info} to use
85 @dircategory Emacs network features
87 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
88 Emacs remote file access via ssh and scp.
92 @title @value{tramp} version @value{trampver} User Manual
93 @author by Daniel Pittman
94 @author based on documentation by Kai Großjohann
103 @node Top, Overview, (dir), (dir)
104 @top @value{tramp} version @value{trampver} User Manual
106 This file documents @value{tramp} version @value{trampver}, a remote file
107 editing package for Emacs.
109 @value{tramp} stands for ``Transparent Remote (file) Access, Multiple
110 Protocol''. This package provides remote file editing, similar to
113 The difference is that Ange FTP uses FTP to transfer files between the
114 local and the remote host, whereas @value{tramp} uses a combination of
115 @command{rsh} and @command{rcp} or other work-alike programs, such as
116 @command{ssh}/@command{scp}.
118 You can find the latest version of this document on the web at
119 @uref{http://www.gnu.org/software/tramp/}.
122 The latest release of @value{tramp} is available for
123 @uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
124 @ref{Obtaining Tramp} for more details, including the Git server
127 @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
128 Savannah Project Page}.
131 There is a mailing list for @value{tramp}, available at
132 @email{tramp-devel@@gnu.org}, and archived at
133 @uref{http://lists.gnu.org/archive/html/tramp-devel/, the
134 @value{tramp} Mail Archive}.
136 Older archives are located at
137 @uref{http://sourceforge.net/mailarchive/forum.php?forum=tramp-devel,
138 SourceForge Mail Archive} and
139 @uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/,
141 @c in HTML output, there's no new paragraph.
150 * Overview:: What @value{tramp} can and cannot do.
154 * Obtaining Tramp:: How to obtain @value{tramp}.
155 * History:: History of @value{tramp}.
156 @ifset installchapter
157 * Installation:: Installing @value{tramp} with your Emacs.
159 * Configuration:: Configuring @value{tramp} for use.
160 * Usage:: An overview of the operation of @value{tramp}.
161 * Bug Reports:: Reporting Bugs and Problems.
162 * Frequently Asked Questions:: Questions and answers from the mailing list.
166 * Files directories and localnames::
167 How file names, directories and localnames
168 are mangled and managed.
169 * Traces and Profiles:: How to Customize Traces.
171 * GNU Free Documentation License:: The license for this documentation.
172 * Function Index:: @value{tramp} functions.
173 * Variable Index:: User options and variables.
174 * Concept Index:: An item for each concept.
177 --- The Detailed Node Listing ---
179 @ifset installchapter
180 Installing @value{tramp} with your Emacs
182 * Installation parameters:: Parameters in order to control installation.
183 * Load paths:: How to plug-in @value{tramp} into your environment.
187 Configuring @value{tramp} for use
189 * Connection types:: Types of connections to remote hosts.
190 * Inline methods:: Inline methods.
191 * External methods:: External methods.
192 * GVFS based methods:: GVFS based external methods.
193 * Gateway methods:: Gateway methods.
194 * Default Method:: Selecting a default method.
195 * Default User:: Selecting a default user.
196 * Default Host:: Selecting a default host.
197 * Multi-hops:: Connecting to a remote host using multiple hops.
198 * Customizing Methods:: Using Non-Standard Methods.
199 * Customizing Completion:: Selecting config files for user/host name completion.
200 * Password handling:: Reusing passwords for several connections.
201 * Connection caching:: Reusing connection related information.
202 * Predefined connection information::
203 Setting own connection related information.
204 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
205 * Remote shell setup:: Remote shell setup hints.
206 * Android shell setup:: Android shell setup hints.
207 * Auto-save and Backup:: Auto-save and Backup.
208 * Windows setup hints:: Issues with Cygwin ssh.
212 * File name Syntax:: @value{tramp} file name conventions.
213 * File name completion:: File name completion.
214 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
215 * Remote processes:: Integration with other Emacs packages.
216 * Cleanup remote connections:: Cleanup remote connections.
218 How file names, directories and localnames are mangled and managed
220 * Localname deconstruction:: Breaking a localname into its components.
221 * External packages:: Integration with external Lisp packages.
228 @chapter An overview of @value{tramp}
231 @value{tramp} is for transparently accessing remote files from within
232 Emacs. @value{tramp} enables an easy, convenient, and consistent
233 interface to remote files as if they are local files. @value{tramp}'s
234 transparency extends to editing, version control, and @code{dired}.
236 @value{tramp} can access remote hosts using any number of access
237 methods, such as @command{rsh}, @command{rlogin}, @command{telnet},
238 and related programs. If these programs can successfully pass
239 @acronym{ASCII]} characters, @value{tramp} can use them.
240 @value{tramp} does not require or mandate 8-bit clean connections.
242 @value{tramp}'s most common access method is through @command{ssh}, a
243 more secure alternative to @command{ftp} and other older access
246 @value{tramp} on Windows operating systems is integrated with the
247 PuTTY package, and uses the @command{plink} program.
249 @value{tramp} mostly operates transparently in the background using
250 the connection programs. As long as these programs enable remote login
251 and can use the terminal, @value{tramp} can adapt them for seamless
252 and transparent access.
254 @value{tramp} temporarily transfers a remote file's contents to the
255 local host editing and related operations. @value{tramp} can also
256 transfer files between hosts using standard Emacs interfaces, a
257 benefit of direct integration of @value{tramp} in Emacs.
259 @value{tramp} can transfer files using any number of available host
260 programs for remote files, such as @command{rcp}, @command{scp},
261 @command{rsync} or (under Windows) @command{pscp}. @value{tramp}
262 provides easy ways to specify these programs and customize them to
263 specific files, hosts, or access methods.
265 For faster small-size file transfers, @value{tramp} supports encoded
266 transfers directly through the shell using @command{mimencode} or
267 @command{uuencode} provided such tools are available on the remote
271 @subsubheading @value{tramp} behind the scenes
272 @cindex behind the scenes
273 @cindex details of operation
276 Accessing a remote file through @value{tramp} entails a series of
277 actions, many of which are transparent to the user. Yet some actions
278 may require user response (such as entering passwords or completing
279 file names). One typical scenario, opening a file on a remote host, is
280 presented here to illustrate the steps involved:
282 @kbd{C-x C-f} to initiate find-file, enter part of the @value{tramp}
283 file name, then hit @kbd{@key{TAB}} for completion. If this is the
284 first time connection to that host, here's what happens:
288 @value{tramp} invokes @samp{telnet @var{host}} or @samp{rsh @var{host}
289 -l @var{user}} and establishes an external process to connect to the
290 remote host. @value{tramp} communicates with the process through an
291 Emacs buffer, which also shows output from the remote host.
294 The remote host may prompt for a login name (for @command{telnet}, for
295 example) in the buffer. If on the other hand, the login name was
296 included in the file name portion, @value{tramp} sends the login name
297 followed by a newline.
300 The remote host may then prompt for a password or pass phrase (for
301 @command{rsh} or for @command{telnet}). @value{tramp} displays the
302 password prompt in the minibuffer. @value{tramp} then sends whatever
303 is entered to the remote host, followed by a newline.
306 @value{tramp} now waits for either the shell prompt or a failed login
309 If @value{tramp} does not receive any messages within a timeout period
310 (a minute, for example), then @value{tramp} responds with an error
311 message about not finding the remote shell prompt. If any messages
312 from the remote host, @value{tramp} displays them in the buffer.
314 For any @samp{login failed} message from the remote host,
315 @value{tramp} aborts the login attempt, and repeats the login steps
319 Upon successful login and @value{tramp} recognizes the shell prompt
320 from the remote host, @value{tramp} prepares the shell environment by
321 turning off echoing, setting shell prompt, and other housekeeping
324 @strong{Note} that for the remote shell, @value{tramp} invokes
325 @command{/bin/sh}. The remote host must recognize @samp{exec /bin/sh}
326 and execute the appropriate shell. This shell must support Bourne
330 @value{tramp} executes @command{cd} and @command{ls} commands to find
331 which files exist on the remote host. @value{tramp} sometimes uses
332 @command{echo} with globbing. @value{tramp} checks if a file or
333 directory is writable with @command{test}. After each command,
334 @value{tramp} parses the output from the remote host for completing
338 After remote file name completion, @value{tramp} transfers the file
339 contents from the remote host.
341 For inline transfers, @value{tramp} sends a command, such as
342 @samp{mimencode -b /path/to/remote/file}, waits until the output has
343 accumulated in the buffer, decodes that output to produce the file's
346 For external transfers, @value{tramp} sends a command as follows:
348 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
350 @value{tramp} reads the local temporary file @file{/tmp/tramp.4711}
351 into a buffer, and then deletes the temporary file.
354 Edit, modify, change the buffer contents as normal, and then save the
355 buffer wth @kbd{C-x C-s}.
358 @value{tramp} transfers the buffer contents to the remote host in
359 a reverse of the process using the appropriate inline or external
363 I hope this has provided you with a basic overview of what happens
364 behind the scenes when you open a file with @value{tramp}.
368 @node Obtaining Tramp
369 @chapter Obtaining @value{tramp}
370 @cindex obtaining Tramp
372 @value{tramp} is included as part of Emacs (since Emacs version 22.1).
374 @value{tramp} is also freely packaged for download on the Internet at
375 @uref{ftp://ftp.gnu.org/gnu/tramp/}.
377 @value{tramp} development versions are available on Git servers.
378 Development versions contain new and incomplete features.
380 One way to obtain from Git server is to visit the Savannah project
381 page at the following URL and then clicking on the Git link in the
382 navigation bar at the top.
385 @uref{http://savannah.gnu.org/projects/tramp/}
388 Another way is to follow the terminal session below:
391 ] @strong{cd ~/emacs}
392 ] @strong{git clone git://git.savannah.gnu.org/tramp.git}
396 From behind a firewall:
399 ] @strong{git config --global http.proxy http://user:pwd@@proxy.server.com:8080}
400 ] @strong{git clone http://git.savannah.gnu.org/r/tramp.git}
407 ] @strong{git clone login@@git.sv.gnu.org:/srv/git/tramp.git}
411 After one of the above commands, @file{~/emacs/tramp} will
412 containing the latest version of @value{tramp}.
415 To fetch updates from the repository, use git pull:
418 ] @strong{cd ~/emacs/tramp}
423 Run @command{autoconf} as follows to generate an up-to-date
424 @file{configure} script:
427 ] @strong{cd ~/emacs/tramp}
433 @chapter History of @value{tramp}
435 @cindex development history
437 @value{tramp} development started at the end of November 1998 as
438 @file{rssh.el}. It provided only one method of access. It used
439 @command{ssh} for login and @command{scp} to transfer file contents.
440 The name was changed to @file{rcp.el} before it got its preset name
441 @value{tramp}. New methods of remote access were added, so was support
444 April 2000 was the first time when multi-hop methods were added. In
445 July 2002, @value{tramp} unified file names with Ange-FTP@. In July
446 2004, proxy hosts replaced multi-hop methods. Running commands on
447 remote hosts was introduced in December 2005. Support for gateways
450 GVFS integration started in February 2009.
452 Remote commands on Windows hosts since September 2011. Ad-hoc
453 multi-hop methods (with a changed syntax) re-enabled in November 2011.
455 In November 2012, added Juergen Hoetzel's @file{tramp-adb.el}.
458 @c Installation chapter is necessary only in case of standalone
459 @c installation. Text taken from trampinst.texi.
460 @ifset installchapter
461 @include trampinst.texi
466 @chapter Configuring @value{tramp}
467 @cindex configuration
468 @cindex default configuration
470 @value{tramp} is initially configured to use the @command{scp} program
471 to connect to the remote host. Just type @kbd{C-x C-f} and then enter
472 file name @file{@trampfn{, user, host, /path/to.file}}. For details,
473 see @xref{Default Method}.
475 For problems related to the behavior of remote shell, see @ref{Remote
476 shell setup} for details.
478 For changing the connection type and file access method from the
479 defaults to one of several other options, see (@pxref{Connection
482 @strong{Note} that some user options and variables described in these
483 examples are not auto loaded by Emacs. All examples require
484 @value{tramp} is installed and loaded:
492 * Connection types:: Types of connections to remote hosts.
493 * Inline methods:: Inline methods.
494 * External methods:: External methods.
495 * GVFS based methods:: GVFS based external methods.
496 * Gateway methods:: Gateway methods.
497 * Default Method:: Selecting a default method.
498 Here we also try to help those who
499 don't have the foggiest which method
501 * Default User:: Selecting a default user.
502 * Default Host:: Selecting a default host.
503 * Multi-hops:: Connecting to a remote host using multiple hops.
504 * Customizing Methods:: Using Non-Standard Methods.
505 * Customizing Completion:: Selecting config files for user/host name completion.
506 * Password handling:: Reusing passwords for several connections.
507 * Connection caching:: Reusing connection related information.
508 * Predefined connection information::
509 Setting own connection related information.
510 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
511 * Remote shell setup:: Remote shell setup hints.
512 * Android shell setup:: Android shell setup hints.
513 * Auto-save and Backup:: Auto-save and Backup.
514 * Windows setup hints:: Issues with Cygwin ssh.
518 @node Connection types
519 @section Types of connections to remote hosts
520 @cindex connection types, overview
522 @dfn{Inline method} and @dfn{external method} are the two basic types
523 of access methods. While they both use the same remote shell access
524 programs, such as @command{rsh}, @command{ssh}, or @command{telnet},
525 they differ in the file access methods. Choosing the right method
526 becomes important for editing files, transferring large files, or
527 operating on a large number of files.
529 @cindex inline methods
530 @cindex external methods
531 @cindex methods, inline
532 @cindex methods, external
534 The performance of the external methods is generally better than that
535 of the inline methods, at least for large files. This is caused by
536 the need to encode and decode the data when transferring inline.
538 The one exception to this rule are the @option{scp}-based access
539 methods. While these methods do see better performance when actually
540 transferring files, the overhead of the cryptographic negotiation at
541 startup may drown out the improvement in file transfer times.
543 External methods should be configured such a way that they don't
544 require a password (with @command{ssh-agent}, or such alike). Modern
545 @command{scp} implementations offer options to reuse existing
546 @command{ssh} connections, which will be enabled by default if
547 available. If it isn't possible, you should consider @ref{Password
548 handling}, otherwise you will be prompted for a password every copy
553 @section Inline methods
554 @cindex inline methods
555 @cindex methods, inline
557 Inline methods use the same login connection to transfer file
558 contents. Inline methods are quick and easy for small files. They
559 depend on the availability of suitable encoding and decoding programs
560 on the remote host. For local source and destination, @value{tramp}
561 may use built-in equivalents of such programs in Emacs.
563 Inline methods can work in situations where an external transfer
564 program is unavailable. Inline methods also work when transferring
565 files between different @emph{user identities} on the same host.
569 @cindex base-64 encoding
571 @value{tramp} checks the remote host for the availability and
572 usability of @command{mimencode} (part of the @command{metamail}
573 package) or @command{uuencode}. @value{tramp} uses the first reliable
574 command it finds. @value{tramp}'s search path can be customized, see
575 @ref{Remote programs}.
577 In case both @command{mimencode} and @command{uuencode} are
578 unavailable, @value{tramp} first transfers a small Perl program to the
579 remote host, and then tries that program for encoding and decoding.
581 To increase transfer speeds for large text files, use compression
582 before encoding. The variable @var{tramp-inline-compress-start-size}
583 specifies the file size for such optimization.
590 @command{rsh} is an option for connecting to hosts within local
591 networks since @command{rsh} is not as secure as other methods.
597 @command{ssh} is a more secure option than others to connect to a
600 @command{ssh} can also take extra parameters as port numbers. For
601 example, a host on port 42 is specified as @file{host#42} (the real
602 host name, a hash sign, then a port number). It is the same as passing
603 @code{-p 42} to the @command{ssh} command.
605 @item @option{telnet}
606 @cindex method telnet
607 @cindex telnet method
609 Connecting to a remote host with @command{telnet} is as insecure
610 as the @option{rsh} method.
616 Instead of connecting to a remote host, @command{su} program allows
617 editing as another user. The host can be either @samp{localhost} or
618 the host returned by the function @command{(system-name)}. See
619 @ref{Multi-hops} for an exception to this behavior.
625 Similar to @option{su} method, @option{sudo} uses @command{sudo}.
626 @command{sudo} must have sufficient rights to start a shell.
632 The @command{sg} program allows editing as different group. The host
633 can be either @samp{localhost} or the host returned by the function
634 @command{(system-name)}. The user name must be specified, but it
635 denotes a group name. See @ref{Multi-hops} for an exception to this
642 Works like @option{ssh} but without the extra authentication prompts.
643 @option{sshx} uses @samp{ssh -t -t @var{host} -l @var{user} /bin/sh}
644 to open a connection with a ``standard'' login shell.
646 @strong{Note} that @option{sshx} does not bypass authentication
647 questions. For example, if the host key of the remote host is not
648 known, @option{sshx} will still ask ``Are you sure you want to
649 continue connecting?''. @value{tramp} cannot handle such questions.
650 Connections will have to be setup where logins can proceed without
653 @option{sshx} is useful for Windows users when @command{ssh} triggers
654 an error about allocating a pseudo tty. This happens due to missing
655 shell prompts that confuses @value{tramp}.
657 @option{sshx} supports the @samp{-p} argument.
659 @item @option{krlogin}
660 @cindex method krlogin
661 @cindex krlogin method
662 @cindex Kerberos (with krlogin method)
664 This method is also similar to @option{ssh}. It uses the
665 @command{krlogin -x} command only for remote host login.
670 @cindex Kerberos (with ksu method)
672 This is another method from the Kerberos suite. It behaves like @option{su}.
678 @option{plink} method is for Windows users with the PuTTY
679 implementation of SSH@. It uses @samp{plink -ssh} to log in to the
682 Check the @samp{Share SSH connections if possible} control for that
685 @option{plink} method supports the @samp{-P} argument.
687 @item @option{plinkx}
688 @cindex method plinkx
689 @cindex plinkx method
691 Another method using PuTTY on Windows with session names instead of
692 host names. @option{plinkx} calls @samp{plink -load @var{session} -t}.
693 User names and port numbers must be defined in the session.
695 Check the @samp{Share SSH connections if possible} control for that
701 @node External methods
702 @section External methods
703 @cindex methods, external
704 @cindex external methods
706 External methods operate over multiple channels, using the remote
707 shell connection for some actions while delegating file transfers to
708 an external transfer program.
710 External methods save on the overhead of encoding and decoding of
713 Since external methods have the overhead of opening a new channel,
714 files smaller than @var{tramp-copy-size-limit} still use inline
718 @item @option{rcp}---@command{rsh} and @command{rcp}
721 @cindex rcp (with rcp method)
722 @cindex rsh (with rcp method)
724 This method uses the @command{rsh} and @command{rcp} commands to
725 connect to the remote host and transfer files. This is the fastest
726 access method available.
728 The alternative method @option{remcp} uses the @command{remsh} and
729 @command{rcp} commands.
731 @item @option{scp}---@command{ssh} and @command{scp}
734 @cindex scp (with scp method)
735 @cindex ssh (with scp method)
737 Using a combination of @command{ssh} to connect and @command{scp} to
738 transfer is the most secure. While the performance is good, it is
739 slower than the inline methods for smaller files. Though there is no
740 overhead of encoding and decoding of the inline methods,
741 @command{scp}'s cryptographic handshake negates those speed gains.
743 @option{ssh}-based methods support @samp{-p} feature for specifying
744 port numbers. For example, @file{host#42} passes @samp{-p 42} in the
745 argument list to @command{ssh}, and @samp{-P 42} in the argument list
748 @item @option{rsync}---@command{ssh} and @command{rsync}
751 @cindex rsync (with rsync method)
752 @cindex ssh (with rsync method)
754 @command{ssh} command to connect in combination with @command{rsync}
755 command to transfer is similar to the @option{scp} method.
757 @command{rsync} performs much better than @command{scp} when
758 transferring files that exist on both hosts. However, this advantage
759 is lost if the file exists only on one side of the connection.
761 This method supports the @samp{-p} argument.
763 @item @option{scpx}---@command{ssh} and @command{scp}
766 @cindex scp (with scpx method)
767 @cindex ssh (with scpx method)
769 @option{scpx} is useful to avoid login shell questions. It is similar
770 in performance to @option{scp}. @option{scpx} uses @samp{ssh -t -t
771 @var{host} -l @var{user} /bin/sh} to open a connection.
773 @option{sshx} is useful for Windows users when @command{ssh} triggers
774 an error about allocating a pseudo tty. This happens due to missing
775 shell prompts that confuses @value{tramp}.
777 This method supports the @samp{-p} argument.
779 @item @option{pscp}---@command{plink} and @command{pscp}
780 @item @option{psftp}---@command{plink} and @command{psftp}
783 @cindex pscp (with pscp method)
784 @cindex plink (with pscp method)
785 @cindex PuTTY (with pscp method)
788 @cindex pscp (with psftp method)
789 @cindex plink (with psftp method)
790 @cindex PuTTY (with psftp method)
792 These methods are similar to @option{scp} or @option{sftp}, but they
793 use the @command{plink} command to connect to the remote host, and
794 they use @command{pscp} or @command{psftp} for transferring the files.
795 These programs are part of PuTTY, an SSH implementation for Windows.
797 Check the @samp{Share SSH connections if possible} control for that
800 These methods support the @samp{-P} argument.
802 @item @option{fcp}---@command{fsh} and @command{fcp}
805 @cindex fsh (with fcp method)
806 @cindex fcp (with fcp method)
808 This method is similar to @option{scp}, but uses @command{fsh} to
809 connect and @command{fcp} to transfer files. @command{fsh/fcp}, a
810 front-end for @command{ssh}, reuse @command{ssh} session by
811 submitting several commands. This avoids the startup overhead due to
812 @command{scp}'s secure connection. Inline methods have similar
815 The command used for this connection is: @samp{fsh @var{host} -l
816 @var{user} /bin/sh -i}
821 @option{fsh} has no inline method since the multiplexing it offers is
822 not useful for @value{tramp}. @command{fsh} connects to remote host
823 and @value{tramp} keeps that one connection open.
825 @item @option{nc}---@command{telnet} and @command{nc}
828 @cindex nc (with nc method)
829 @cindex telnet (with nc method)
831 Using @command{telnet} to connect and @command{nc} to transfer files
832 is sometimes the only combination suitable for accessing routers or
833 NAS hosts. These dumb devices have severely restricted local shells,
834 such as the @command{busybox} and do not host any other encode or
841 When @value{tramp} uses @option{ftp}, it forwards requests to whatever
842 ftp program is specified by Ange FTP. This external program must be
843 capable of servicing requests from @value{tramp}.
845 @item @option{smb}---@command{smbclient}
849 This is another non-native @value{tramp} method. @command{smbclient}
850 connects to any host with SMB/CIFS protocol, such as MS Windows and
851 Samba Servers running on Unixes. Tests show this @value{tramp} method
852 works with MS Windows NT, MS Windows 2000, MS Windows XP, MS Windows
853 Vista, and MS Windows 7.
855 Using @command{smbclient} requires a few tweaks when working with
858 The first directory in the localname must be a share name on the
861 Since smb shares end in the @code{$} character, @value{tramp} must use
862 @code{$$} when specifying those shares to avoid environment variable
865 When @value{tramp} is not specific about the share name or uses the
866 generic remote directory @code{/}, @command{smbclient} returns all
869 Since SMB authentication is based on each SMB share, @value{tramp}
870 prompts for a password even when accessing a different share on the
871 same SMB host. This prompting can be suppressed by @ref{Password
874 To accommodate user name/domain name syntax required by MS Windows
875 authorization, @value{tramp} provides for an extended syntax in
876 @code{user%domain} format (where user is username, @code{%} is the
877 percent symbol, and domain is the windows domain name). An example:
880 @trampfn{smb, daniel%BIZARRE, melancholia, /daniel$$/.emacs}
883 where user @code{daniel} connects as a domain user to the SMB host
884 @code{melancholia} in the windows domain @code{BIZARRE} to edit
885 @file{.emacs} located in the home directory (share @code{daniel$}).
887 Alternatively, for local WINS users (as opposed to domain users),
888 substitute the domain name with the name of the local host in
889 UPPERCASE as shown here:
892 @trampfn{smb, daniel%MELANCHOLIA, melancholia, /daniel$$/.emacs}
895 where user @code{daniel} connects as local user to the SMB host
896 @code{melancholia} in the local domain @code{MELANCHOLIA} to edit
897 @file{.emacs} located in the home directory (share @code{daniel$}).
899 The domain name and user name are optional for @command{smbclient}
900 authentication. When user name is not specified, @command{smbclient}
901 uses the anonymous user (without prompting for password). This
902 behavior is unlike other @value{tramp} methods, where local user name
905 @option{smb} method is unavailable if Emacs is run under a local user
906 authentication context in MS Windows. However such users can still
907 access remote files using UNC file names instead of @value{tramp}:
910 //melancholia/daniel$$/.emacs
913 UNC file name specification does not allow to specify a different user
914 name for authentication like the @command{smbclient} can.
920 This method uses Android Debug Bridge program for accessing Android
921 devices. The Android Debug Bridge must be installed locally for
922 @value{tramp} to work. Some GNU/Linux distributions provide Android
923 Debug Bridge as an installation package. Alternatively, the program is
924 installed as part of the Android SDK@. @value{tramp} finds the
925 @command{adb} program either via the @env{PATH} environment variable
926 or the absolute path set in the variable @var{tramp-adb-program}.
928 @value{tramp} connects to Android devices with @option{adb} only when
929 the custom option @option{tramp-adb-connect-if-not-connected} is not
930 @code{nil}. Otherwise, the connection must be established outside
933 @value{tramp} does not require a host name part of the remote file
934 name when a single Android device is connected to @command{adb}.
935 @value{tramp} instead uses @file{@trampfn{adb, , ,}} as the default
936 name. @command{adb devices} shows available host names.
938 @option{adb} method normally does not need user name to authenticate
939 on the Andriod device because it runs under the @command{adbd}
940 process. But when a user name is specified, however, @value{tramp}
941 applies an @command{su} in the syntax. When authentication does not
942 succeed, especially on un-rooted Android devices, @value{tramp}
943 displays login errors.
945 For Andriod devices connected through TCP/IP, a port number can be
946 specified using @file{device#42} host name syntax or @value{tramp} can
947 use the default value as declared in @command{adb} command. Port
948 numbers are not applicable to Android devices connected through USB@.
954 @node GVFS based methods
955 @section GVFS based external methods
956 @cindex methods, gvfs
957 @cindex gvfs based methods
960 GVFS is the virtual file system for the Gnome Desktop,
961 @uref{http://en.wikipedia.org/wiki/GVFS}. Remote files on GVFS are
962 mounted locally through FUSE and @value{tramp} uses this locally
963 mounted directory internally.
965 Emacs uses the D-Bus mechanism to communicate with GVFS@. Emacs must
966 have the message bus system, D-Bus integration active, @pxref{Top, ,
974 This method is for connecting to remote hosts with the Apple Filing
975 Protocol for accessing files on Mac OS X volumes. @value{tramp} access
976 syntax requires a leading volume (share) name, for example:
977 @file{@trampfn{afp, user, host, /volume}}.
986 @option{dav} method provides access to WebDAV files and directories
987 based on standard protocols, such as HTTP@. @option{davs} does the same
988 but with SSL encryption. Both methods support the port numbers.
994 OBEX is an FTP-like access protocol for cell phones and similar simple
995 devices. @value{tramp} supports OBEX over Bluetooth.
1001 This method uses @command{sftp} in order to securely access remote
1002 hosts. @command{sftp} is a more secure option for connecting to hosts
1003 that for security reasons refuse @command{ssh} connections.
1005 @item @option{synce}
1006 @cindex method synce
1007 @cindex synce method
1009 @option{synce} method allows connecting to Windows Mobile devices. It
1010 uses GVFS for mounting remote files and directories via FUSE and
1011 requires the SYNCE-GVFS plugin.
1015 @defopt tramp-gvfs-methods
1016 @vindex tramp-gvfs-methods
1017 This custom option is a list of external methods for GVFS@. By
1018 default, this list includes @option{afp}, @option{dav}, @option{davs},
1019 @option{obex}, @option{sftp} and @option{synce}. Other methods to
1020 include are: @option{ftp} and @option{smb}.
1025 @node Gateway methods
1026 @section Gateway methods
1027 @cindex methods, gateway
1028 @cindex gateway methods
1030 Gateway methods are for proxy host declarations (@pxref{Multi-hops})
1031 so as to pass through firewalls and proxy servers. They are not like
1032 the other methods that declare direct connections to a remote host.
1034 A gateway method always comes with a port setting. @value{tramp}
1035 targets the port number with the gateway method
1036 @file{localhost#random_port} from where the firewall or proxy server
1039 Gateway methods support user name and password declarations for
1040 authenticating the corresponding firewall or proxy server. Such
1041 authentication can be passed through only if granted access by system
1045 @item @option{tunnel}
1046 @cindex method tunnel
1047 @cindex tunnel method
1049 This method implements an HTTP tunnel via the @command{CONNECT}
1050 command (conforming to RFC 2616, 2817 specifications). Proxy servers
1051 using HTTP version 1.1 or later protocol support this command.
1053 For authentication, this protocol uses only @option{Basic
1054 Authentication} (see RFC 2617). When no port number is specified, this
1055 protocol defaults to @option{8080}.
1057 @item @option{socks}
1058 @cindex method socks
1059 @cindex socks method
1061 The @option{socks} method connects to SOCKSv5 servers (see RFC 1928)
1062 and supports @option{Username/Password Authentication}.
1064 The default port number for the socks server is @option{1080}, if not
1065 specified otherwise.
1070 @node Default Method
1071 @section Selecting a default method
1072 @cindex default method
1073 @vindex tramp-default-method
1074 @vindex tramp-default-method-alist
1076 Default method is for transferring files. The variable
1077 @code{tramp-default-method} sets it. @value{tramp} uses this variable
1078 to determine the default method for tramp file names that do not have
1082 (setq tramp-default-method "ssh")
1085 Default methods for transferring files can be customized for specific
1086 user and host combinations through the alist variable
1087 @code{tramp-default-method-alist}.
1089 For example, the following two lines specify to use the @option{ssh}
1090 method for all user names matching @samp{john} and the @option{rsync}
1091 method for all host names matching @samp{lily}. The third line
1092 specifies to use the @option{su} method for the user @samp{root} on
1093 the host @samp{localhost}.
1096 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1097 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1098 (add-to-list 'tramp-default-method-alist
1099 '("\\`localhost\\'" "\\`root\\'" "su"))
1103 See the documentation for the variable
1104 @code{tramp-default-method-alist} for details.
1107 External methods performance faster for large files.
1110 @xref{Inline methods}.
1111 @xref{External methods}.
1113 Choosing the access method also depends on the security environment.
1114 For example, @option{rsh} and @option{telnet} methods that use clear
1115 text password transfers are inappropriate for over the Internet
1116 connections. Secure remote connections should use @option{ssh} that
1120 @subsection Which method to use?
1121 @cindex choosing the right method
1123 @value{tramp} provides maximum number of choices for maximum
1124 flexibility. Choosing which method depends on the hosts, clients,
1125 network speeds, and the security context.
1127 Start by using an inline method.
1129 External methods might be more efficient for large files, but most
1130 @value{tramp} users edit small files more often than large files.
1132 Enable compression, @var{tramp-inline-compress-start-size}, for a
1133 performance boost for large files.
1135 Since @command{ssh} has become the most common method of remote host
1136 access and it has the most reasonable security protocols, use
1137 @option{ssh} method. Typical @option{ssh} usage to edit the
1138 @file{/etc/motd} file on the otherhost:
1141 @kbd{C-x C-f @trampfn{ssh, root, otherhost,/etc/motd} @key{RET}}
1144 If @option{ssh} is unavailable for whatever reason, look for other
1145 obvious options. For Windows, try the @option{plink} method. For
1146 Kerberos, try @option{krlogin}.
1148 For editing local files as @option{su} or @option{sudo} methods, try
1149 the shortened syntax of @samp{root}:
1152 @kbd{C-x C-f @trampfn{su, , , /etc/motd} @key{RET}}
1155 For editing large files, @option{scp} is faster than @option{ssh}.
1156 @option{pscp} is faster than @option{plink}. But this speed
1157 improvement is not always true.
1161 @section Selecting a default user
1162 @cindex default user
1163 @vindex tramp-default-user
1164 @vindex tramp-default-user-alist
1166 @value{tramp} file name can omit the user name part since
1167 @value{tramp} substitutes the currently logged-in user name. However
1168 this substitution can be overridden with @code{tramp-default-user}.
1172 (setq tramp-default-user "root")
1175 Instead of a single default user, @code{tramp-default-user-alist}
1176 allows multiple default user values based on access method or host
1177 name combinations. The alist can hold multiple values. For example, to
1178 use the @samp{john} as the default user for the domain
1179 @samp{somewhere.else} only:
1182 (add-to-list 'tramp-default-user-alist
1183 '("ssh" ".*\\.somewhere\\.else\\'" "john"))
1187 See the documentation for the variable @code{tramp-default-user-alist}
1190 A Caution: @value{tramp} will override any default user specified in
1191 the configuration files outside Emacs, such as @file{~/.ssh/config}.
1192 To stop @value{tramp} from applying the default value, set the
1193 corresponding alist entry to nil:
1196 (add-to-list 'tramp-default-user-alist
1197 '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
1200 The last entry in @code{tramp-default-user-alist} should be reserved
1201 for catch-all or most often used login.
1204 (add-to-list 'tramp-default-user-alist
1205 '(nil nil "jonas") t)
1210 @section Selecting a default host
1211 @cindex default host
1212 @vindex tramp-default-host
1213 @vindex tramp-default-host-alist
1215 When host name is omitted, @value{tramp} substitutes the value from
1216 the @code{tramp-default-host} variable. It is initially populated
1217 with the local hostname where Emacs is running. Both the default user
1218 and default host can be overridden as follows:
1221 (setq tramp-default-user "john"
1222 tramp-default-host "target")
1225 With both defaults set, @samp{@trampfn{ssh, , ,}} will connect
1226 @value{tramp} to John's home directory on target.
1228 @strong{Note} @samp{/::} won't work, because @samp{/:} is the prefix
1229 for quoted file names.
1231 Instead of a single default host, @code{tramp-default-host-alist}
1232 allows multiple default host values based on access method or user
1233 name combinations. The alist can hold multiple values. While
1234 @code{tramp-default-host} is sufficient in most cases, some methods,
1235 like @option{adb}, require defaults overwritten.
1238 See the documentation for the variable @code{tramp-default-host-alist}
1243 @section Connecting to a remote host using multiple hops
1247 Multi-hops are methods to reach hosts behind firewalls or to reach the
1248 outside world from inside a bastion host. With multi-hops,
1249 @value{tramp} can negotiate these hops with the appropriate user/host
1250 authentication at each hop. All methods until now have been the single
1251 hop kind, where the start and end points of the connection did not
1252 have intermediate check points.
1254 @defopt tramp-default-proxies-alist
1255 @vindex tramp-default-proxies-alist
1256 @option{tramp-default-proxies-alist} specifies proxy hosts to pass
1257 through. This variable is list of triples consisting of (@var{host}
1258 @var{user} @var{proxy}).
1260 The first match is the proxy host through which passes the file name
1261 and the target host matching @var{user}@@@var{host}. @var{host} and
1262 @var{user} are regular expressions or @code{nil}, interpreted as a
1263 regular expression which always matches.
1265 @var{proxy} is a literal @value{tramp} file name whose local name part
1266 is ignored, and the method and user name parts are optional.
1268 The method must be an inline or gateway method (@pxref{Inline
1269 methods}, @pxref{Gateway methods}).
1270 If @var{proxy} is @code{nil}, no additional hop is required reaching
1271 @var{user}@@@var{host}.
1273 For example, to pass through the host @samp{bastion.your.domain} as
1274 user @samp{bird} to reach remote hosts outside the local domain:
1277 (add-to-list 'tramp-default-proxies-alist
1278 '("\\." nil "@trampfn{ssh, bird, bastion.your.domain,}"))
1279 (add-to-list 'tramp-default-proxies-alist
1280 '("\\.your\\.domain\\'" nil nil))
1283 @strong{Note}: @code{add-to-list} adds elements at the beginning of a
1284 list. Therefore, most relevant rules must come last in the list.
1286 Proxy hosts can be cascaded in the alist. If there is another host
1287 called @samp{jump.your.domain}, which is the only host allowed to
1288 connect to @samp{bastion.your.domain}, then:
1291 (add-to-list 'tramp-default-proxies-alist
1292 '("\\`bastion\\.your\\.domain\\'"
1294 "@trampfn{ssh, , jump.your.domain,}"))
1297 @var{proxy} can take patterns @code{%h} or @code{%u} for @var{host} or
1298 @var{user} respectively.
1300 To login as @samp{root} on remote hosts in the domain
1301 @samp{your.domain}, but login as @samp{root} is disabled for non-local
1302 access, then use this alist entry:
1305 (add-to-list 'tramp-default-proxies-alist
1306 '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh, , %h,}"))
1309 Opening @file{@trampfn{sudo, , randomhost.your.domain,}} first
1310 connects to @samp{randomhost.your.domain} via @code{ssh} under your
1311 account name, and then perform @code{sudo -u root} on that host.
1313 It is key for the sudo method in the above example to be applied on
1314 the host after reaching it and not on the local host.
1316 @var{host}, @var{user} and @var{proxy} can also take Lisp forms. These
1317 forms when evaluated must return either a string or @code{nil}.
1319 To generalize (from the previous example): For all hosts, except my
1320 local one, first connect via @command{ssh}, and then apply
1321 @command{sudo -u root}:
1324 (add-to-list 'tramp-default-proxies-alist
1325 '(nil "\\`root\\'" "@trampfn{ssh, , %h,}"))
1326 (add-to-list 'tramp-default-proxies-alist
1327 '((regexp-quote (system-name)) nil nil))
1330 The above configuration allows @value{tramp} connection as @samp{root}
1331 to remote Ubuntu hosts.
1333 @code{tramp-default-proxies-alist} is also used for passing through
1334 firewalls or proxy servers.
1336 For example, the local host @samp{proxy.your.domain} on port 3128
1337 serves as HTTP proxy to the outer world. User has access rights to
1338 another proxy server on @samp{host.other.domain}.@footnote{HTTP tunnels
1339 are intended for secure SSL/TLS communication. Therefore, many proxy
1340 servers restrict the tunnels to related target ports. You might need
1341 to run your ssh server on your target host @samp{host.other.domain} on
1342 such a port, like 443 (https). See
1343 @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall} for
1344 discussion of ethical issues.} Then the configuration is:
1347 (add-to-list 'tramp-default-proxies-alist
1348 '("\\`host\\.other\\.domain\\'" nil
1349 "@trampfn{tunnel, , proxy.your.domain#3128,}"))
1352 Gateway methods in a multiple hop chain can be declared only as the first hop.
1355 Passing through hops involves dealing with restricted shells, such as
1356 @command{rbash}. If @value{tramp} is made aware, then it would use
1357 them for proxies only.
1359 @defopt tramp-restricted-shell-hosts-alist
1360 @vindex tramp-restricted-shell-hosts-alist
1361 An alist of regular expressions of hosts running restricted shells,
1362 such as @command{rbash}. @value{tramp} will then use them only as
1365 To specify the bastion host from the example above as running a
1369 (add-to-list 'tramp-restricted-shell-hosts-alist
1370 "\\`bastion\\.your\\.domain\\'")
1375 @node Customizing Methods
1376 @section Using Non-Standard Methods
1377 @cindex customizing methods
1378 @cindex using non-standard methods
1379 @cindex create your own methods
1381 The @code{tramp-methods} variable currently has an exhaustive list of
1382 predefined methods. Any part of this list can be modified with more
1383 suitable settings. Refer to the Lisp documentation of that variable,
1384 accessible with @kbd{C-h v tramp-methods @key{RET}}.
1387 @node Customizing Completion
1388 @section Selecting config files for user/host name completion
1389 @cindex customizing completion
1390 @cindex selecting config files
1391 @vindex tramp-completion-function-alist
1393 @code{tramp-completion-function-alist} uses predefined files for user
1394 and host name completion (@pxref{File name completion}). For each
1395 method, it keeps a set of configuration files and a function that can
1396 parse that file. Each entry in @code{tramp-completion-function-alist}
1397 is of the form (@var{method} @var{pair1} @var{pair2} @dots{}).
1399 Each @var{pair} is composed of (@var{function} @var{file}).
1400 @var{function} is responsible for extracting user names and host names
1401 from @var{file} for completion. There are two functions which access
1404 @defun tramp-get-completion-function method
1405 This function returns the list of completion functions for @var{method}.
1409 (tramp-get-completion-function "rsh")
1411 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1412 (tramp-parse-rhosts "~/.rhosts"))
1416 @defun tramp-set-completion-function method function-list
1417 This function sets @var{function-list} as list of completion functions
1422 (tramp-set-completion-function "ssh"
1423 '((tramp-parse-sconfig "/etc/ssh_config")
1424 (tramp-parse-sconfig "~/.ssh/config")))
1426 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1427 (tramp-parse-sconfig "~/.ssh/config"))
1431 The following predefined functions parsing configuration files exist:
1434 @item @code{tramp-parse-rhosts}
1435 @findex tramp-parse-rhosts
1437 This function parses files which are syntactical equivalent to
1438 @file{~/.rhosts}. It returns both host names and user names, if
1441 @item @code{tramp-parse-shosts}
1442 @findex tramp-parse-shosts
1444 This function parses files which are syntactical equivalent to
1445 @file{~/.ssh/known_hosts}. Since there are no user names specified
1446 in such files, it can return host names only.
1448 @item @code{tramp-parse-sconfig}
1449 @findex tramp-parse-shosts
1451 This function returns the host nicknames defined by @code{Host} entries
1452 in @file{~/.ssh/config} style files.
1454 @item @code{tramp-parse-shostkeys}
1455 @findex tramp-parse-shostkeys
1457 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1458 @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1459 @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1460 are always @code{nil}.
1462 @item @code{tramp-parse-sknownhosts}
1463 @findex tramp-parse-shostkeys
1465 Another SSH2 style parsing of directories like
1466 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1467 case, hosts names are coded in file names
1468 @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1470 @item @code{tramp-parse-hosts}
1471 @findex tramp-parse-hosts
1473 A function dedicated to @file{/etc/hosts} for host names.
1475 @item @code{tramp-parse-passwd}
1476 @findex tramp-parse-passwd
1478 A function which parses @file{/etc/passwd} files for user names.
1480 @item @code{tramp-parse-etc-group}
1481 @findex tramp-parse-etc-group
1483 A function which parses @file{/etc/group} files for group names.
1485 @item @code{tramp-parse-netrc}
1486 @findex tramp-parse-netrc
1488 A function which parses @file{~/.netrc} and @file{~/.authinfo}-style files.
1492 To keep a custom file with custom data in a custom structure, a custom
1493 function has to be provided. This function must meet the following
1496 @defun my-tramp-parse file
1497 @var{file} must be either a file on the host, or @code{nil}. The
1498 function must return a list of (@var{user} @var{host}), which are
1499 taken as candidates for completion for user and host names.
1503 (my-tramp-parse "~/.my-tramp-hosts")
1505 @result{} ((nil "toto") ("daniel" "melancholia"))
1510 @node Password handling
1511 @section Reusing passwords for several connections
1514 To avoid repeated prompts for passwords, consider native caching
1515 mechanisms, such as @command{ssh-agent} for @option{ssh}-like
1516 methods, or @command{pageant} for @option{plink}-like methods.
1518 @value{tramp} offers alternatives when native solutions cannot meet
1522 @anchor{Using an authentication file}
1523 @subsection Using an authentication file
1524 @vindex auth-sources
1526 The package @file{auth-source.el}, originally developed for No Gnus,
1527 reads passwords from different sources, @xref{Help for users, ,
1528 auth-source, auth}. The default authentication file is
1529 @file{~/.authinfo.gpg}, but this can be changed via the variable
1530 @code{auth-sources}.
1533 A typical entry in the authentication file:
1536 machine melancholia port scp login daniel password geheim
1539 The port can take any @value{tramp} method (@pxref{Inline methods},
1540 @pxref{External methods}). Omitting port values matches all
1541 @value{tramp} methods.
1543 Setting @code{auth-source-debug} to @code{t} to debug messages.
1546 @anchor{Caching passwords}
1547 @subsection Caching passwords
1549 @value{tramp} can cache passwords as entered and reuse when needed for
1550 the same user or host name independent of the access method.
1552 @vindex password-cache-expiry
1554 @code{password-cache-expiry} sets the duration (in seconds) the
1555 passwords are remembered. Passwords are never saved permanently nor
1556 can they extend beyond the lifetime of the current Emacs session. Set
1557 @code{password-cache-expiry} to @code{nil} to disable expiration.
1559 @vindex password-cache
1561 Set @code{password-cache} to @code{nil} to disable password caching.
1563 @strong{Implementation Note}: password caching depends on
1564 @file{password-cache.el} package. @value{tramp} activates password
1565 caching only if @value{tramp} can discover, while Emacs is loading,
1566 the package through @code{load-path}.
1568 @ifset installchapter
1569 @file{password.el} is available from No Gnus or from the @value{tramp}
1570 @file{contrib} directory, see @ref{Installation parameters}.
1574 @node Connection caching
1575 @section Reusing connection related information
1577 @vindex tramp-persistency-file-name
1579 For faster initial connection times, @value{tramp} stores previous
1580 connection properties in a file specified by the variable
1581 @code{tramp-persistency-file-name}.
1583 The default file name for @code{tramp-persistency-file-name} is
1584 @file{~/.emacs.d/tramp}.
1586 @value{tramp} reads this file during Emacs startup, and writes to it
1587 when exiting Emacs. Delete this file for @value{tramp} to recreate a
1588 new one on next Emacs startup.
1590 Set @code{tramp-persistency-file-name} to @code{nil} to disable
1591 storing connections persistently.
1593 To reuse connection information from the persistent list,
1594 @value{tramp} needs to uniquely identify every host. However in some
1595 cases, two different connections may result in the same persistent
1596 information. For example, connecting to a host using @command{ssh} and
1597 connecting to the same host through @code{sshd} on port 3001. Both
1598 access methods result in nearly identical persistent specifications
1599 @file{@trampfn{ssh, , localhost,}} and @file{@trampfn{ssh, ,
1602 Changing host names could avoid duplicates. One way is to add a
1603 @option{Host} section in @file{~/.ssh/config} (@pxref{Frequently Asked
1604 Questions}). Another way is to apply multiple hops (@pxref{Multi-hops}).
1606 When @value{tramp} detects a change in the operating system version in
1607 a remote host (via the command @command{uname -sr}), it flushes all
1608 connection related information for that host and creates a new entry.
1611 @node Predefined connection information
1612 @section Setting own connection related information
1613 @vindex tramp-connection-properties
1615 For more precise customization, parameters specified by
1616 @code{tramp-methods} can be overwritten manually.
1618 Set @code{tramp-connection-properties} to manually override
1619 @code{tramp-methods}. Properties in this list are in the form
1620 @code{(@var{regexp} @var{property} @var{value})}. @var{regexp} matches
1621 remote file names. Use @code{nil} to match all. @var{property} is the
1622 property's name, and @var{value} is the property's value.
1624 @var{property} is any method specific parameter contained in
1625 @code{tramp-methods}. The parameter key in @code{tramp-methods} is a
1626 symbol name @code{tramp-<foo>}. To overwrite that property, use the
1627 string @samp{<foo>} for @var{property}. For example, this changes the
1631 (add-to-list 'tramp-connection-properties
1632 (list (regexp-quote "@trampfn{ssh, user, randomhost.your.domain,}")
1633 "remote-shell" "/bin/ksh"))
1634 (add-to-list 'tramp-connection-properties
1635 (list (regexp-quote "@trampfn{ssh, user, randomhost.your.domain,}")
1636 "remote-shell-login" '("-")))
1639 The parameters @code{tramp-remote-shell} and
1640 @code{tramp-remote-shell-login} in @code{tramp-methods} now have new
1641 values for the remote host.
1643 @var{property} could also be any property found in
1644 @code{tramp-persistency-file-name}.
1646 To get around how restricted shells randomly drop connections, set the
1647 special property @samp{busybox}. For example:
1650 (add-to-list 'tramp-connection-properties
1651 (list (regexp-quote "@trampfn{ssh, user, randomhost.your.domain,}")
1656 @node Remote programs
1657 @section How @value{tramp} finds and uses programs on the remote host
1659 @value{tramp} requires access to and rights to several commands on
1660 remote hosts: @command{ls}, @command{test}, @command{find} and
1663 Besides there are other required programs for @ref{Inline methods} and
1664 @ref{External methods} of connection.
1666 To improve performance and accuracy of remote file access,
1667 @value{tramp} uses @command{perl} (or @command{perl5}) and
1668 @command{grep} when available.
1670 @defopt tramp-remote-path
1671 @vindex tramp-remote-path
1672 @vindex tramp-default-remote-path
1673 @vindex tramp-own-remote-path
1674 @option{tramp-remote-path} specifies which remote directory paths
1675 @value{tramp} can search for @ref{Remote programs}.
1677 @value{tramp} uses standard defaults, such as @file{/bin} and
1678 @file{/usr/bin}, which are reasonable for most hosts. To accommodate
1679 differences in hosts and paths, for example, @file{/bin:/usr/bin} on
1681 @file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin} on
1682 Solaris, @value{tramp} queries the remote host with @command{getconf
1683 PATH} and updates the symbol @code{tramp-default-remote-path}.
1685 For instances where hosts keep obscure locations for paths for
1686 security reasons, manually add such paths to local @file{.emacs} as
1687 shown below for @value{tramp} to use when connecting.
1690 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1693 Another way to find the remote path is to use the path assigned to the
1694 remote user by the remote host. @value{tramp} does not normally retain
1695 this remote path after logging. However, @code{tramp-own-remote-path}
1696 preserves the path value, which can be used to update
1697 @code{tramp-remote-path}.
1700 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1704 When remote search paths are changed, local @value{tramp} caches must
1705 be recomputed. To force @value{tramp} to recompute afresh, exit
1706 Emacs, remove the persistent file (@pxref{Connection caching}), and
1710 @node Remote shell setup
1711 @section Remote shell setup hints
1712 @cindex remote shell setup
1713 @cindex @file{.profile} file
1714 @cindex @file{.login} file
1715 @cindex shell init files
1717 @value{tramp} checks for the availability of standard programs in the
1718 usual locations. Common tactics include successively trying
1719 @command{test -e}, @command{/usr/bin/test -e}, and @command{/bin/test
1720 -e}. @command{ls -d} is another approach. But these approaches do not
1721 help with these new login patterns.
1723 When @value{tramp} encounters two-factor logins or additional challenge
1724 questions, such as entering birth date or security code or passphrase,
1725 @value{tramp} needs a few more configuration steps to accommodate
1728 The difference between a password prompt and a passphrase prompt is
1729 that the password for completing the login while the passphrase is
1730 for authorizing access to local authentication information, such as
1733 There is no one configuration to accommodate all the variations in
1734 login security, especially not the exotic ones. However, @value{tramp}
1735 provides a few tweaks to address the most common ones.
1738 @item @var{tramp-shell-prompt-pattern}
1739 @vindex tramp-shell-prompt-pattern
1741 @code{tramp-shell-prompt-pattern} is for remote login shell prompt,
1742 which may not be the same as the local login shell prompt,
1743 @code{shell-prompt-pattern}. Since most hosts use identical prompts,
1744 @value{tramp} sets a similar default value for both prompts.
1746 @item @var{tramp-password-prompt-regexp}
1747 @item @var{tramp-wrong-passwd-regexp}
1748 @vindex tramp-password-prompt-regexp
1749 @vindex tramp-wrong-passwd-regexp
1751 @value{tramp} uses @var{tramp-password-prompt-regexp} to distinguish
1752 between prompts for passwords and prompts for passphrases. By default,
1753 @var{tramp-password-prompt-regexp} handles the detection in English
1754 language environments. See a localization example below:
1758 tramp-password-prompt-regexp
1762 '("passphrase" "Passphrase"
1764 "password" "Password"
1766 "passwort" "Passwort"
1768 "mot de passe" "Mot de passe") t)
1772 Similar localization may be necessary for handling wrong password
1773 prompts, for which @value{tramp} uses @var{tramp-wrong-passwd-regexp}.
1775 @item @command{tset} and other questions
1776 @cindex Unix command tset
1777 @cindex tset Unix command
1778 @vindex tramp-terminal-type
1780 To suppress inappropriate prompts for terminal type, @value{tramp}
1781 sets the @env{TERM} to @code{dumb} before the remote login process
1782 begins via the variable @code{tramp-terminal-type}. This will silence
1783 common @command{tset} related prompts.
1785 @value{tramp}'s strategy for handling such prompts (commonly triggered
1786 from login scripts on remote hosts) is to set the environment
1787 variables so that no prompts interrupt the shell initialization
1790 @vindex tramp-actions-before-shell
1792 An alternative approach is to configure @value{tramp} with strings
1793 that can identify such questions using
1794 @code{tramp-actions-before-shell}. Example:
1797 (defconst my-tramp-prompt-regexp
1798 (concat (regexp-opt '("Enter the birth date of your mother:") t)
1800 "Regular expression matching my login prompt question.")
1802 (defun my-tramp-action (proc vec)
1803 "Enter \"19000101\" in order to give a correct answer."
1804 (save-window-excursion
1805 (with-current-buffer (tramp-get-connection-buffer vec)
1806 (tramp-message vec 6 "\n%s" (buffer-string))
1807 (tramp-send-string vec "19000101"))))
1809 (add-to-list 'tramp-actions-before-shell
1810 '(my-tramp-prompt-regexp my-tramp-action))
1814 @item Conflicting names for users and variables in @file{.profile}
1816 When a user name is the same as a variable name in a local file, such
1817 as @file{.profile}, then @value{tramp} may send incorrect values for
1818 environment variables. To avoid incorrect values, change the local
1819 variable name to something different from the user name. For example,
1820 if the user name is @env{FRUMPLE}, then change the variable name to
1824 @item Non-Bourne commands in @file{.profile}
1826 When the remote host's @file{.profile} is also used for shells other
1827 than Bourne shell, then some incompatible syntaxes for commands in
1828 @file{.profile} may trigger errors in Bourne shell on the host and may
1829 not complete client's @value{tramp} connections.
1831 One example of a Bourne shell incompatible syntax in @file{.profile}:
1832 using @command{export FOO=bar} instead of @command{FOO=bar; export
1833 FOO}. After remote login, @value{tramp} will trigger an error during
1834 its execution of @command{/bin/sh} on the remote host because Bourne
1835 shell does not recognize the export command as entered in
1838 Likewise, (@code{~}) character in paths will cause errors because
1839 Bourne shell does not do (@code{~}) character expansions.
1841 One approach to avoiding these incompatibilities is to make all
1842 commands in @file{~/.shrc} and @file{~/.profile} Bourne shell
1843 compatible so @value{tramp} can complete connections to that remote.
1844 To accommodate using non-Bourne shells on that remote, use other
1845 shell-specific config files. For example, bash can use
1846 @file{~/.bash_profile} and ignore @file{.profile}.
1849 @item Interactive shell prompt
1851 @value{tramp} redefines the remote shell prompt internally for robust
1852 parsing. This redefinition affects the looks of a prompt in an
1853 interactive remote shell through commands, such as @kbd{M-x
1854 shell}. Such prompts, however, can be reset to something more readable
1855 and recognizable using these @value{tramp} variables.
1857 @value{tramp} sets the @env{INSIDE_EMACS} variable in the startup
1858 script file @file{~/.emacs_SHELLNAME}.
1860 @env{SHELLNAME} is @code{bash} or equivalent shell names. Change it by
1861 setting the environment variable @env{ESHELL} in the @file{.emacs} as
1865 (setenv "ESHELL" "bash")
1868 Then re-set the prompt string in @file{~/.emacs_SHELLNAME} as follows:
1871 # Reset the prompt for remote Tramp shells.
1872 if [ "$@{INSIDE_EMACS/*tramp*/tramp@}" == "tramp" ] ; then
1878 @xref{Interactive Shell, , , emacs}.
1881 @item @command{busybox} / @command{nc}
1882 @cindex Unix command nc
1883 @cindex nc Unix command
1885 @value{tramp}'s @option{nc} method uses the @command{nc} command to
1886 install and execute a listener as follows (see @code{tramp-methods}):
1892 The above command-line syntax has changed with @command{busybox}
1893 versions. If @command{nc} refuses the @command{-p} parameter, then
1894 overwrite as follows:
1898 'tramp-connection-properties
1899 `(,(regexp-quote "192.168.0.1") "remote-copy-args" (("-l") ("%r"))))
1903 where @samp{192.168.0.1} is the remote host IP address
1904 (@pxref{Predefined connection information}).
1909 @node Android shell setup
1910 @section Android shell setup hints
1911 @cindex android shell setup
1913 @value{tramp} uses the @option{adb} method to access Android
1914 devices. Android devices provide a restricted shell access through an
1915 USB connection. The local host must have Andriod SDK installed.
1917 Applications such as @code{SSHDroid} that run @command{sshd} process
1918 on the Android device can accept any @option{ssh}-based methods
1919 provided these settings are adjusted:
1921 @code{sh} must be specified for remote shell since Android devices do
1922 not provide @code{/bin/sh}. @code{sh} will then invoke whatever shell is
1923 installed on the device with this setting:
1926 (add-to-list 'tramp-connection-properties
1927 (list (regexp-quote "192.168.0.26") "remote-shell" "sh"))
1931 where @samp{192.168.0.26} is the Android device's IP address.
1932 (@pxref{Predefined connection information}).
1934 @value{tramp} requires preserving @env{PATH} environment variable from
1935 user settings. Android devices prefer @file{/system/xbin} path over
1936 @file{/system/bin}. Both of these are set as follows:
1939 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1940 (add-to-list 'tramp-remote-path "/system/xbin")
1944 When the Android device is not @samp{rooted}, specify a writable
1945 directory for temporary files:
1948 (add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")
1952 Open a remote connection with the command @kbd{C-x C-f @trampfn{ssh, ,
1953 192.168.0.26#2222, }}, where @command{sshd} is listening on port
1956 To add a corresponding entry to the @file{~/.ssh/config} file
1957 (recommended), use this:
1961 HostName 192.168.0.26
1967 To use the host name @samp{android} instead of the IP address shown in
1968 the previous example, fix the connection properties as follows:
1971 (add-to-list 'tramp-connection-properties
1972 (list (regexp-quote "android") "remote-shell" "sh"))
1976 Open a remote connection with a more concise command @kbd{C-x C-f
1977 @trampfn{ssh, , android, }}.
1980 @node Auto-save and Backup
1981 @section Auto-save and Backup configuration
1984 @vindex backup-directory-alist
1986 To avoid @value{tramp} from saving backup files owned by root to
1987 locations accessible to others, default backup settings in
1988 @code{backup-directory-alist} have to be altered.
1990 Here's a scenario where files could be inadvertently exposed. Emacs
1991 by default writes backup files to the same directory as the original
1992 files unless changed to another location, such as
1993 @file{~/.emacs.d/backups/}. Such a directory will also be used by
1994 default by @value{tramp} when using, say, a restricted file
1995 @file{@trampfn{su, root, localhost, /etc/secretfile}}. The backup
1996 file of the secretfile is now owned by the user logged in from tramp
1999 When @code{backup-directory-alist} is @code{nil} (the default), such
2000 problems do not occur.
2002 To ``turns off'' the backup feature for @value{tramp} files and stop
2003 @value{tramp} from saving to the backup directory, use this:
2006 (add-to-list 'backup-directory-alist
2007 (cons tramp-file-name-regexp nil))
2011 Disabling backups can be targetted to just @option{su} and
2012 @option{sudo} methods:
2015 (setq backup-enable-predicate
2017 (and (normal-backup-enable-predicate name)
2019 (let ((method (file-remote-p name 'method)))
2020 (when (stringp method)
2021 (member method '("su" "sudo"))))))))
2024 Another option is to create better backup file naming with user and
2025 host names prefixed to the file name. For example, transforming
2026 @file{/etc/secretfile} to
2027 @file{~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile}, set the
2028 @value{tramp} variable @code{tramp-backup-directory-alist} from the
2029 existing variable @code{backup-directory-alist}.
2031 Then @value{tramp} backs up to a file name that is transformed with a
2032 prefix consisting of the DIRECTORY name. This file name prefixing
2033 happens only when the DIRECTORY is an absolute local file name.
2039 (add-to-list 'backup-directory-alist
2040 (cons "." "~/.emacs.d/backups/"))
2041 (setq tramp-backup-directory-alist backup-directory-alist)
2045 The backup file name of @file{@trampfn{su, root, localhost,
2046 /etc/secretfile}} would be @file{@trampfn{su, root, localhost,
2047 ~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}}
2049 Just as for backup files, similar issues of file naming affect
2050 auto-saving @value{tramp} files. Auto-saved files are saved in the
2051 directory specified by the variable
2052 @code{auto-save-file-name-transforms}. By default this is set to the
2053 local temporary directory. But in some versions of Debian GNU/Linux,
2054 this points to the source directory where the Emacs was compiled.
2055 Reset such values to a valid directory.
2057 Set @code{auto-save-file-name-transforms} to @code{nil} to save
2058 auto-saved files to the same directory as the original file.
2060 Alternatively, set the variable @code{tramp-auto-save-directory} to
2061 direct all auto saves to that location.
2063 @node Windows setup hints
2064 @section Issues with Cygwin ssh
2065 @cindex Cygwin, issues
2067 This section is incomplete. Please share your solutions.
2069 @cindex method sshx with Cygwin
2070 @cindex sshx method with Cygwin
2072 Cygwin's @command{ssh} works only with a Cygwin version of Emacs. To
2073 check for compatibility: type @kbd{M-x eshell}, and start @kbd{ssh
2074 test.host}. Incompatbilities trigger this message:
2077 Pseudo-terminal will not be allocated because stdin is not a terminal.
2080 Some older versions of Cygwin's @command{ssh} work with the
2081 @option{sshx} access method. Consult Cygwin's FAQ at
2082 @uref{http://cygwin.com/faq/} for details.
2085 @cindex method scpx with Cygwin
2086 @cindex scpx method with Cygwin
2088 When using the @option{scpx} access method, Emacs may call
2089 @command{scp} with Windows file naming, such as @code{c:/foo}. But
2090 the version of @command{scp} that is installed with Cygwin does not
2091 know about Windows file naming, which causes it to incorrectly look
2092 for a host named @code{c}.
2094 A workaround: write a wrapper script for @option{scp} to convert
2095 Windows file names to Cygwin file names.
2097 @cindex Cygwin and ssh-agent
2098 @cindex SSH_AUTH_SOCK and Emacs on Windows
2100 When using the @command{ssh-agent} on Windows for password-less
2101 interaction, @option{ssh} methods depend on the environment variable
2102 @env{SSH_AUTH_SOCK}. But this variable is not set when Emacs is
2103 started from a Desktop shortcut and authentication fails.
2105 One workaround is to use a Windows based SSH Agent, such as
2106 Pageant. It is part of the Putty Suite of tools.
2108 The fallback is to start Emacs from a shell.
2112 @chapter Using @value{tramp}
2113 @cindex using @value{tramp}
2115 @value{tramp} operates transparently, accessing remote files as if
2116 they are local. However, @value{tramp} employs a formalized remote
2117 file naming syntax to perform its functions transparently. This
2118 syntax consists of many parts specifying access methods,
2119 authentication, host names, and file names. Ange FTP uses a similar
2124 Unlike opening local files in Emacs, which are instantaneous, opening
2125 remote files in @value{tramp} is slower at first. Sometimes there is
2126 a noticable delay before the prompts for passwords or authentication
2127 appear in the minibuffer. Hitting @kbd{@key{RET}} or other keys
2128 during this gap will be processed by Emacs. This type-ahead facility
2129 is a feature of Emacs that may cause missed prompts when using
2133 * File name Syntax:: @value{tramp} file name conventions.
2134 * File name completion:: File name completion.
2135 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
2136 * Remote processes:: Integration with other Emacs packages.
2137 * Cleanup remote connections:: Cleanup remote connections.
2141 @node File name Syntax
2142 @section @value{tramp} file name conventions
2143 @cindex file name syntax
2144 @cindex file name examples
2146 @file{@trampfn{, , host, localfilename}}
2147 opens file @var{localfilename} on the remote host @var{host}, using
2148 the default method. @xref{Default Method}.
2151 @item @value{prefix}melancholia@value{postfix}.emacs
2152 For the file @file{.emacs} located in the home directory, on the host
2155 @item @value{prefix}melancholia.danann.net@value{postfix}.emacs
2156 For the file @file{.emacs} specified using the fully qualified domain name of
2159 @item @value{prefix}melancholia@value{postfix}~/.emacs
2160 For the file @file{.emacs} specified using the @file{~}, which is expanded.
2162 @item @value{prefix}melancholia@value{postfix}~daniel/.emacs
2163 For the file @file{.emacs} located in @code{daniel}'s home directory
2164 on the host, @code{melancholia}. The @file{~<user>} construct is
2165 expanded to the home directory of that user on the remote host.
2167 @item @value{prefix}melancholia@value{postfix}/etc/squid.conf
2168 For the file @file{/etc/squid.conf} on the host @code{melancholia}.
2172 @var{host} can take IPv4 or IPv6 address, as in @file{@trampfn{, ,
2173 127.0.0.1, .emacs}} or @file{@trampfn{, ,
2174 @value{ipv6prefix}::1@value{ipv6postfix}, .emacs}}. For syntactical
2175 reasons, IPv6 addresses must be embedded in square brackets
2176 @file{@value{ipv6prefix}} and @file{@value{ipv6postfix}}.
2178 By default, @value{tramp} will use the current local user name as the
2179 remote user name for log in to the remote host. Specifying a different
2180 name using the proper syntax will override this default behavior:
2183 @trampfn{, user, host, path/to.file}
2186 @file{@trampfn{, daniel, melancholia, .emacs}} is for file
2187 @file{.emacs} in @code{daniel}'s home directory on the host,
2190 Specify other file access methods (@pxref{Inline methods},
2191 @pxref{External methods}) as part of the file name.
2193 Method name comes before user name, as in
2194 @file{@value{prefix}@var{method}@value{postfixhop}} (Note the trailing
2195 colon). The syntax specificaton for user, host, and file do not
2198 To connect to the host @code{melancholia} as @code{daniel}, using
2199 @option{ssh} method for @file{.emacs} in @code{daniel}'s home
2200 directory, the full specification is: @file{@trampfn{ssh, daniel,
2201 melancholia, .emacs}}.
2203 A remote file name containing a host name, which is the same string as
2204 a method name, is not allowed.
2206 For specifying port numbers, affix @file{#<port>} to the host
2207 name. For example: @file{@trampfn{ssh, daniel, melancholia#42,
2211 @node File name completion
2212 @section File name completion
2213 @cindex file name completion
2215 @value{tramp} can complete the following @value{tramp} file name
2216 components: method names, user names, host names, and file names
2217 located on remote hosts. Enable this by activating partial completion
2220 @xref{Completion Options, , , emacs}.
2223 For example, type @kbd{C-x C-f @value{prefix}t @key{TAB}},
2224 @value{tramp} completion choices show up as
2227 @c @multitable {@trampfn{telnet, , melancholia.danann.net,}} {@trampfn{telnet, , 192.168.0.1,}}
2228 @multitable @columnfractions .5 .5
2229 @item @value{prefixhop}telnet@value{postfixhop} @tab tmp/
2230 @item @value{prefixhop}toto@value{postfix} @tab
2234 @samp{@value{prefixhop}telnet@value{postfixhop}} is a possible
2235 completion for the respective method, @samp{tmp/} stands for the
2236 directory @file{/tmp} on your local host, and
2237 @samp{@value{prefixhop}toto@value{postfix}} might be a host
2238 @value{tramp} has detected in your @file{~/.ssh/known_hosts} file
2239 (when using @option{ssh} as default method).
2241 Type @kbd{e @key{TAB}} for the minibuffer completion to
2242 @samp{@value{prefix}telnet@value{postfixhop}}. Typing @kbd{@key{TAB}}
2243 shows host names @value{tramp} from @file{/etc/hosts} file, for example.
2246 @multitable @columnfractions .5 .5
2247 @c @multitable {@trampfn{telnet, , melancholia.danann.net,}} {@trampfn{telnet, , 192.168.0.1,}}
2248 @item @trampfn{telnet, , 127.0.0.1,} @tab @trampfn{telnet, , 192.168.0.1,}
2249 @item @trampfn{telnet, , @value{ipv6prefix}::1@value{ipv6postfix},} @tab @trampfn{telnet, , localhost,}
2250 @item @trampfn{telnet, , melancholia.danann.net,} @tab @trampfn{telnet, , melancholia,}
2254 Choose a host from the above list and then continue to complete file
2257 When the configuration (@pxref{Customizing Completion}) includes user
2258 names, then the completion lists will account for the user names as well.
2260 Remote hosts previously visited or hosts whose connections are kept
2261 persistently (@pxref{Connection caching}) will be included in the
2264 After remote host name completion comes completion of file names on
2265 the remote host. It works the same as on loal host file completion
2266 except when killing with double-slash @file{//} kills only the file
2267 name part of the @value{tramp} file name syntax. A triple-slash
2268 stands for the default behavior.
2270 @xref{Minibuffer File, , , emacs}.
2277 @kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin//etc} @key{TAB}}
2278 @print{} @trampfn{telnet, , melancholia, /etc}
2280 @kbd{C-x C-f @trampfn{telnet, , melancholia, //etc} @key{TAB}}
2283 @kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin///etc} @key{TAB}}
2287 During file name completion, remote directory contents are re-read
2288 regularly to account for any changes in the filesystem that may affect
2289 the completion candidates. Such re-reads can account for changes to
2290 the file system by applications outside Emacs (@pxref{Connection
2293 @defopt tramp-completion-reread-directory-timeout
2294 @vindex tramp-completion-reread-directory-timeout
2295 The timeout is number of seconds since last remote command for
2296 rereading remote directory contents. 0 re-reads immediately during
2297 file name completion, @code{nil} uses cached directory contents.
2301 @node Ad-hoc multi-hops
2302 @section Declaring multiple hops in the file name
2303 @cindex multi-hop, ad-hoc
2304 @cindex proxy hosts, ad-hoc
2306 @value{tramp} file name syntax can accommodate ad hoc specification of
2307 multiple proxies without using @code{tramp-default-proxies-alist}
2308 configuration setup(@pxref{Multi-hops}).
2310 Each proxy is specified using the same syntax as the remote host
2311 specification minus the file name part. Each hop is separated by a
2312 @samp{|}. Chain the proxies from the starting host to the destination
2313 remote host name and file name. For example, hopping over a single
2314 proxy @samp{bird@@bastion} to a remote file on @samp{you@@remotehost}:
2317 @c @kbd{C-x C-f @trampfn{ssh@value{postfixhop}bird@@bastion|ssh, you,
2318 @c remotehost, /path}}
2319 @kbd{C-x C-f @value{prefix}ssh@value{postfixhop}bird@@bastion|ssh@value{postfixhop}you@@remotehost@value{postfix}/path}
2322 Proxies can take patterns @code{%h} or @code{%u}.
2324 @value{tramp} adds the ad-hoc definitions on the fly to
2325 @code{tramp-default-proxies-alist} and is available for re-use during
2326 that Emacs session. Subsequent @value{tramp} connections to the same
2327 remote host can then use the shortcut form: @samp{@trampfn{ssh, you,
2328 remotehost, /path}}.
2330 @defopt tramp-save-ad-hoc-proxies
2331 @vindex tramp-save-ad-hoc-proxies
2332 For ad-hoc definitions to be saved automatically in
2333 @option{tramp-default-proxies-alist} for future Emacs sessions, set
2334 @option{tramp-save-ad-hoc-proxies}.
2337 (setq tramp-save-ad-hoc-proxies t)
2342 @node Remote processes
2343 @section Integration with other Emacs packages
2347 @value{tramp} supports starting new running processes on the remote
2348 host for discovering remote file names. Emacs packages on the remote
2349 host need no specific modifications for @value{tramp}'s use.
2351 This type of integration does not work with the @option{ftp} method,
2352 and does not support the pty association as specified in
2353 @code{start-file-process}.
2355 @code{process-file} and @code{start-file-process} work on the remote
2356 host when the variable @code{default-directory} is remote:
2359 (let ((default-directory "/ssh:remote.host:"))
2360 (start-file-process "grep" (get-buffer-create "*grep*")
2361 "/bin/sh" "-c" "grep -e tramp *"))
2366 Remote processes do not apply to GVFS (see @ref{GVFS based methods})
2367 because the remote file system is mounted on the local host and
2368 @value{tramp} just accesses by changing the @code{default-directory}.
2371 @value{tramp} starts a remote process when a command is executed in a
2372 remote file or directory buffer. As of now, these packages have been
2373 integrated to work with @value{tramp}: @file{compile.el} (commands
2374 like @code{compile} and @code{grep}) and @file{gud.el} (@code{gdb} or
2377 For @value{tramp} to find the command on the remote, it must be
2378 accessible through the default search path as setup by @value{tramp}
2379 upon first connection. Alternatively, use an absolute path or extend
2380 @code{tramp-remote-path} (see @ref{Remote programs}):
2383 (add-to-list 'tramp-remote-path "~/bin")
2384 (add-to-list 'tramp-remote-path "/appli/pub/bin")
2387 Customize @code{tramp-remote-process-environment} to suit the remote
2388 program's environment for the remote host.
2389 @code{tramp-remote-process-environment} is a list of strings
2390 structured similar to @code{process-environment}, where each element
2391 is a string of the form @samp{ENVVARNAME=VALUE}.
2393 To avoid any conflicts with local host variables set through local
2394 configuration files, such as @file{~/.profile}, use @samp{ENVVARNAME=}
2395 to unset them for the remote environment.
2398 Use @code{add-to-list} to add entries:
2401 (add-to-list 'tramp-remote-process-environment "JAVA_HOME=/opt/java")
2404 Modifying or deleting already existing values in the
2405 @code{tramp-remote-process-environment} list may not be feasible on
2406 restricted remote hosts. For example, some system administrators
2407 disallow changing @env{HISTORY} variable. To accommodate such
2408 restrictions when using @value{tramp}, fix the
2409 @code{tramp-remote-process-environment} by the following code in the
2410 local @file{.emacs} file:
2413 (let ((process-environment tramp-remote-process-environment))
2414 (setenv "HISTORY" nil)
2415 (setq tramp-remote-process-environment process-environment))
2418 @value{tramp} does not use the defaults specified in
2419 @code{process-environment} for running @code{process-file} or
2420 @code{start-file-process} on remote hosts. When values from
2421 @code{process-environment} are needed for remote processes, then set
2425 (let ((process-environment (cons "HGPLAIN=1" process-environment)))
2426 (process-file @dots{}))
2429 This works only for environment variables not already set in the
2430 @code{process-environment}.
2432 For integrating other Emacs packages so @value{tramp} can execute
2433 remotely, please file a bug report. @xref{Bug Reports}.
2436 @subsection Running remote programs that create local X11 windows
2438 To allow a remote program to create an X11 window on the local host,
2439 set the @env{DISPLAY} environment variable for the remote host as
2440 follows in the local @file{.emacs} file:
2443 (add-to-list 'tramp-remote-process-environment
2444 (format "DISPLAY=%s" (getenv "DISPLAY")))
2448 @code{(getenv "DISPLAY")} should return a recognizable name for the
2449 local host that the remote host can redirect X11 window
2450 interactions. If querying for a recognizable name is not possible for
2451 whatever reason, then replace @code{(getenv "DISPLAY")} with a
2452 hard-coded, fixed name. Note that using @code{:0} for X11 display name
2453 here will not work as expected.
2455 An alternate approach is specify @code{ForwardX11 yes} or
2456 @code{ForwardX11Trusted yes} in the file @file{~/.ssh/config} on the
2460 @subsection Running @code{shell} on a remote host
2463 Set @option{explicit-shell-file-name} to the appropriate shell name
2464 when using @value{tramp} between two hosts with different operating
2465 systems, such as @samp{windows-nt} and @samp{gnu/linux}. This option
2466 ensures the correct name of the remote shell program.
2468 Starting with Emacs 24, when @option{explicit-shell-file-name} is
2469 equal to @code{nil}, calling @code{shell} interactively will prompt
2473 @subsection Running @code{shell-command} on a remote host
2474 @cindex shell-command
2476 @code{shell-command} executes commands synchronously or asynchronously
2477 on remote hosts and displays output in buffers on the local
2481 @kbd{C-x C-f @trampfn{sudo, , , } @key{RET}}
2482 @kbd{M-! tail -f /var/log/syslog.log & @key{RET}}
2485 @command{tail} command outputs continuously to the local buffer,
2486 @file{*Async Shell Command*}
2488 @kbd{M-x auto-revert-tail-mode} runs similarly showing continuous output.
2491 @subsection Running @code{eshell} on a remote host
2494 @value{tramp} is integrated into @file{eshell.el}, which enables
2495 interactive eshell sessions on remote hosts at the command prompt.
2496 You must add the module @code{eshell-tramp} to
2497 @code{eshell-modules-list}. Here's a sample interaction after opening
2498 @kbd{M-x eshell} on a remote host:
2501 @b{~ $} cd @trampfn{sudo, , , /etc} @key{RET}
2502 @b{@trampfn{sudo, root, host, /etc} $} hostname @key{RET}
2504 @b{@trampfn{sudo, root, host, /etc} $} id @key{RET}
2505 uid=0(root) gid=0(root) groups=0(root)
2506 @b{@trampfn{sudo, root, host, /etc} $} find-file shadow @key{RET}
2508 @b{@trampfn{sudo, root, host, /etc} $}
2511 @code{eshell} in Emacs 23.2 added custom @code{su} and @code{sudo}
2512 commands that set the default directory correctly for the
2513 @file{*eshell*} buffer. @value{tramp} silently updates
2514 @code{tramp-default-proxies-alist} with an entry for this directory
2515 (@pxref{Multi-hops}):
2518 @b{~ $} cd @trampfn{ssh, user, remotehost, /etc} @key{RET}
2519 @b{@trampfn{ssh, user, remotehost, /etc} $} find-file shadow @key{RET}
2520 File is not readable: @trampfn{ssh, user, remotehost, /etc/shadow}
2521 @b{@trampfn{ssh, user, remotehost, /etc} $} sudo find-file shadow @key{RET}
2524 @b{@trampfn{ssh, user, remotehost, /etc} $} su - @key{RET}
2525 @b{@trampfn{su, root, remotehost, /root} $} id @key{RET}
2526 uid=0(root) gid=0(root) groups=0(root)
2527 @b{@trampfn{su, root, remotehost, /root} $}
2531 @anchor{Running a debugger on a remote host}
2532 @subsection Running a debugger on a remote host
2537 @file{gud.el} provides a unified interface to symbolic debuggers
2539 (@ref{Debuggers, , , emacs}).
2541 @value{tramp} can run debug on remote hosts by calling @code{gdb}
2542 with a remote file name:
2545 @kbd{M-x gdb @key{RET}}
2546 @b{Run gdb (like this):} gdb --annotate=3 @trampfn{ssh, , host, ~/myprog} @key{RET}
2549 Relative file names are based on the remote default directory. When
2550 @file{myprog.pl} exists in @file{@trampfn{ssh, , host, /home/user}},
2551 valid calls include:
2554 @kbd{M-x perldb @key{RET}}
2555 @b{Run perldb (like this):} perl -d myprog.pl @key{RET}
2558 Just the local part of a remote file name, such as @kbd{perl -d
2559 /home/user/myprog.pl}, is not possible.
2561 Arguments of the program to be debugged must be literal, can take
2562 relative or absolute paths, but not remote paths.
2565 @subsection Running remote processes on Windows hosts
2569 @command{winexe} runs processes on a remote Windows host, and
2570 @value{tramp} can use it for @code{process-file} and
2571 @code{start-file-process}.
2573 @code{tramp-smb-winexe-program} specifies the local @command{winexe}
2574 command. Powershell V2.0 on the remote host is required to run
2575 processes triggered from @value{tramp}.
2577 @option{explicit-shell-file-name} and @option{explicit-*-args} have to
2578 be set properly so @kbd{M-x shell} can open a proper remote shell on a
2579 Windows host. To open @command{cmd}, set it as follows:
2582 (setq explicit-shell-file-name "cmd"
2583 explicit-cmd-args '("/q"))
2587 To open @command{powershell} as a remote shell, use this:
2590 (setq explicit-shell-file-name "powershell"
2591 explicit-powershell-args '("-file" "-"))
2595 @node Cleanup remote connections
2596 @section Cleanup remote connections
2599 @value{tramp} provides several ways to flush remote connections.
2601 @deffn Command tramp-cleanup-connection vec
2602 This command flushes all connection related objects. @option{vec} is
2603 the internal representation of a remote connection. When called
2604 interactively, this command lists active remote connections in the
2605 minibuffer. Each connection is of the format @file{@trampfn{method,
2606 user, host, }}. Flushing remote connections also cleans the password
2607 cache (@pxref{Password handling}), file cache, connection cache
2608 (@pxref{Connection caching}), and connection buffers.
2611 @deffn Command tramp-cleanup-this-connection
2612 Flushes only the current buffer's remote connection objects, the same
2613 as in @code{tramp-cleanup-connection}.
2616 @deffn Command tramp-cleanup-all-connections
2617 Flushes all active remote connection objects, the same as in
2618 @code{tramp-cleanup-connection}.
2621 @deffn Command tramp-cleanup-all-buffers
2622 Just as for @code{tramp-cleanup-all-connections}, all remote
2623 connections are cleaned up in addition to killing buffers related to
2624 that remote connection.
2629 @chapter Reporting Bugs and Problems
2632 @value{tramp}'s development team is actively engaged in solving bugs
2633 and problems and looks to feature requests and suggestions.
2635 @value{tramp}'s mailing list is the place for more advice and
2636 information on working with @value{tramp}, solving problems,
2637 discussing, and general discussions about @value{tramp}.
2639 @value{tramp}'s mailing list is moderated but even non-subscribers can
2640 post for moderator approval. Sometimes this approval step may take as
2641 long as 48 hours due to public holidays.
2643 @email{tramp-devel@@gnu.org} is the mailing list. Messages sent to
2644 this address go to all the subscribers. This is @emph{not} the
2645 address to send subscription requests to.
2647 To subscribe to the mailing list, visit:
2648 @uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/, the
2649 @value{tramp} Mail Subscription Page}.
2651 @ifset installchapter
2652 Before sending a bug report, run the test suite first @ref{Testing}.
2656 Check if the bug or problem is already addressed in @xref{Frequently
2659 Run @kbd{M-x tramp-bug} to generate a buffer with details of the
2660 system along with the details of the @value{tramp}
2661 installation. Please include these details with the bug report.
2663 The bug report must describe in as excruciating detail as possible the
2664 steps required to reproduce the problem. These details must include
2665 the setup of the remote host and any special or unique conditions that
2668 Include a minimal test case that reproduces the problem. This will
2669 help the development team find the best solution and avoid unrelated
2672 To exclude cache-related problems, flush all caches before running the
2673 test, @ref{Cleanup remote connections}.
2675 When including @value{tramp}'s messages in the bug report, increase
2676 the verbosity level to 6 (@pxref{Traces and Profiles, Traces}) in the
2677 @file{~/.emacs} file before repeating steps to the bug. Include the
2678 contents of the @file{*tramp/foo*} and @file{*debug tramp/foo*}
2679 buffers with the bug report.
2681 @strong{Note} that a verbosity level greater than 6 is not necessary
2682 at this stage. Also note that a verbosity level of 6 or greater, the
2683 contents of files and directories will be included in the debug
2684 buffer. Passwords typed in @value{tramp} will never be included
2688 @node Frequently Asked Questions
2689 @chapter Frequently Asked Questions
2690 @cindex frequently asked questions
2695 Where is the latest @value{tramp}?
2697 @value{tramp} is available at the GNU URL:
2700 @uref{ftp://ftp.gnu.org/gnu/tramp/}
2703 @value{tramp}'s GNU project page is located here:
2706 @uref{http://savannah.gnu.org/projects/tramp/}
2710 Which systems does it work on?
2712 The package works successfully on Emacs 23, Emacs 24, and Emacs 25.
2714 While Unix and Unix-like systems are the primary remote targets,
2715 @value{tramp} has equal success connecting to other platforms, such as
2716 MS Windows XP/Vista/7.
2720 How to speed up @value{tramp}?
2722 @value{tramp} does many things in the background, some of which
2723 depends on network speeds, response speeds of remote hosts, and
2724 authentication delays. During these operations, @value{tramp}'s
2725 responsiveness slows down. Some suggestions within the scope of
2726 @value{tramp}'s settings include:
2728 Use an external method, such as @option{scp}, which are faster than
2731 Keep the file @code{tramp-persistency-file-name}, which is where
2732 @value{tramp} caches remote information about hosts and files. Caching
2733 is enabled by default. Don't disable it.
2735 Set @code{remote-file-name-inhibit-cache} to @code{nil} if remote
2736 files are not independently updated outside @value{tramp}'s control.
2737 That cache cleanup will be necessary if the remote directories or
2738 files are updated independent of @value{tramp}.
2740 Set @code{tramp-completion-reread-directory-timeout} to @code{nil} to
2741 speed up completions, @ref{File name completion}.
2743 Disable version control to avoid delays:
2746 (setq vc-ignore-dir-regexp
2747 (format "\\(%s\\)\\|\\(%s\\)"
2748 vc-ignore-dir-regexp
2749 tramp-file-name-regexp))
2752 Disable excessive traces. Set @code{tramp-verbose} to 3 or lower,
2753 default being 3. Increase trace levels temporarily when hunting for
2757 @value{tramp} does not connect to the remote host
2759 Three main reasons for why @value{tramp} does not connect to the remote host:
2763 Unknown characters in the prompt
2765 @value{tramp} needs a clean recognizable prompt on the remote host for
2766 accurate parsing. Shell prompts that contain escape sequences for
2767 coloring cause parsing problems. @ref{Remote shell setup} for
2768 customizing prompt detection using regular expressions.
2770 To check if the remote host's prompt is being recognized, use this
2771 test: switch to @value{tramp} connection buffer @file{*tramp/foo*},
2772 put the cursor at the top of the buffer, and then apply the following
2776 @kbd{M-: (re-search-forward (concat tramp-shell-prompt-pattern "$"))}
2779 If the cursor has not moved to the prompt at the bottom of the buffer,
2780 then @value{tramp} has failed to recognize the prompt.
2782 When using zsh on remote hosts, disable zsh line editor because zsh
2783 uses left-hand side and right-hand side prompts in parallel. Add the
2784 following line to @file{~/.zshrc}:
2787 [ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
2790 When using fish shell on remote hosts, disable fancy formatting by
2791 adding the following to @file{~/.config/fish/config.fish}:
2794 function fish_prompt
2795 if test $TERM = "dumb"
2803 When using WinSSHD on remote hosts, @value{tramp} do not recognize the
2804 strange prompt settings.
2807 Echoed characters after login
2809 @value{tramp} suppresses echos from remote hosts with the
2810 @command{stty -echo} command. But sometimes it is too late to suppress
2811 welcome messages from the remote host containing harmful control
2812 characters. Using @option{sshx} or @option{scpx} methods can avoid
2813 this problem because they allocate a pseudo tty. @xref{Inline
2817 @value{tramp} stops transferring strings longer than 500 characters
2819 Set @code{tramp-chunksize} to 500 to get around this problem, which is
2820 related to faulty implementation of @code{process-send-string} on
2821 HP-UX, FreeBSD and Tru64 Unix systems. Consult the documentation for
2822 @code{tramp-chunksize} to see when this is necessary.
2824 Set @code{file-precious-flag} to @code{t} for files accessed by
2825 @value{tramp} so the file contents are checked using checksum by
2826 first saving to a temporary file.
2828 @pxref{Saving Buffers, , , elisp}
2835 (when (file-remote-p default-directory)
2836 (set (make-local-variable 'file-precious-flag) t))))
2842 @value{tramp} does not recognize if a @command{ssh} session hangs
2844 @command{ssh} sessions on the local host hang when the network is
2845 down. @value{tramp} cannot safely detect such hangs. The network
2846 configuration for @command{ssh} can be configured to kill such hangs
2847 with the following command in the @file{~/.ssh/config}:
2851 ServerAliveInterval 5
2856 @value{tramp} does not use default @command{ssh} @code{ControlPath}
2858 @value{tramp} overwrites @code{ControlPath} settings when initiating
2859 @command{ssh} sessions. @value{tramp} does this to fend off a stall
2860 if a master session opened outside the Emacs session is no longer
2861 open. That is why @value{tramp} prompts for the password again even
2862 if there is an @command{ssh} already open.
2864 Some @command{ssh} versions support a @code{ControlPersist} option,
2865 which allows to set the @code{ControlPath} provided the variable
2866 @code{tramp-ssh-controlmaster-options} is customized as follows:
2869 (setq tramp-ssh-controlmaster-options
2871 "-o ControlPath=/tmp/ssh-ControlPath-%%r@@%%h:%%p "
2872 "-o ControlMaster=auto -o ControlPersist=yes"))
2875 Note how "%r", "%h" and "%p" must be encoded as "%%r", "%%h" and
2878 If the @file{~/.ssh/config} is configured appropriately for the above
2879 behavior, then any changes to @command{ssh} can be suppressed with
2880 this @code{nil} setting:
2883 (setq tramp-use-ssh-controlmaster-options nil)
2888 File name completion does not work with @value{tramp}
2890 @acronym{ANSI} escape sequences from the remote shell may cause errors
2891 in @value{tramp}'s parsing of remote buffers.
2893 To test if this is the case, open a remote shell and check if the output
2894 of @command{ls} is in color.
2896 To disable @acronym{ANSI} escape sequences from the remote hosts,
2897 disable @option{--color=yes} or @option{--color=auto} in the remote
2898 host's @file{.bashrc} or @file{.profile}. Turn this alias on and off
2899 to see if file name completion works.
2902 File name completion does not work in directories with large number of
2905 This may be related to globbing, which is the use of shell's ability
2906 to expand wild card specifications, such as @samp{*.c}. For
2907 directories with large number of files, globbing might exceed the
2908 shell's limit on length of command lines and hang. @value{tramp} uses
2911 To test if globbing hangs, open a shell on the remote host and then
2912 run @samp{ls -d * ..?* > /dev/null}.
2914 When testing, ensure the remote shell is the same shell
2915 (@command{/bin/sh}, @command{ksh} or @command{bash}), that
2916 @value{tramp} uses when connecting to that host.
2920 How to get notified after @value{tramp} completes file transfers?
2922 Make Emacs beep after reading from or writing to the remote host with
2923 the following code in @file{~/.emacs} file.
2926 (defadvice tramp-handle-write-region
2927 (after tramp-write-beep-advice activate)
2928 "Make tramp beep after writing a file."
2932 (defadvice tramp-handle-do-copy-or-rename-file
2933 (after tramp-copy-beep-advice activate)
2934 "Make tramp beep after copying a file."
2938 (defadvice tramp-handle-insert-file-contents
2939 (after tramp-insert-beep-advice activate)
2940 "Make tramp beep after inserting a file."
2947 How to get a Visual Warning when working with @samp{root} privileges
2949 Get a modeline indication when working with @samp{root} privileges
2950 with the following code (tested with Emacs 22.1) in @file{~/.emacs}
2954 (defun my-mode-line-function ()
2955 (when (string-match "^/su\\(do\\)?:" default-directory)
2956 (setq mode-line-format
2957 (format-mode-line mode-line-format 'font-lock-warning-face))))
2959 (add-hook 'find-file-hook 'my-mode-line-function)
2960 (add-hook 'dired-mode-hook 'my-mode-line-function)
2965 How to get host indication in the mode line?
2967 The following code (tested with Emacs 22.1) in @file{~/.emacs} file
2971 (defconst my-mode-line-buffer-identification
2975 (if (file-remote-p default-directory)
2976 (tramp-file-name-host
2977 (tramp-dissect-file-name default-directory))
2979 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
2980 (substring host-name 0 (match-beginning 1))
2985 mode-line-buffer-identification
2986 my-mode-line-buffer-identification)
2992 mode-line-buffer-identification
2993 my-mode-line-buffer-identification)))
2996 The mode line in Emacs 23.1 and later versions now contains an
2997 indication if @code{default-directory} for the current buffer is on a
2998 remote host. Moreover, the corresponding tool-tip shows the remote
2999 host name. The above @code{:eval} clause can also be simplified to
3000 show the host name in the mode line:
3005 (or (file-remote-p default-directory 'host)
3007 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
3008 (substring host-name 0 (match-beginning 1))
3014 Remote host does not understand default options for directory listing
3016 Emacs computes the @command{dired} options based on the local host but
3017 if the remote host cannot understand the same @command{ls} command,
3018 then set them with a hook as follows:
3022 'dired-before-readin-hook
3024 (when (file-remote-p default-directory)
3025 (setq dired-actual-switches "-al"))))
3030 Why is @file{~/.sh_history} file on the remote host growing?
3032 Due to @command{ksh} saving tilde expansions triggered by
3033 @value{tramp}, the history file is probably growing rapidly. To fix,
3034 turn off saving history by putting this shell code in the
3038 if [ -f $HOME/.sh_history ] ; then
3039 /bin/rm $HOME/.sh_history
3041 if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
3044 if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
3049 For @option{ssh}-based method, add the following line to your
3050 @file{~/.ssh/environment} file:
3058 How to shorten long file names when typing in @value{tramp}?
3060 Adapt several of these approaches to reduce typing. If the full name
3061 is @file{@trampfn{ssh, news, news.my.domain, /opt/news/etc}}, then:
3066 Use default values for method name and user name:
3068 You can define default methods and user names for hosts,
3069 (@pxref{Default Method}, @pxref{Default User}):
3072 (setq tramp-default-method "ssh"
3073 tramp-default-user "news")
3076 The reduced typing: @kbd{C-x C-f @trampfn{, , news.my.domain, /opt/news/etc}}.
3078 @strong{Note} that there are some useful shortcuts already. Accessing
3079 your local host as @samp{root} user, is possible just by @kbd{C-x C-f
3083 Use configuration options of the access method:
3085 Programs used for access methods already offer powerful configurations
3086 (@pxref{Customizing Completion}). For @option{ssh}, configure the
3087 file @file{~/.ssh/config}:
3091 HostName news.my.domain
3095 The reduced typing: @kbd{C-x C-f @trampfn{ssh, , xy, /opt/news/etc}}.
3097 Depending on the number of files in the directories, host names
3098 completion can further reduce key strokes: @kbd{C-x C-f
3099 @value{prefix}ssh@value{postfixhop}x @key{TAB}}.
3102 Use environment variables to expand long strings
3104 For long file names, set up environment variables that are expanded in
3105 the minibuffer. Environment variables are set either outside Emacs or
3106 inside Emacs with Lisp:
3109 (setenv "xy" "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}")
3112 The reduced typing: @kbd{C-x C-f $xy @key{RET}}.
3114 @strong{Note} that file name cannot be edited here because the
3115 environment variables are not expanded during editing in the
3118 @item Define own keys:
3120 Redefine another key sequence in Emacs for @kbd{C-x C-f}:
3124 [(control x) (control y)]
3130 "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))))
3133 Simply typing @kbd{C-x C-y} would prepare minibuffer editing of file
3136 See @uref{http://www.emacswiki.org/cgi-bin/wiki/TrampMode, the Emacs
3137 Wiki} for a more comprehensive example.
3140 Define own abbreviation (1):
3142 Abbreviation list expansion can be used to reduce typing long file names:
3146 'directory-abbrev-alist
3147 '("^/xy" . "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))
3150 The reduced typing: @kbd{C-x C-f /xy @key{RET}}.
3152 @strong{Note} that file name cannot be edited here because the
3153 environment variables are not expanded during editing in the
3157 Define own abbreviation (2):
3159 The @code{abbrev-mode} gives additional flexibility for editing in the
3163 (define-abbrev-table 'my-tramp-abbrev-table
3164 '(("xy" "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}")))
3167 'minibuffer-setup-hook
3170 (setq local-abbrev-table my-tramp-abbrev-table)))
3172 (defadvice minibuffer-complete
3173 (before my-minibuffer-complete activate)
3176 ;; If you use partial-completion-mode
3177 (defadvice PC-do-completion
3178 (before my-PC-do-completion activate)
3182 The reduced typing: @kbd{C-x C-f xy @key{TAB}}.
3184 The minibuffer expands for further editing.
3186 @item Use bookmarks:
3188 Use bookmarks to save Tramp file names.
3190 @pxref{Bookmarks, , , emacs}.
3193 Upon visiting a location with @value{tramp}, save it as a bookmark with
3194 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{set}}.
3196 To revisit that bookmark:
3197 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{jump}}.
3199 @item Use recent files:
3201 @file{recentf} remembers visited places.
3203 @pxref{File Conveniences, , , emacs}.
3206 Keep remote file names in the recent list without have to check for
3207 their accessibility through remote access:
3213 Reaching recently opened files: @kbd{@key{menu-bar} @key{file}
3216 @item Use filecache:
3218 Since @file{filecache} remembers visited places, add the remote
3219 directory to the cache:
3222 (eval-after-load "filecache"
3223 '(file-cache-add-directory
3224 "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))
3227 Then use directory completion in the minibuffer with @kbd{C-x C-f
3232 @file{bbdb} has a built-in feature for Ange FTP files, which also
3233 works for @value{tramp} file names.
3235 @pxref{bbdb-ftp, Storing FTP sites in the BBDB, , bbdb}.
3238 Load @file{bbdb} in Emacs:
3245 Create a BBDB entry with @kbd{M-x bbdb-create-ftp-site}. Then specify
3246 a method and user name where needed. Examples:
3249 @kbd{M-x bbdb-create-ftp-site @key{RET}}
3250 @b{Ftp Site:} news.my.domain @key{RET}
3251 @b{Ftp Directory:} /opt/news/etc/ @key{RET}
3252 @b{Ftp Username:} ssh@value{postfixhop}news @key{RET}
3253 @b{Company:} @key{RET}
3254 @b{Additional Comments:} @key{RET}
3257 In BBDB buffer, access an entry by pressing the key @key{F}.
3261 Thanks to @value{tramp} users for contributing to these recipes.
3264 Why saved multi-hop file names do not work in a new Emacs session?
3266 When saving ad-hoc multi-hop @value{tramp} file names (@pxref{Ad-hoc
3267 multi-hops}) via bookmarks, recent files, filecache, bbdb, or another
3268 package, use the full ad-hoc file name including all hops, like
3269 @file{@trampfn{ssh, bird, bastion|ssh@value{postfixhop}news.my.domain,
3272 Alternatively, when saving abbreviated multi-hop file names
3273 @file{@trampfn{ssh, news, news.my.domain, /opt/news/etc}}, the custom
3274 option @code{tramp-save-ad-hoc-proxies} must be set non-@code{nil}
3279 How to connect to a remote Emacs session using @value{tramp}?
3281 Configure Emacs Client
3283 (@pxref{Emacs Server, , , emacs}).
3286 Then on the remote host, start the Emacs Server:
3290 (setq server-host (system-name)
3295 If @code{(system-name)} of the remote host cannot be resolved on the
3296 local host, use IP address instead.
3298 Copy from the remote host the resulting file
3299 @file{~/.emacs.d/server/server} to the local host, to the same
3302 Then start Emacs Client from the command line:
3305 emacsclient @trampfn{ssh, user, host, /file/to/edit}
3308 @code{user} and @code{host} refer to the local host.
3310 To make Emacs Client an editor for other programs, use a wrapper
3311 script @file{emacsclient.sh}:
3315 emacsclient @trampfn{ssh, $(whoami), $(hostname --fqdn), $1}
3318 Then change the environment variable @env{EDITOR} to point to the
3322 export EDITOR=/path/to/emacsclient.sh
3327 How to disable other packages from calling @value{tramp}?
3329 There are packages that call @value{tramp} without the user ever
3330 entering a remote file name. Even without applying a remote file
3331 syntax, some packages enable @value{tramp} on their own. How can users
3332 disable such features.
3338 Disable @value{tramp} file name completion:
3341 (custom-set-variables
3342 '(ido-enable-tramp-completion nil))
3348 Disable remote directory tracking mode:
3351 (rlogin-directory-tracking-mode -1)
3357 How to disable @value{tramp}?
3361 To keep Ange FTP as default the remote files access package, set this
3365 (setq tramp-default-method "ftp")
3369 To disable both @value{tramp} (and Ange FTP), set @code{tramp-mode} to
3370 @code{nil} in @file{.emacs}.
3373 (setq tramp-mode nil)
3377 To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp}. Unloading
3378 @value{tramp} resets Ange FTP plugins also.
3383 @c For the developer
3384 @node Files directories and localnames
3385 @chapter How file names, directories and localnames are mangled and managed.
3388 * Localname deconstruction:: Splitting a localname into its component parts.
3389 * External packages:: Integrating with external Lisp packages.
3393 @node Localname deconstruction
3394 @section Splitting a localname into its component parts
3396 @value{tramp} package redefines lisp functions
3397 @code{file-name-directory} and @code{file-name-nondirectory} to
3398 accommodate the unique file naming syntax that @value{tramp} requires.
3400 The replacements dissect the file name, use the original handler for
3401 the localname, take that result, and then re-build the @value{tramp}
3402 file name. By relying on the original handlers for localnames,
3403 @value{tramp} benefits from platform specific hacks to the original
3407 @node External packages
3408 @section Integrating with external Lisp packages
3409 @subsection File name completion.
3411 For name completions in the minibuffer, @value{tramp} depends on the
3412 last input character to decide whether to look for method name
3413 completion or host name completion. For example, @kbd{C-x C-f
3414 @value{prefix}ssh@value{postfixhop} @key{TAB}} is not entirely clear
3415 if @option{ssh} is a method or a host name. But if the last input
3416 character was either @key{TAB}, @key{SPACE} or @kbd{?}, then
3417 @value{tramp} favors file name completion over host name completion.
3419 What about external packages using other characters to trigger file
3420 name completions? They must somehow signal this to @value{tramp}. Use
3421 the variable @code{non-essential} temporarily and bind it to
3422 non-@code{nil} value.
3425 (let ((non-essential t))
3430 @subsection File attributes cache.
3432 Keeping a local cache of remote file attributes in sync with the
3433 remote host is a time-consuming operation. Flushing and re-querying
3434 these attributes can tax @value{tramp} to a grinding halt on busy
3437 To get around these types of slow-downs in @value{tramp}'s
3438 responsiveness, set the @code{process-file-side-effects} to @code{nil}
3439 to stop @value{tramp} from flushing the cache. This is helpful in
3440 situations where callers to @code{process-file} know there are no file
3441 attribute changes. The let-bind form to accomplish this:
3444 (let (process-file-side-effects)
3448 For asynchronous processes, @value{tramp} uses a process sentinel to
3449 flush file attributes cache. When callers to @code{start-file-process}
3450 know beforehand no file attribute changes are expected, then the
3451 process sentinel should be set to the default state. In cases where
3452 the caller defines its own process sentinel, @value{tramp}'s process
3453 sentinel is overwritten. The caller can still flush the file
3454 attributes cache in its process sentinel with this code:
3457 (unless (memq (process-status proc) '(run open))
3458 (dired-uncache remote-directory))
3461 Since @value{tramp} traverses subdirectories starting with the
3462 root-directory, it is most likely sufficient to make the
3463 @code{default-directory} of the process buffer as the root directory.
3466 @node Traces and Profiles
3467 @chapter How to Customize Traces
3469 @value{tramp} messages are raised with verbosity levels ranging from 0
3470 to 10. @value{tramp} does not display all messages; only those with a
3471 verbosity level less than or equal to @code{tramp-verbose}.
3473 The verbosity levels are
3475 @w{ 0} silent (no @value{tramp} messages at all)
3476 @*@indent @w{ 1} errors
3477 @*@indent @w{ 2} warnings
3478 @*@indent @w{ 3} connection to remote hosts (default verbosity)
3479 @*@indent @w{ 4} activities
3480 @*@indent @w{ 5} internal
3481 @*@indent @w{ 6} sent and received strings
3482 @*@indent @w{ 7} file caching
3483 @*@indent @w{ 8} connection properties
3484 @*@indent @w{ 9} test commands
3485 @*@indent @w{10} traces (huge)
3487 With @code{tramp-verbose} greater than or equal to 4, messages are
3488 also written to a @value{tramp} debug buffer. Such debug buffers are
3489 essential to bug and problem analyses. For @value{tramp} bug reports,
3490 set the @code{tramp-verbose} level to 6 (@pxref{Bug Reports}).
3492 The debug buffer is in
3494 @ref{Outline Mode, , , emacs}.
3499 In this buffer, messages can be filtered by their level. To see
3500 messages up to verbosity level 5, enter @kbd{C-u 6 C-c C-q}.
3502 Other navigation keys are described in
3503 @ref{Outline Visibility, , , emacs}.
3506 @value{tramp} handles errors internally. But to get a Lisp backtrace,
3507 both the error and the signal have to be set as follows:
3510 (setq debug-on-error t
3514 To enable stepping through @value{tramp} function call traces, they
3515 have to be specifically enabled as shown in this code:
3519 (dolist (elt (all-completions "tramp-" obarray 'functionp))
3520 (trace-function-background (intern elt)))
3521 (untrace-function 'tramp-read-passwd)
3522 (untrace-function 'tramp-gw-basic-authentication)
3525 The buffer @file{*trace-output*} contains the output from the function
3526 call traces. Disable @code{tramp-read-passwd} and
3527 @code{tramp-gw-basic-authentication} to stop password strings from
3528 being written to @file{*trace-output*}.
3531 @node GNU Free Documentation License
3532 @appendix GNU Free Documentation License
3533 @include doclicense.texi
3536 @node Function Index
3537 @unnumbered Function Index
3541 @node Variable Index
3542 @unnumbered Variable Index
3547 @unnumbered Concept Index
3554 @c * Say something about the .login and .profile files of the remote
3556 @c * Explain how tramp.el works in principle: open a shell on a remote
3557 @c host and then send commands to it.
3558 @c * Consistent small or capitalized words especially in menus.
3559 @c * Make a unique declaration of @trampfn.