     [file docstyle.texi not included]

     [file trampver.texi not included]

tramp version trampver User Manual
**********************************

This file documents tramp version trampver, a remote file editing package for Emacs.

tramp stands for ``Transparent Remote (file) Access, Multiple Protocol''.  This package provides remote file editing, similar to Ange FTP.

The difference is that Ange FTP uses FTP to transfer files between the local and the remote host, whereas tramp uses a combination of rsh and rcp or other work-alike programs, such as ssh/scp.

You can find the latest version of this document on the web at http://www.gnu.org/software/tramp/.

There is a mailing list for tramp, available at tramp-devel@gnu.org, and archived at the tramp Mail Archive (http://lists.gnu.org/archive/html/tramp-devel/).

Copyright © 1999--2016 Free Software Foundation, Inc.

     Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the license is included in the section entitled ``GNU Free Documentation License''.

     (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and modify this GNU manual.''

An overview of tramp
********************

tramp is for transparently accessing remote files from within Emacs.  tramp enables an easy, convenient, and consistent interface to remote files as if they are local files.  tramp's transparency extends to editing, version control, and dired.

tramp can access remote hosts using any number of access methods, such as rsh, rlogin, telnet, and related programs.  If these programs can successfully pass ASCII] characters, tramp can use them. tramp does not require or mandate 8-bit clean connections.

tramp's most common access method is through ssh, a more secure alternative to ftp and other older access methods.

tramp on Windows operating systems is integrated with the PuTTY package, and uses the plink program.

tramp mostly operates transparently in the background using the connection programs.  As long as these programs enable remote login and can use the terminal, tramp can adapt them for seamless and transparent access.

tramp temporarily transfers a remote file's contents to the local host editing and related operations.  tramp can also transfer files between hosts using standard Emacs interfaces, a benefit of direct integration of tramp in Emacs.

tramp can transfer files using any number of available host programs for remote files, such as rcp, scp, rsync or (under Windows) pscp.  tramp provides easy ways to specify these programs and customize them to specific files, hosts, or access methods.

For faster small-size file transfers, tramp supports encoded transfers directly through the shell using mimencode or uuencode provided such tools are available on the remote host.

tramp behind the scenes
.......................

Accessing a remote file through tramp entails a series of actions, many of which are transparent to the user.  Yet some actions may require user response (such as entering passwords or completing file names).  One typical scenario, opening a file on a remote host, is presented here to illustrate the steps involved:

C-x C-f to initiate find-file, enter part of the tramp file name, then hit TAB for completion.  If this is the first time connection to that host, here's what happens:

  * tramp invokes telnet HOST or rsh HOST
     -l USER and establishes an external process to connect to the remote host.  tramp communicates with the process through an Emacs buffer, which also shows output from the remote host.

  * The remote host may prompt for a login name (for telnet, for example) in the buffer.  If on the other hand, the login name was included in the file name portion, tramp sends the login name followed by a newline.

  * The remote host may then prompt for a password or pass phrase (for rsh or for telnet).  tramp displays the password prompt in the minibuffer.  tramp then sends whatever is entered to the remote host, followed by a newline.

  * tramp now waits for either the shell prompt or a failed login message.

     If tramp does not receive any messages within a timeout period (a minute, for example), then tramp responds with an error message about not finding the remote shell prompt.  If any messages from the remote host, tramp displays them in the buffer.

     For any login failed message from the remote host, tramp aborts the login attempt, and repeats the login steps again.

  * Upon successful login and tramp recognizes the shell prompt from the remote host, tramp prepares the shell environment by turning off echoing, setting shell prompt, and other housekeeping chores.

     Note that for the remote shell, tramp invokes /bin/sh.  The remote host must recognize exec /bin/sh and execute the appropriate shell.  This shell must support Bourne shell syntax.

  * tramp executes cd and ls commands to find which files exist on the remote host.  tramp sometimes uses echo with globbing.  tramp checks if a file or directory is writable with test.  After each command, tramp parses the output from the remote host for completing the next operation.

  * After remote file name completion, tramp transfers the file contents from the remote host.

     For inline transfers, tramp sends a command, such as mimencode -b /path/to/remote/file, waits until the output has accumulated in the buffer, decodes that output to produce the file's contents.

     For external transfers, tramp sends a command as follows:

          rcp user@host:/path/to/remote/file /tmp/tramp.4711

     tramp reads the local temporary file /tmp/tramp.4711 into a buffer, and then deletes the temporary file.

  * Edit, modify, change the buffer contents as normal, and then save the buffer wth C-x C-s.

  * tramp transfers the buffer contents to the remote host in a reverse of the process using the appropriate inline or external program.

I hope this has provided you with a basic overview of what happens behind the scenes when you open a file with tramp.

Obtaining tramp
***************

tramp is included as part of Emacs (since Emacs version 22.1).

tramp is also freely packaged for download on the Internet at ftp://ftp.gnu.org/gnu/tramp/.

tramp development versions are available on Git servers. Development versions contain new and incomplete features.

One way to obtain from Git server is to visit the Savannah project page at the following URL and then clicking on the Git link in the navigation bar at the top.

http://savannah.gnu.org/projects/tramp/

Another way is to follow the terminal session below:

     ] cd ~/emacs
     ] git clone git://git.savannah.gnu.org/tramp.git

From behind a firewall:

     ] git config --global http.proxy http://user:pwd@proxy.server.com:8080
     ] git clone http://git.savannah.gnu.org/r/tramp.git

Tramp developers:

     ] git clone login@git.sv.gnu.org:/srv/git/tramp.git

After one of the above commands, ~/emacs/tramp will containing the latest version of tramp.

To fetch updates from the repository, use git pull:

     ] cd ~/emacs/tramp
     ] git pull

Run autoconf as follows to generate an up-to-date configure script:

     ] cd ~/emacs/tramp
     ] autoconf

History of tramp
****************

tramp development started at the end of November 1998 as rssh.el.  It provided only one method of access.  It used ssh for login and scp to transfer file contents. The name was changed to rcp.el before it got its preset name tramp.  New methods of remote access were added, so was support for version control.

April 2000 was the first time when multi-hop methods were added.  In July 2002, tramp unified file names with Ange-FTP.  In July 2004, proxy hosts replaced multi-hop methods.  Running commands on remote hosts was introduced in December 2005.  Support for gateways since April 2007. Remote commands on Windows hosts since September 2011.  Ad-hoc multi-hop methods (with a changed syntax) re-enabled in November 2011.

In November 2012, added Juergen Hoetzel's tramp-adb.el.

Configuring tramp
*****************

tramp is initially configured to use the scp program to connect to the remote host.  Just type C-x C-f and then enter file name prefix
user@hostpostfix/path/to.file.  For details, see Default Method.

For problems related to the behavior of remote shell, see Remote shell setup for details.

For changing the connection type and file access method from the defaults to one of several other options, see (see Connection types).

Note that some user options and variables described in these examples are not auto loaded by Emacs.  All examples require tramp is installed and loaded:

     (require 'tramp)

Types of connections to remote hosts
====================================

Inline method and external method are the two basic types of access methods.  While they both use the same remote shell access programs, such as rsh, ssh, or telnet, they differ in the file access methods.  Choosing the right method becomes important for editing files, transferring large files, or operating on a large number of files.

The performance of the external methods is generally better than that of the inline methods, at least for large files.  This is caused by the need to encode and decode the data when transferring inline.

The one exception to this rule are the scp-based access methods.  While these methods do see better performance when actually transferring files, the overhead of the cryptographic negotiation at startup may drown out the improvement in file transfer times.

External methods should be configured such a way that they don't require a password (with ssh-agent, or such alike).  Modern scp implementations offer options to reuse existing ssh connections, which will be enabled by default if available.  If it isn't possible, you should consider Password handling, otherwise you will be prompted for a password every copy action.

Inline methods
==============

Inline methods use the same login connection to transfer file contents.  Inline methods are quick and easy for small files.  They depend on the availability of suitable encoding and decoding programs on the remote host.  For local source and destination, tramp may use built-in equivalents of such programs in Emacs.

Inline methods can work in situations where an external transfer program is unavailable.  Inline methods also work when transferring files between different user identities on the same host.

tramp checks the remote host for the availability and usability of mimencode (part of the metamail package) or uuencode.  tramp uses the first reliable command it finds.  tramp's search path can be customized, see Remote programs.

In case both mimencode and uuencode are unavailable, tramp first transfers a small Perl program to the remote host, and then tries that program for encoding and decoding.

To increase transfer speeds for large text files, use compression before encoding.  The variable TRAMP-INLINE-COMPRESS-START-SIZE specifies the file size for such optimization.

rsh

     rsh is an option for connecting to hosts within local networks since rsh is not as secure as other methods.

ssh

     ssh is a more secure option than others to connect to a remote host.

     ssh can also take extra parameters as port numbers.  For example, a host on port 42 is specified as host#42 (the real host name, a hash sign, then a port number).  It is the same as passing -p 42 to the ssh command.

telnet

     Connecting to a remote host with telnet is as insecure as the rsh method.

su

     Instead of connecting to a remote host, su program allows editing as another user.  The host can be either localhost or the host returned by the function (system-name).  See Multi-hops for an exception to this behavior.

sudo

     Similar to su method, sudo uses sudo. sudo must have sufficient rights to start a shell.

sg

     The sg program allows editing as different group.  The host can be either localhost or the host returned by the function (system-name).  The user name must be specified, but it denotes a group name.  See Multi-hops for an exception to this behavior.

sshx

     Works like ssh but without the extra authentication prompts. sshx uses ssh -t -t HOST -l USER /bin/sh to open a connection with a ``standard'' login shell.

     Note that sshx does not bypass authentication questions.  For example, if the host key of the remote host is not known, sshx will still ask ``Are you sure you want to continue connecting?''.  tramp cannot handle such questions. Connections will have to be setup where logins can proceed without such questions.

     sshx is useful for Windows users when ssh triggers an error about allocating a pseudo tty.  This happens due to missing shell prompts that confuses tramp.

     sshx supports the -p argument.

krlogin

     This method is also similar to ssh.  It uses the krlogin -x command only for remote host login.

ksu

     This is another method from the Kerberos suite.  It behaves like su.

plink

     plink method is for Windows users with the PuTTY implementation of SSH.  It uses plink -ssh to log in to the remote host.

     Check the Share SSH connections if possible control for that session.

     plink method supports the -P argument.

plinkx

     Another method using PuTTY on Windows with session names instead of host names.  plinkx calls plink -load SESSION -t. User names and port numbers must be defined in the session.

     Check the Share SSH connections if possible control for that session.

External methods
================

External methods operate over multiple channels, using the remote shell connection for some actions while delegating file transfers to an external transfer program.

External methods save on the overhead of encoding and decoding of inline methods.

Since external methods have the overhead of opening a new channel, files smaller than TRAMP-COPY-SIZE-LIMIT still use inline methods.

rcp---rsh and rcp

     This method uses the rsh and rcp commands to connect to the remote host and transfer files.  This is the fastest access method available.

     The alternative method remcp uses the remsh and rcp commands.

scp---ssh and scp

     Using a combination of ssh to connect and scp to transfer is the most secure.  While the performance is good, it is slower than the inline methods for smaller files.  Though there is no overhead of encoding and decoding of the inline methods, scp's cryptographic handshake negates those speed gains.

     ssh-based methods support -p feature for specifying port numbers.  For example, host#42 passes -p 42 in the argument list to ssh, and -P 42 in the argument list to scp.

rsync---ssh and rsync

     ssh command to connect in combination with rsync command to transfer is similar to the scp method.

     rsync performs much better than scp when transferring files that exist on both hosts.  However, this advantage is lost if the file exists only on one side of the connection.

     This method supports the -p argument.

scpx---ssh and scp

     scpx is useful to avoid login shell questions.  It is similar in performance to scp.  scpx uses ssh -t -t HOST -l USER /bin/sh to open a connection.

     sshx is useful for Windows users when ssh triggers an error about allocating a pseudo tty.  This happens due to missing shell prompts that confuses tramp.

     This method supports the -p argument.

pscp---plink and pscp

psftp---plink and psftp

     These methods are similar to scp or sftp, but they use the plink command to connect to the remote host, and they use pscp or psftp for transferring the files. These programs are part of PuTTY, an SSH implementation for Windows.

     Check the Share SSH connections if possible control for that session.

     These methods support the -P argument.

fcp---fsh and fcp

     This method is similar to scp, but uses fsh to connect and fcp to transfer files.  fsh/fcp, a front-end for ssh, reuse ssh session by submitting several commands.  This avoids the startup overhead due to scp's secure connection.  Inline methods have similar benefits.

     The command used for this connection is: fsh HOST -l USER /bin/sh -i

     fsh has no inline method since the multiplexing it offers is not useful for tramp.  fsh connects to remote host and tramp keeps that one connection open.

nc---telnet and nc

     Using telnet to connect and nc to transfer files is sometimes the only combination suitable for accessing routers or NAS hosts.  These dumb devices have severely restricted local shells, such as the busybox and do not host any other encode or decode programs.

ftp

     When tramp uses ftp, it forwards requests to whatever ftp program is specified by Ange FTP.  This external program must be capable of servicing requests from tramp.

smb---smbclient

     This is another non-native tramp method.  smbclient connects to any host with SMB/CIFS protocol, such as MS Windows and Samba Servers running on Unixes.  Tests show this tramp method works with MS Windows NT, MS Windows 2000, MS Windows XP, MS Windows Vista, and MS Windows 7.

     Using smbclient requires a few tweaks when working with tramp:

     The first directory in the localname must be a share name on the remote host.

     Since smb shares end in the $ character, tramp must use $$ when specifying those shares to avoid environment variable substitutions.

     When tramp is not specific about the share name or uses the generic remote directory /, smbclient returns all available shares.

     Since SMB authentication is based on each SMB share, tramp prompts for a password even when accessing a different share on the same SMB host.  This prompting can be suppressed by Password handling.

     To accommodate user name/domain name syntax required by MS Windows authorization, tramp provides for an extended syntax in user%domain format (where user is username, % is the percent symbol, and domain is the windows domain name).  An example:

          prefix
          smbpostfixhop
          daniel%BIZARRE@melancholiapostfix/daniel$$/.emacs

     where user daniel connects as a domain user to the SMB host melancholia in the windows domain BIZARRE to edit .emacs located in the home directory (share daniel$).

     Alternatively, for local WINS users (as opposed to domain users), substitute the domain name with the name of the local host in UPPERCASE as shown here:

          prefix
          smbpostfixhop
          daniel%MELANCHOLIA@melancholiapostfix/daniel$$/.emacs

     where user daniel connects as local user to the SMB host melancholia in the local domain MELANCHOLIA to edit .emacs located in the home directory (share daniel$).

     The domain name and user name are optional for smbclient authentication.  When user name is not specified, smbclient uses the anonymous user (without prompting for password).  This behavior is unlike other tramp methods, where local user name is substituted.

     smb method is unavailable if Emacs is run under a local user authentication context in MS Windows.  However such users can still access remote files using UNC file names instead of tramp:

          //melancholia/daniel$$/.emacs

     UNC file name specification does not allow to specify a different user name for authentication like the smbclient can.

adb

     This method uses Android Debug Bridge program for accessing Android devices.  The Android Debug Bridge must be installed locally for tramp to work.  Some GNU/Linux distributions provide Android Debug Bridge as an installation package.  Alternatively, the program is installed as part of the Android SDK.  tramp finds the adb program either via the PATH environment variable or the absolute path set in the variable TRAMP-ADB-PROGRAM.

     tramp connects to Android devices with adb only when the custom option tramp-adb-connect-if-not-connected is not nil.  Otherwise, the connection must be established outside Emacs.

     tramp does not require a host name part of the remote file name when a single Android device is connected to adb. tramp instead uses prefix
     adbpostfixhop
     postfix as the default name.  adb devices shows available host names.

     adb method normally does not need user name to authenticate on the Andriod device because it runs under the adbd process.  But when a user name is specified, however, tramp applies an su in the syntax.  When authentication does not succeed, especially on un-rooted Android devices, tramp displays login errors.

     For Andriod devices connected through TCP/IP, a port number can be specified using device#42 host name syntax or tramp can use the default value as declared in adb command.  Port numbers are not applicable to Android devices connected through USB.

Gateway methods
===============

Gateway methods are for proxy host declarations (see Multi-hops) so as to pass through firewalls and proxy servers.  They are not like the other methods that declare direct connections to a remote host.

A gateway method always comes with a port setting.  tramp targets the port number with the gateway method localhost#random_port from where the firewall or proxy server is accessed.

Gateway methods support user name and password declarations for authenticating the corresponding firewall or proxy server.  Such authentication can be passed through only if granted access by system administrators.

tunnel

     This method implements an HTTP tunnel via the CONNECT command (conforming to RFC 2616, 2817 specifications).  Proxy servers using HTTP version 1.1 or later protocol support this command.

     For authentication, this protocol uses only Basic Authentication (see RFC 2617).  When no port number is specified, this protocol defaults to 8080.

socks

     The socks method connects to SOCKSv5 servers (see RFC 1928) and supports Username/Password Authentication.

     The default port number for the socks server is 1080, if not specified otherwise.

Selecting a default method
==========================

Default method is for transferring files.  The variable tramp-default-method sets it.  tramp uses this variable to determine the default method for tramp file names that do not have one specified.

     (setq tramp-default-method "ssh")

Default methods for transferring files can be customized for specific user and host combinations through the alist variable tramp-default-method-alist.

For example, the following two lines specify to use the ssh method for all user names matching john and the rsync method for all host names matching lily.  The third line specifies to use the su method for the user root on the host localhost.

     (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
     (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
     (add-to-list 'tramp-default-method-alist
                  '("\\`localhost\\'" "\\`root\\'" "su"))

See the documentation for the variable tramp-default-method-alist for details.

External methods performance faster for large files.

See Inline methods. See External methods.

Choosing the access method also depends on the security environment. For example, rsh and telnet methods that use clear text password transfers are inappropriate for over the Internet connections.  Secure remote connections should use ssh that provide encryption.

Which method to use?
--------------------

tramp provides maximum number of choices for maximum flexibility.  Choosing which method depends on the hosts, clients, network speeds, and the security context.

Start by using an inline method.

External methods might be more efficient for large files, but most tramp users edit small files more often than large files.

Enable compression, TRAMP-INLINE-COMPRESS-START-SIZE, for a performance boost for large files.

Since ssh has become the most common method of remote host access and it has the most reasonable security protocols, use ssh method.  Typical ssh usage to edit the /etc/motd file on the otherhost:

     C-x C-f prefix
     sshpostfixhop
     root@otherhostpostfix/etc/motd RET

If ssh is unavailable for whatever reason, look for other obvious options.  For Windows, try the plink method.  For Kerberos, try krlogin.

For editing local files as su or sudo methods, try the shortened syntax of root:

     C-x C-f prefix
     supostfixhop
     postfix/etc/motd RET

For editing large files, scp is faster than ssh. pscp is faster than plink.  But this speed improvement is not always true.

Selecting a default user
========================

tramp file name can omit the user name part since tramp substitutes the currently logged-in user name.  However this substitution can be overridden with tramp-default-user. For example:

     (setq tramp-default-user "root")

Instead of a single default user, tramp-default-user-alist allows multiple default user values based on access method or host name combinations.  The alist can hold multiple values.  For example, to use the john as the default user for the domain somewhere.else only:

     (add-to-list 'tramp-default-user-alist
                  '("ssh" ".*\\.somewhere\\.else\\'" "john"))

See the documentation for the variable tramp-default-user-alist for more details.

A Caution: tramp will override any default user specified in the configuration files outside Emacs, such as ~/.ssh/config. To stop tramp from applying the default value, set the corresponding alist entry to nil:

     (add-to-list 'tramp-default-user-alist
                  '("ssh" "\\`here\\.somewhere\\.else\\'" nil))

The last entry in tramp-default-user-alist should be reserved for catch-all or most often used login.

     (add-to-list 'tramp-default-user-alist
                  '(nil nil "jonas") t)

Selecting a default host
========================

When host name is omitted, tramp substitutes the value from the tramp-default-host variable.  It is initially populated with the local hostname where Emacs is running.  Both the default user and default host can be overridden as follows:

     (setq tramp-default-user "john"
           tramp-default-host "target")

With both defaults set, prefix
sshpostfixhop
postfix will connect tramp to John's home directory on target.

Note /:: won't work, because /: is the prefix for quoted file names.

Instead of a single default host, tramp-default-host-alist allows multiple default host values based on access method or user name combinations.  The alist can hold multiple values.  While tramp-default-host is sufficient in most cases, some methods, like adb, require defaults overwritten.

See the documentation for the variable tramp-default-host-alist for more details.

Connecting to a remote host using multiple hops
===============================================

Multi-hops are methods to reach hosts behind firewalls or to reach the outside world from inside a bastion host.  With multi-hops, tramp can negotiate these hops with the appropriate user/host authentication at each hop.  All methods until now have been the single hop kind, where the start and end points of the connection did not have intermediate check points.

 -- User Option: tramp-default-proxies-alist
     tramp-default-proxies-alist specifies proxy hosts to pass through.  This variable is list of triples consisting of (HOST USER PROXY).

     The first match is the proxy host through which passes the file name and the target host matching USER@HOST.  HOST and USER are regular expressions or nil, interpreted as a regular expression which always matches.

     PROXY is a literal tramp file name whose local name part is ignored, and the method and user name parts are optional.

     The method must be an inline or gateway method (see Inline methods, see Gateway methods). If PROXY is nil, no additional hop is required reaching USER@HOST.

     For example, to pass through the host bastion.your.domain as user bird to reach remote hosts outside the local domain:

          (add-to-list 'tramp-default-proxies-alist
                       '("\\." nil "prefix
          sshpostfixhop
          bird@bastion.your.domainpostfix"))
          (add-to-list 'tramp-default-proxies-alist
                       '("\\.your\\.domain\\'" nil nil))

     Note: add-to-list adds elements at the beginning of a list.  Therefore, most relevant rules must come last in the list.

     Proxy hosts can be cascaded in the alist.  If there is another host called jump.your.domain, which is the only host allowed to connect to bastion.your.domain, then:

          (add-to-list 'tramp-default-proxies-alist
                       '("\\`bastion\\.your\\.domain\\'"
                         "\\`bird\\'"
                         "prefix
          sshpostfixhop
          jump.your.domainpostfix"))

     PROXY can take patterns %h or %u for HOST or USER respectively.

     To login as root on remote hosts in the domain your.domain, but login as root is disabled for non-local access, then use this alist entry:

          (add-to-list 'tramp-default-proxies-alist
                       '("\\.your\\.domain\\'" "\\`root\\'" "prefix
          sshpostfixhop
          %hpostfix"))

     Opening prefix
     sudopostfixhop
     randomhost.your.domainpostfix first connects to randomhost.your.domain via ssh under your account name, and then perform sudo -u root on that host.

     It is key for the sudo method in the above example to be applied on the host after reaching it and not on the local host.

     HOST, USER and PROXY can also take Lisp forms.  These forms when evaluated must return either a string or nil.

     To generalize (from the previous example): For all hosts, except my local one, first connect via ssh, and then apply sudo -u root:

          (add-to-list 'tramp-default-proxies-alist
                       '(nil "\\`root\\'" "prefix
          sshpostfixhop
          %hpostfix"))
          (add-to-list 'tramp-default-proxies-alist
                       '((regexp-quote (system-name)) nil nil))

     The above configuration allows tramp connection as root to remote Ubuntu hosts.

     tramp-default-proxies-alist is also used for passing through firewalls or proxy servers.

     For example, the local host proxy.your.domain on port 3128 serves as HTTP proxy to the outer world.  User has access rights to another proxy server on host.other.domain. (HTTP tunnels are intended for secure SSL/TLS communication.  Therefore, many proxy servers restrict the tunnels to related target ports.  You might need to run your ssh server on your target host host.other.domain on such a port, like 443 (https).  See http://savannah.gnu.org/maintenance/CvsFromBehindFirewall for discussion of ethical issues.)  Then the configuration is:

          (add-to-list 'tramp-default-proxies-alist
                       '("\\`host\\.other\\.domain\\'" nil
                       "prefix
          tunnelpostfixhop
          proxy.your.domain#3128postfix"))

     Gateway methods in a multiple hop chain can be declared only as the first hop.

Passing through hops involves dealing with restricted shells, such as rbash.  If tramp is made aware, then it would use them for proxies only.

 -- User Option: tramp-restricted-shell-hosts-alist
     An alist of regular expressions of hosts running restricted shells, such as rbash.  tramp will then use them only as proxies.

     To specify the bastion host from the example above as running a restricted shell:

          (add-to-list 'tramp-restricted-shell-hosts-alist
                       "\\`bastion\\.your\\.domain\\'")

Using Non-Standard Methods
==========================

The tramp-methods variable currently has an exhaustive list of predefined methods.  Any part of this list can be modified with more suitable settings.  Refer to the Lisp documentation of that variable, accessible with C-h v tramp-methods RET.

Selecting config files for user/host name completion
====================================================

tramp-completion-function-alist uses predefined files for user and host name completion (see File name completion).  For each method, it keeps a set of configuration files and a function that can parse that file.  Each entry in tramp-completion-function-alist is of the form (METHOD PAIR1 PAIR2 ...).

Each PAIR is composed of (FUNCTION FILE). FUNCTION is responsible for extracting user names and host names from FILE for completion.  There are two functions which access this variable:

 -- Function: tramp-get-completion-function method
     This function returns the list of completion functions for METHOD.

     Example:

          (tramp-get-completion-function "rsh")

               => ((tramp-parse-rhosts "/etc/hosts.equiv")
                   (tramp-parse-rhosts "~/.rhosts"))

 -- Function: tramp-set-completion-function method function-list
     This function sets FUNCTION-LIST as list of completion functions for METHOD.

     Example:

          (tramp-set-completion-function "ssh"
           '((tramp-parse-sconfig "/etc/ssh_config")
             (tramp-parse-sconfig "~/.ssh/config")))

               => ((tramp-parse-sconfig "/etc/ssh_config")
                   (tramp-parse-sconfig "~/.ssh/config"))

The following predefined functions parsing configuration files exist:

tramp-parse-rhosts

     This function parses files which are syntactical equivalent to ~/.rhosts.  It returns both host names and user names, if specified.

tramp-parse-shosts

     This function parses files which are syntactical equivalent to ~/.ssh/known_hosts.  Since there are no user names specified in such files, it can return host names only.

tramp-parse-sconfig

     This function returns the host nicknames defined by Host entries in ~/.ssh/config style files.

tramp-parse-shostkeys

     SSH2 parsing of directories /etc/ssh2/hostkeys/* and ~/ssh2/hostkeys/*.  Hosts are coded in file names hostkey_PORTNUMBER_HOST-NAME.pub.  User names are always nil.

tramp-parse-sknownhosts

     Another SSH2 style parsing of directories like /etc/ssh2/knownhosts/* and ~/ssh2/knownhosts/*.  This case, hosts names are coded in file names HOST-NAME.ALGORITHM.pub.  User names are always nil.

tramp-parse-hosts

     A function dedicated to /etc/hosts for host names.

tramp-parse-passwd

     A function which parses /etc/passwd files for user names.

tramp-parse-etc-group

     A function which parses /etc/group files for group names.

tramp-parse-netrc

     A function which parses ~/.netrc and ~/.authinfo-style files.

To keep a custom file with custom data in a custom structure, a custom function has to be provided.  This function must meet the following conventions:

 -- Function: my-tramp-parse file
     FILE must be either a file on the host, or nil.  The function must return a list of (USER HOST), which are taken as candidates for completion for user and host names.

     Example:

          (my-tramp-parse "~/.my-tramp-hosts")

               => ((nil "toto") ("daniel" "melancholia"))

Reusing passwords for several connections
=========================================

To avoid repeated prompts for passwords, consider native caching mechanisms, such as ssh-agent for ssh-like methods, or pageant for plink-like methods.

tramp offers alternatives when native solutions cannot meet the need.

Using an authentication file
----------------------------

The package auth-source.el, originally developed for No Gnus, reads passwords from different sources, see auth-source (auth).  The default authentication file is ~/.authinfo.gpg, but this can be changed via the variable auth-sources.

A typical entry in the authentication file:

     machine melancholia port scp login daniel password geheim

The port can take any tramp method (see Inline methods, see External methods).  Omitting port values matches all tramp methods.

Setting auth-source-debug to t to debug messages.

Caching passwords
-----------------

tramp can cache passwords as entered and reuse when needed for the same user or host name independent of the access method.

password-cache-expiry sets the duration (in seconds) the passwords are remembered.  Passwords are never saved permanently nor can they extend beyond the lifetime of the current Emacs session.  Set password-cache-expiry to nil to disable expiration.

Set password-cache to nil to disable password caching.

Implementation Note: password caching depends on password-cache.el package.  tramp activates password caching only if tramp can discover, while Emacs is loading, the package through load-path.

Reusing connection related information
======================================

For faster initial connection times, tramp stores previous connection properties in a file specified by the variable tramp-persistency-file-name.

The default file name for tramp-persistency-file-name is ~/.emacs.d/tramp.

tramp reads this file during Emacs startup, and writes to it when exiting Emacs.  Delete this file for tramp to recreate a new one on next Emacs startup.

Set tramp-persistency-file-name to nil to disable storing connections persistently.

To reuse connection information from the persistent list, tramp needs to uniquely identify every host.  However in some cases, two different connections may result in the same persistent information.  For example, connecting to a host using ssh and connecting to the same host through sshd on port 3001.  Both access methods result in nearly identical persistent specifications prefix
sshpostfixhop
localhostpostfix and prefix
sshpostfixhop
localhost#3001postfix.

Changing host names could avoid duplicates.  One way is to add a Host section in ~/.ssh/config (see Frequently Asked Questions).  Another way is to apply multiple hops (see Multi-hops).

When tramp detects a change in the operating system version in a remote host (via the command uname -sr), it flushes all connection related information for that host and creates a new entry.

Setting own connection related information
==========================================

For more precise customization, parameters specified by tramp-methods can be overwritten manually.

Set tramp-connection-properties to manually override tramp-methods.  Properties in this list are in the form (REGEXP PROPERTY VALUE).  REGEXP matches remote file names.  Use nil to match all.  PROPERTY is the property's name, and VALUE is the property's value.

PROPERTY is any method specific parameter contained in tramp-methods.  The parameter key in tramp-methods is a symbol name tramp-<foo>.  To overwrite that property, use the string <foo> for PROPERTY.  For example, this changes the remote shell:

     (add-to-list 'tramp-connection-properties
                  (list (regexp-quote "prefix
     sshpostfixhop
     user@randomhost.your.domainpostfix")
                        "remote-shell" "/bin/ksh"))
     (add-to-list 'tramp-connection-properties
                  (list (regexp-quote "prefix
     sshpostfixhop
     user@randomhost.your.domainpostfix")
                        "remote-shell-login" '("-")))

The parameters tramp-remote-shell and tramp-remote-shell-login in tramp-methods now have new values for the remote host.

PROPERTY could also be any property found in tramp-persistency-file-name.

To get around how restricted shells randomly drop connections, set the special property busybox.  For example:

     (add-to-list 'tramp-connection-properties
                  (list (regexp-quote "prefix
     sshpostfixhop
     user@randomhost.your.domainpostfix")
                        "busybox" t))

How tramp finds and uses programs on the remote host
====================================================

tramp requires access to and rights to several commands on remote hosts: ls, test, find and cat.

Besides there are other required programs for Inline methods and External methods of connection.

To improve performance and accuracy of remote file access, tramp uses perl (or perl5) and grep when available.

 -- User Option: tramp-remote-path
     tramp-remote-path specifies which remote directory paths tramp can search for Remote programs.

     tramp uses standard defaults, such as /bin and /usr/bin, which are reasonable for most hosts.  To accommodate differences in hosts and paths, for example, /bin:/usr/bin on Debian GNU/Linux or /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin on Solaris, tramp queries the remote host with getconf
     PATH and updates the symbol tramp-default-remote-path.

     For instances where hosts keep obscure locations for paths for security reasons, manually add such paths to local .emacs as shown below for tramp to use when connecting.

          (add-to-list 'tramp-remote-path "/usr/local/perl/bin")

     Another way to find the remote path is to use the path assigned to the remote user by the remote host.  tramp does not normally retain this remote path after logging.  However, tramp-own-remote-path preserves the path value, which can be used to update tramp-remote-path.

          (add-to-list 'tramp-remote-path 'tramp-own-remote-path)

When remote search paths are changed, local tramp caches must be recomputed.  To force tramp to recompute afresh, exit Emacs, remove the persistent file (see Connection caching), and restart Emacs.

Remote shell setup hints
========================

tramp checks for the availability of standard programs in the usual locations.  Common tactics include successively trying test -e, /usr/bin/test -e, and /bin/test -e.  ls -d is another approach.  But these approaches do not help with these new login patterns.

When tramp encounters two-factor logins or additional challenge questions, such as entering birth date or security code or passphrase, tramp needs a few more configuration steps to accommodate them.

The difference between a password prompt and a passphrase prompt is that the password for completing the login while the passphrase is for authorizing access to local authentication information, such as the ssh key.

There is no one configuration to accommodate all the variations in login security, especially not the exotic ones.  However, tramp provides a few tweaks to address the most common ones.

TRAMP-SHELL-PROMPT-PATTERN

     tramp-shell-prompt-pattern is for remote login shell prompt, which may not be the same as the local login shell prompt, shell-prompt-pattern.  Since most hosts use identical prompts, tramp sets a similar default value for both prompts.

TRAMP-PASSWORD-PROMPT-REGEXP

TRAMP-WRONG-PASSWD-REGEXP

     tramp uses TRAMP-PASSWORD-PROMPT-REGEXP to distinguish between prompts for passwords and prompts for passphrases.  By default, TRAMP-PASSWORD-PROMPT-REGEXP handles the detection in English language environments.  See a localization example below:

          (setq
            tramp-password-prompt-regexp
              (concat
                "^.*"
                (regexp-opt
                  '("passphrase" "Passphrase"
                    ;; English
                    "password" "Password"
                    ;; Deutsch
                    "passwort" "Passwort"
                    ;; Français
                    "mot de passe" "Mot de passe") t)
                ".*:\0? *"))

     Similar localization may be necessary for handling wrong password prompts, for which tramp uses TRAMP-WRONG-PASSWD-REGEXP.

tset and other questions

     To suppress inappropriate prompts for terminal type, tramp sets the TERM to dumb before the remote login process begins via the variable tramp-terminal-type.  This will silence common tset related prompts.

     tramp's strategy for handling such prompts (commonly triggered from login scripts on remote hosts) is to set the environment variables so that no prompts interrupt the shell initialization process.

     An alternative approach is to configure tramp with strings that can identify such questions using tramp-actions-before-shell.  Example:

          (defconst my-tramp-prompt-regexp
            (concat (regexp-opt '("Enter the birth date of your mother:") t)
                    "\\s-*")
            "Regular expression matching my login prompt question.")

          (defun my-tramp-action (proc vec)
            "Enter \"19000101\" in order to give a correct answer."
            (save-window-excursion
              (with-current-buffer (tramp-get-connection-buffer vec)
                (tramp-message vec 6 "\n%s" (buffer-string))
                (tramp-send-string vec "19000101"))))

          (add-to-list 'tramp-actions-before-shell
                       '(my-tramp-prompt-regexp my-tramp-action))

Conflicting names for users and variables in .profile

     When a user name is the same as a variable name in a local file, such as .profile, then tramp may send incorrect values for environment variables.  To avoid incorrect values, change the local variable name to something different from the user name.  For example, if the user name is FRUMPLE, then change the variable name to FRUMPLE_DIR.

Non-Bourne commands in .profile

     When the remote host's .profile is also used for shells other than Bourne shell, then some incompatible syntaxes for commands in .profile may trigger errors in Bourne shell on the host and may not complete client's tramp connections.

     One example of a Bourne shell incompatible syntax in .profile: using export FOO=bar instead of FOO=bar; export
     FOO.  After remote login, tramp will trigger an error during its execution of /bin/sh on the remote host because Bourne shell does not recognize the export command as entered in .profile.

     Likewise, (~) character in paths will cause errors because Bourne shell does not do (~) character expansions.

     One approach to avoiding these incompatibilities is to make all commands in ~/.shrc and ~/.profile Bourne shell compatible so tramp can complete connections to that remote. To accommodate using non-Bourne shells on that remote, use other shell-specific config files.  For example, bash can use ~/.bash_profile and ignore .profile.

Interactive shell prompt

     tramp redefines the remote shell prompt internally for robust parsing.  This redefinition affects the looks of a prompt in an interactive remote shell through commands, such as M-x shell.  Such prompts, however, can be reset to something more readable and recognizable using these tramp variables.

     tramp sets the INSIDE_EMACS variable in the startup script file ~/.emacs_SHELLNAME.

     SHELLNAME is bash or equivalent shell names.  Change it by setting the environment variable ESHELL in the .emacs as follows:

          (setenv "ESHELL" "bash")

     Then re-set the prompt string in ~/.emacs_SHELLNAME as follows:

          # Reset the prompt for remote Tramp shells.
          if [ "${INSIDE_EMACS/*tramp*/tramp}" == "tramp" ] ; then
             PS1="[\u@\h \w]$ "
          fi

     See Interactive Shell (emacs).

busybox / nc

     tramp's nc method uses the nc command to install and execute a listener as follows (see tramp-methods):

          # nc -l -p 42

     The above command-line syntax has changed with busybox versions.  If nc refuses the -p parameter, then overwrite as follows:

          (add-to-list
           'tramp-connection-properties
           `(,(regexp-quote "192.168.0.1") "remote-copy-args" (("-l") ("%r"))))

     where 192.168.0.1 is the remote host IP address (see Predefined connection information).

Android shell setup hints
=========================

tramp uses the adb method to access Android devices.  Android devices provide a restricted shell access through an USB connection.  The local host must have Andriod SDK installed.

Applications such as SSHDroid that run sshd process on the Android device can accept any ssh-based methods provided these settings are adjusted:

sh must be specified for remote shell since Android devices do not provide /bin/sh.  sh will then invoke whatever shell is installed on the device with this setting:

     (add-to-list 'tramp-connection-properties
     	     (list (regexp-quote "192.168.0.26") "remote-shell" "sh"))

where 192.168.0.26 is the Android device's IP address. (see Predefined connection information).

tramp requires preserving PATH environment variable from user settings.  Android devices prefer /system/xbin path over /system/bin.  Both of these are set as follows:

     (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
     (add-to-list 'tramp-remote-path "/system/xbin")

When the Android device is not rooted, specify a writable directory for temporary files:

     (add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")

Open a remote connection with the command C-x C-f
prefix
sshpostfixhop
192.168.0.26#2222postfix, where sshd is listening on port 2222.

To add a corresponding entry to the ~/.ssh/config file (recommended), use this:

     Host android
          HostName 192.168.0.26
          User root
          Port 2222

To use the host name android instead of the IP address shown in the previous example, fix the connection properties as follows:

     (add-to-list 'tramp-connection-properties
     	     (list (regexp-quote "android") "remote-shell" "sh"))

Open a remote connection with a more concise command C-x C-f
prefix
sshpostfixhop
androidpostfix.

Auto-save and Backup configuration
==================================

To avoid tramp from saving backup files owned by root to locations accessible to others, default backup settings in backup-directory-alist have to be altered.

Here's a scenario where files could be inadvertently exposed.  Emacs by default writes backup files to the same directory as the original files unless changed to another location, such as ~/.emacs.d/backups/.  Such a directory will also be used by default by tramp when using, say, a restricted file prefix
supostfixhop
root@localhostpostfix/etc/secretfile.  The backup file of the secretfile is now owned by the user logged in from tramp and not root.

When backup-directory-alist is nil (the default), such problems do not occur.

To ``turns off'' the backup feature for tramp files and stop tramp from saving to the backup directory, use this:

     (add-to-list 'backup-directory-alist
                  (cons tramp-file-name-regexp nil))

Disabling backups can be targetted to just su and sudo methods:

     (setq backup-enable-predicate
           (lambda (name)
             (and (normal-backup-enable-predicate name)
                  (not
                   (let ((method (file-remote-p name 'method)))
                     (when (stringp method)
                       (member method '("su" "sudo"))))))))

Another option is to create better backup file naming with user and host names prefixed to the file name.  For example, transforming /etc/secretfile to ~/.emacs.d/backups/!su:root@localhost:!etc!secretfile, set the tramp variable tramp-backup-directory-alist from the existing variable backup-directory-alist.

Then tramp backs up to a file name that is transformed with a prefix consisting of the DIRECTORY name.  This file name prefixing happens only when the DIRECTORY is an absolute local file name.

Example:

     (add-to-list 'backup-directory-alist
                  (cons "." "~/.emacs.d/backups/"))
     (setq tramp-backup-directory-alist backup-directory-alist)

The backup file name of prefix
supostfixhop
root@localhostpostfix/etc/secretfile would be prefix
supostfixhop
root@localhostpostfix~/.emacs.d/backups/!su:root@localhost:!etc!secretfile~.

Just as for backup files, similar issues of file naming affect auto-saving tramp files.  Auto-saved files are saved in the directory specified by the variable auto-save-file-name-transforms.  By default this is set to the local temporary directory.  But in some versions of Debian GNU/Linux, this points to the source directory where the Emacs was compiled. Reset such values to a valid directory.

Set auto-save-file-name-transforms to nil to save auto-saved files to the same directory as the original file.

Alternatively, set the variable tramp-auto-save-directory to direct all auto saves to that location.

Issues with Cygwin ssh
======================

This section is incomplete.  Please share your solutions.

Cygwin's ssh works only with a Cygwin version of Emacs.  To check for compatibility: type M-x eshell, and start ssh test.host.  Incompatbilities trigger this message:

     Pseudo-terminal will not be allocated because stdin is not a terminal.

Some older versions of Cygwin's ssh work with the sshx access method.  Consult Cygwin's FAQ at http://cygwin.com/faq/ for details.

When using the scpx access method, Emacs may call scp with Windows file naming, such as c:/foo.  But the version of scp that is installed with Cygwin does not know about Windows file naming, which causes it to incorrectly look for a host named c.

A workaround: write a wrapper script for scp to convert Windows file names to Cygwin file names.

When using the ssh-agent on Windows for password-less interaction, ssh methods depend on the environment variable SSH_AUTH_SOCK.  But this variable is not set when Emacs is started from a Desktop shortcut and authentication fails.

One workaround is to use a Windows based SSH Agent, such as Pageant.  It is part of the Putty Suite of tools.

The fallback is to start Emacs from a shell.

Using tramp
***********

tramp operates transparently, accessing remote files as if they are local.  However, tramp employs a formalized remote file naming syntax to perform its functions transparently.  This syntax consists of many parts specifying access methods, authentication, host names, and file names.  Ange FTP uses a similar syntax.

Unlike opening local files in Emacs, which are instantaneous, opening remote files in tramp is slower at first.  Sometimes there is a noticable delay before the prompts for passwords or authentication appear in the minibuffer.  Hitting RET or other keys during this gap will be processed by Emacs.  This type-ahead facility is a feature of Emacs that may cause missed prompts when using tramp.

tramp file name conventions
===========================

prefix
hostpostfixlocalfilename opens file LOCALFILENAME on the remote host HOST, using the default method.  See Default Method.

prefixmelancholiapostfix.emacs
     For the file .emacs located in the home directory, on the host melancholia.

prefixmelancholia.danann.netpostfix.emacs
     For the file .emacs specified using the fully qualified domain name of the host.

prefixmelancholiapostfix~/.emacs
     For the file .emacs specified using the ~, which is expanded.

prefixmelancholiapostfix~daniel/.emacs
     For the file .emacs located in daniel's home directory on the host, melancholia.  The ~<user> construct is expanded to the home directory of that user on the remote host.

prefixmelancholiapostfix/etc/squid.conf
     For the file /etc/squid.conf on the host melancholia.

HOST can take IPv4 or IPv6 address, as in prefix
127.0.0.1postfix.emacs or prefix
ipv6prefix::1ipv6postfixpostfix.emacs. For syntactical reasons, IPv6 addresses must be embedded in square brackets ipv6prefix and ipv6postfix.

By default, tramp will use the current local user name as the remote user name for log in to the remote host.  Specifying a different name using the proper syntax will override this default behavior:

     prefix
     user@hostpostfixpath/to.file

prefix
daniel@melancholiapostfix.emacs is for file .emacs in daniel's home directory on the host, melancholia.

Specify other file access methods (see Inline methods, see External methods) as part of the file name.

Method name comes before user name, as in prefixMETHODpostfixhop (Note the trailing colon).  The syntax specificaton for user, host, and file do not change.

To connect to the host melancholia as daniel, using ssh method for .emacs in daniel's home directory, the full specification is: prefix
sshpostfixhop
daniel@melancholiapostfix.emacs.

A remote file name containing a host name, which is the same string as a method name, is not allowed.

For specifying port numbers, affix #<port> to the host name.  For example: prefix
sshpostfixhop
daniel@melancholia#42postfix.emacs.

File name completion
====================

tramp can complete the following tramp file name components: method names, user names, host names, and file names located on remote hosts.  Enable this by activating partial completion in .emacs. See Completion Options (emacs).

For example, type C-x C-f prefixt TAB, tramp completion choices show up as

     prefixhoptelnetpostfixhop   tmp/
     prefixhoptotopostfix

prefixhoptelnetpostfixhop is a possible completion for the respective method, tmp/ stands for the directory /tmp on your local host, and prefixhoptotopostfix might be a host tramp has detected in your ~/.ssh/known_hosts file (when using ssh as default method).

Type e TAB for the minibuffer completion to prefixtelnetpostfixhop.  Typing TAB shows host names tramp from /etc/hosts file, for example.

     prefix
     telnetpostfixhop
     127.0.0.1postfix   prefix
     telnetpostfixhop
     192.168.0.1postfix
     prefixtelnetpostfixhopipv6prefix::1ipv6postfixpostfix   prefix
     telnetpostfixhop
     localhostpostfix
     prefix
     telnetpostfixhop
     melancholia.danann.netpostfix   prefix
     telnetpostfixhop
     melancholiapostfix

Choose a host from the above list and then continue to complete file names on that host.

When the configuration (see Customizing Completion) includes user names, then the completion lists will account for the user names as well.

Remote hosts previously visited or hosts whose connections are kept persistently (see Connection caching) will be included in the completion lists.

After remote host name completion comes completion of file names on the remote host.  It works the same as on loal host file completion except when killing with double-slash // kills only the file name part of the tramp file name syntax.  A triple-slash stands for the default behavior. See Minibuffer File (emacs).

Example:

     C-x C-f prefix
     telnetpostfixhop
     melancholiapostfix/usr/local/bin//etc TAB
          -| prefix
     telnetpostfixhop
     melancholiapostfix/etc

     C-x C-f prefix
     telnetpostfixhop
     melancholiapostfix//etc TAB
          -| /etc

     C-x C-f prefix
     telnetpostfixhop
     melancholiapostfix/usr/local/bin///etc TAB
          -| /etc

During file name completion, remote directory contents are re-read regularly to account for any changes in the filesystem that may affect the completion candidates.  Such re-reads can account for changes to the file system by applications outside Emacs (see Connection caching).

 -- User Option: tramp-completion-reread-directory-timeout
     The timeout is number of seconds since last remote command for rereading remote directory contents.  0 re-reads immediately during file name completion, nil uses cached directory contents.

Declaring multiple hops in the file name
========================================

tramp file name syntax can accommodate ad hoc specification of multiple proxies without using tramp-default-proxies-alist configuration setup(see Multi-hops).

Each proxy is specified using the same syntax as the remote host specification minus the file name part.  Each hop is separated by a |.  Chain the proxies from the starting host to the destination remote host name and file name.  For example, hopping over a single proxy bird@bastion to a remote file on you@remotehost:

     C-x C-f prefixsshpostfixhopbird@bastion|sshpostfixhopyou@remotehostpostfix/path

Proxies can take patterns %h or %u.

tramp adds the ad-hoc definitions on the fly to tramp-default-proxies-alist and is available for re-use during that Emacs session.  Subsequent tramp connections to the same remote host can then use the shortcut form: prefix
sshpostfixhop
you@remotehostpostfix/path.

 -- User Option: tramp-save-ad-hoc-proxies
     For ad-hoc definitions to be saved automatically in tramp-default-proxies-alist for future Emacs sessions, set tramp-save-ad-hoc-proxies.

          (setq tramp-save-ad-hoc-proxies t)

Integration with other Emacs packages
=====================================

tramp supports starting new running processes on the remote host for discovering remote file names.  Emacs packages on the remote host need no specific modifications for tramp's use.

This type of integration does not work with the ftp method, and does not support the pty association as specified in start-file-process.

process-file and start-file-process work on the remote host when the variable default-directory is remote:

     (let ((default-directory "/ssh:remote.host:"))
       (start-file-process "grep" (get-buffer-create "*grep*")
                           "/bin/sh" "-c" "grep -e tramp *"))

tramp starts a remote process when a command is executed in a remote file or directory buffer.  As of now, these packages have been integrated to work with tramp: compile.el (commands like compile and grep) and gud.el (gdb or perldb).

For tramp to find the command on the remote, it must be accessible through the default search path as setup by tramp upon first connection.  Alternatively, use an absolute path or extend tramp-remote-path (see Remote programs):

     (add-to-list 'tramp-remote-path "~/bin")
     (add-to-list 'tramp-remote-path "/appli/pub/bin")

Customize tramp-remote-process-environment to suit the remote program's environment for the remote host. tramp-remote-process-environment is a list of strings structured similar to process-environment, where each element is a string of the form ENVVARNAME=VALUE.

To avoid any conflicts with local host variables set through local configuration files, such as ~/.profile, use ENVVARNAME= to unset them for the remote environment.

Use add-to-list to add entries:

     (add-to-list 'tramp-remote-process-environment "JAVA_HOME=/opt/java")

Modifying or deleting already existing values in the tramp-remote-process-environment list may not be feasible on restricted remote hosts.  For example, some system administrators disallow changing HISTORY variable.  To accommodate such restrictions when using tramp, fix the tramp-remote-process-environment by the following code in the local .emacs file:

     (let ((process-environment tramp-remote-process-environment))
       (setenv "HISTORY" nil)
       (setq tramp-remote-process-environment process-environment))

tramp does not use the defaults specified in process-environment for running process-file or start-file-process on remote hosts.  When values from process-environment are needed for remote processes, then set them as follows:

     (let ((process-environment (cons "HGPLAIN=1" process-environment)))
       (process-file ...))

This works only for environment variables not already set in the process-environment.

For integrating other Emacs packages so tramp can execute remotely, please file a bug report.  See Bug Reports.

Running remote programs that create local X11 windows
-----------------------------------------------------

To allow a remote program to create an X11 window on the local host, set the DISPLAY environment variable for the remote host as follows in the local .emacs file:

     (add-to-list 'tramp-remote-process-environment
                  (format "DISPLAY=%s" (getenv "DISPLAY")))

(getenv "DISPLAY") should return a recognizable name for the local host that the remote host can redirect X11 window interactions.  If querying for a recognizable name is not possible for whatever reason, then replace (getenv "DISPLAY") with a hard-coded, fixed name.  Note that using :0 for X11 display name here will not work as expected.

An alternate approach is specify ForwardX11 yes or ForwardX11Trusted yes in the file ~/.ssh/config on the local host.

Running shell on a remote host
------------------------------

Set explicit-shell-file-name to the appropriate shell name when using tramp between two hosts with different operating systems, such as windows-nt and gnu/linux.  This option ensures the correct name of the remote shell program.

Starting with Emacs 24, when explicit-shell-file-name is equal to nil, calling shell interactively will prompt for a shell name.

Running shell-command on a remote host
--------------------------------------

shell-command executes commands synchronously or asynchronously on remote hosts and displays output in buffers on the local host.  Example:

     C-x C-f prefix
     sudopostfixhop
     postfix RET
     M-! tail -f /var/log/syslog.log & RET

tail command outputs continuously to the local buffer, *Async Shell Command*

M-x auto-revert-tail-mode runs similarly showing continuous output.

Running eshell on a remote host
-------------------------------

tramp is integrated into eshell.el, which enables interactive eshell sessions on remote hosts at the command prompt. You must add the module eshell-tramp to eshell-modules-list.  Here's a sample interaction after opening M-x eshell on a remote host:

     ~ $ cd prefix
     sudopostfixhop
     postfix/etc RET
     prefix
     sudopostfixhop
     root@hostpostfix/etc $ hostname RET
     host
     prefix
     sudopostfixhop
     root@hostpostfix/etc $ id RET
     uid=0(root) gid=0(root) groups=0(root)
     prefix
     sudopostfixhop
     root@hostpostfix/etc $ find-file shadow RET
     #<buffer shadow>
     prefix
     sudopostfixhop
     root@hostpostfix/etc $

eshell in Emacs 23.2 added custom su and sudo commands that set the default directory correctly for the *eshell* buffer.  tramp silently updates tramp-default-proxies-alist with an entry for this directory (see Multi-hops):

     ~ $ cd prefix
     sshpostfixhop
     user@remotehostpostfix/etc RET
     prefix
     sshpostfixhop
     user@remotehostpostfix/etc $ find-file shadow RET
     File is not readable: prefix
     sshpostfixhop
     user@remotehostpostfix/etc/shadow
     prefix
     sshpostfixhop
     user@remotehostpostfix/etc $ sudo find-file shadow RET
     #<buffer shadow>

     prefix
     sshpostfixhop
     user@remotehostpostfix/etc $ su - RET
     prefix
     supostfixhop
     root@remotehostpostfix/root $ id RET
     uid=0(root) gid=0(root) groups=0(root)
     prefix
     supostfixhop
     root@remotehostpostfix/root $

Running a debugger on a remote host
-----------------------------------

gud.el provides a unified interface to symbolic debuggers (Debuggers (emacs)). tramp can run debug on remote hosts by calling gdb with a remote file name:

     M-x gdb RET
     Run gdb (like this): gdb --annotate=3 prefix
     sshpostfixhop
     hostpostfix~/myprog RET

Relative file names are based on the remote default directory.  When myprog.pl exists in prefix
sshpostfixhop
hostpostfix/home/user, valid calls include:

     M-x perldb RET
     Run perldb (like this): perl -d myprog.pl RET

Just the local part of a remote file name, such as perl -d /home/user/myprog.pl, is not possible.

Arguments of the program to be debugged must be literal, can take relative or absolute paths, but not remote paths.

Running remote processes on Windows hosts
-----------------------------------------

winexe runs processes on a remote Windows host, and tramp can use it for process-file and start-file-process.

tramp-smb-winexe-program specifies the local winexe command.  Powershell V2.0 on the remote host is required to run processes triggered from tramp.

explicit-shell-file-name and explicit-*-args have to be set properly so M-x shell can open a proper remote shell on a Windows host.  To open cmd, set it as follows:

     (setq explicit-shell-file-name "cmd"
           explicit-cmd-args '("/q"))

To open powershell as a remote shell, use this:

     (setq explicit-shell-file-name "powershell"
           explicit-powershell-args '("-file" "-"))

Cleanup remote connections
==========================

tramp provides several ways to flush remote connections.

 -- Command: tramp-cleanup-connection vec
     This command flushes all connection related objects.  vec is the internal representation of a remote connection.  When called interactively, this command lists active remote connections in the minibuffer.  Each connection is of the format prefix
     methodpostfixhop
     user@hostpostfix.  Flushing remote connections also cleans the password cache (see Password handling), file cache, connection cache (see Connection caching), and connection buffers.

 -- Command: tramp-cleanup-this-connection
     Flushes only the current buffer's remote connection objects, the same as in tramp-cleanup-connection.

 -- Command: tramp-cleanup-all-connections
     Flushes all active remote connection objects, the same as in tramp-cleanup-connection.

 -- Command: tramp-cleanup-all-buffers
     Just as for tramp-cleanup-all-connections, all remote connections are cleaned up in addition to killing buffers related to that remote connection.

Reporting Bugs and Problems
***************************

tramp's development team is actively engaged in solving bugs and problems and looks to feature requests and suggestions.

tramp's mailing list is the place for more advice and information on working with tramp, solving problems, discussing, and general discussions about tramp.

tramp's mailing list is moderated but even non-subscribers can post for moderator approval.  Sometimes this approval step may take as long as 48 hours due to public holidays.

tramp-devel@gnu.org is the mailing list.  Messages sent to this address go to all the subscribers.  This is not the address to send subscription requests to.

To subscribe to the mailing list, visit: the tramp Mail Subscription Page (http://lists.gnu.org/mailman/listinfo/tramp-devel/).

Check if the bug or problem is already addressed in see Frequently Asked Questions.

Run M-x tramp-bug to generate a buffer with details of the system along with the details of the tramp installation.  Please include these details with the bug report.

The bug report must describe in as excruciating detail as possible the steps required to reproduce the problem.  These details must include the setup of the remote host and any special or unique conditions that exist.

Include a minimal test case that reproduces the problem.  This will help the development team find the best solution and avoid unrelated detours.

To exclude cache-related problems, flush all caches before running the test, Cleanup remote connections.

When including tramp's messages in the bug report, increase the verbosity level to 6 (see Traces) in the ~/.emacs file before repeating steps to the bug.  Include the contents of the *tramp/foo* and *debug tramp/foo* buffers with the bug report.

Note that a verbosity level greater than 6 is not necessary at this stage.  Also note that a verbosity level of 6 or greater, the contents of files and directories will be included in the debug buffer.  Passwords typed in tramp will never be included there.

Frequently Asked Questions
**************************

  * Where is the latest tramp?

     tramp is available at the GNU URL:

     ftp://ftp.gnu.org/gnu/tramp/

     tramp's GNU project page is located here:

     http://savannah.gnu.org/projects/tramp/

  * Which systems does it work on?

     The package works successfully on Emacs 23, Emacs 24, and Emacs 25.

     While Unix and Unix-like systems are the primary remote targets, tramp has equal success connecting to other platforms, such as MS Windows XP/Vista/7.

  * How to speed up tramp?

     tramp does many things in the background, some of which depends on network speeds, response speeds of remote hosts, and authentication delays.  During these operations, tramp's responsiveness slows down.  Some suggestions within the scope of tramp's settings include:

     Use an external method, such as scp, which are faster than internal methods.

     Keep the file tramp-persistency-file-name, which is where tramp caches remote information about hosts and files.  Caching is enabled by default.  Don't disable it.

     Set remote-file-name-inhibit-cache to nil if remote files are not independently updated outside tramp's control. That cache cleanup will be necessary if the remote directories or files are updated independent of tramp.

     Set tramp-completion-reread-directory-timeout to nil to speed up completions, File name completion.

     Disable version control to avoid delays:

          (setq vc-ignore-dir-regexp
                (format "\\(%s\\)\\|\\(%s\\)"
                        vc-ignore-dir-regexp
                        tramp-file-name-regexp))

     Disable excessive traces.  Set tramp-verbose to 3 or lower, default being 3.  Increase trace levels temporarily when hunting for bugs.

  * tramp does not connect to the remote host

     Three main reasons for why tramp does not connect to the remote host:

       - Unknown characters in the prompt

          tramp needs a clean recognizable prompt on the remote host for accurate parsing.  Shell prompts that contain escape sequences for coloring cause parsing problems.  Remote shell setup for customizing prompt detection using regular expressions.

          To check if the remote host's prompt is being recognized, use this test: switch to tramp connection buffer *tramp/foo*, put the cursor at the top of the buffer, and then apply the following expression:

               M-: (re-search-forward (concat tramp-shell-prompt-pattern "$"))

          If the cursor has not moved to the prompt at the bottom of the buffer, then tramp has failed to recognize the prompt.

          When using zsh on remote hosts, disable zsh line editor because zsh uses left-hand side and right-hand side prompts in parallel.  Add the following line to ~/.zshrc:

               [ $TERM = "dumb" ] && unsetopt zle && PS1='$ '

          When using fish shell on remote hosts, disable fancy formatting by adding the following to ~/.config/fish/config.fish:

               function fish_prompt
                 if test $TERM = "dumb"
                    echo "\$ "
                 else
                    ...
                 end
               end

          When using WinSSHD on remote hosts, tramp do not recognize the strange prompt settings.

       - Echoed characters after login

          tramp suppresses echos from remote hosts with the stty -echo command.  But sometimes it is too late to suppress welcome messages from the remote host containing harmful control characters.  Using sshx or scpx methods can avoid this problem because they allocate a pseudo tty.  See Inline methods.

       - tramp stops transferring strings longer than 500 characters

          Set tramp-chunksize to 500 to get around this problem, which is related to faulty implementation of process-send-string on HP-UX, FreeBSD and Tru64 Unix systems.  Consult the documentation for tramp-chunksize to see when this is necessary.

          Set file-precious-flag to t for files accessed by tramp so the file contents are checked using checksum by first saving to a temporary file. see Saving Buffers (elisp)

               (add-hook
                'find-file-hook
                (lambda ()
                  (when (file-remote-p default-directory)
                    (set (make-local-variable 'file-precious-flag) t))))

  * tramp does not recognize if a ssh session hangs

     ssh sessions on the local host hang when the network is down.  tramp cannot safely detect such hangs.  The network configuration for ssh can be configured to kill such hangs with the following command in the ~/.ssh/config:

          Host *
               ServerAliveInterval 5

  * tramp does not use default ssh ControlPath

     tramp overwrites ControlPath settings when initiating ssh sessions.  tramp does this to fend off a stall if a master session opened outside the Emacs session is no longer open.  That is why tramp prompts for the password again even if there is an ssh already open.

     Some ssh versions support a ControlPersist option, which allows to set the ControlPath provided the variable tramp-ssh-controlmaster-options is customized as follows:

          (setq tramp-ssh-controlmaster-options
                (concat
                  "-o ControlPath=/tmp/ssh-ControlPath-%%r@%%h:%%p "
                  "-o ControlMaster=auto -o ControlPersist=yes"))

     Note how "%r", "%h" and "%p" must be encoded as "%%r", "%%h" and "%%p".

     If the ~/.ssh/config is configured appropriately for the above behavior, then any changes to ssh can be suppressed with this nil setting:

          (setq tramp-use-ssh-controlmaster-options nil)

  * File name completion does not work with tramp

     ANSI escape sequences from the remote shell may cause errors in tramp's parsing of remote buffers.

     To test if this is the case, open a remote shell and check if the output of ls is in color.

     To disable ANSI escape sequences from the remote hosts, disable --color=yes or --color=auto in the remote host's .bashrc or .profile.  Turn this alias on and off to see if file name completion works.

  * File name completion does not work in directories with large number of files

     This may be related to globbing, which is the use of shell's ability to expand wild card specifications, such as *.c.  For directories with large number of files, globbing might exceed the shell's limit on length of command lines and hang.  tramp uses globbing.

     To test if globbing hangs, open a shell on the remote host and then run ls -d * ..?* > /dev/null.

     When testing, ensure the remote shell is the same shell (/bin/sh, ksh or bash), that tramp uses when connecting to that host.

  * How to get notified after tramp completes file transfers?

     Make Emacs beep after reading from or writing to the remote host with the following code in ~/.emacs file.

          (defadvice tramp-handle-write-region
            (after tramp-write-beep-advice activate)
            "Make tramp beep after writing a file."
            (interactive)
            (beep))

          (defadvice tramp-handle-do-copy-or-rename-file
            (after tramp-copy-beep-advice activate)
            "Make tramp beep after copying a file."
            (interactive)
            (beep))

          (defadvice tramp-handle-insert-file-contents
            (after tramp-insert-beep-advice activate)
            "Make tramp beep after inserting a file."
            (interactive)
            (beep))

  * How to get a Visual Warning when working with root privileges

     Get a modeline indication when working with root privileges with the following code (tested with Emacs 22.1) in ~/.emacs file:

          (defun my-mode-line-function ()
            (when (string-match "^/su\\(do\\)?:" default-directory)
              (setq mode-line-format
                    (format-mode-line mode-line-format 'font-lock-warning-face))))

          (add-hook 'find-file-hook 'my-mode-line-function)
          (add-hook 'dired-mode-hook 'my-mode-line-function)

  * How to get host indication in the mode line?

     The following code (tested with Emacs 22.1) in ~/.emacs file shows it:

          (defconst my-mode-line-buffer-identification
            (list
             '(:eval
               (let ((host-name
                      (if (file-remote-p default-directory)
                          (tramp-file-name-host
                           (tramp-dissect-file-name default-directory))
                        (system-name))))
                 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
                     (substring host-name 0 (match-beginning 1))
                   host-name)))
             ": %12b"))

          (setq-default
           mode-line-buffer-identification
           my-mode-line-buffer-identification)

          (add-hook
           'dired-mode-hook
           (lambda ()
             (setq
              mode-line-buffer-identification
              my-mode-line-buffer-identification)))

     The mode line in Emacs 23.1 and later versions now contains an indication if default-directory for the current buffer is on a remote host.  Moreover, the corresponding tool-tip shows the remote host name.  The above :eval clause can also be simplified to show the host name in the mode line:

             '(:eval
               (let ((host-name
                      (or (file-remote-p default-directory 'host)
                          (system-name))))
                 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
                     (substring host-name 0 (match-beginning 1))
                   host-name)))

  * Remote host does not understand default options for directory listing

     Emacs computes the dired options based on the local host but if the remote host cannot understand the same ls command, then set them with a hook as follows:

          (add-hook
           'dired-before-readin-hook
           (lambda ()
             (when (file-remote-p default-directory)
               (setq dired-actual-switches "-al"))))

  * Why is ~/.sh_history file on the remote host growing?

     Due to ksh saving tilde expansions triggered by tramp, the history file is probably growing rapidly.  To fix, turn off saving history by putting this shell code in the .kshrc file:

          if [ -f $HOME/.sh_history ] ; then
             /bin/rm $HOME/.sh_history
          fi
          if [ "${HISTFILE-unset}" != "unset" ] ; then
             unset HISTFILE
          fi
          if [ "${HISTSIZE-unset}" != "unset" ] ; then
             unset HISTSIZE
          fi

     For ssh-based method, add the following line to your ~/.ssh/environment file:

          HISTFILE=/dev/null

  * How to shorten long file names when typing in tramp?

     Adapt several of these approaches to reduce typing.  If the full name is prefix
     sshpostfixhop
     news@news.my.domainpostfix/opt/news/etc, then:

      1. Use default values for method name and user name:

          You can define default methods and user names for hosts, (see Default Method, see Default User):

               (setq tramp-default-method "ssh"
                     tramp-default-user "news")

          The reduced typing: C-x C-f prefix
          news.my.domainpostfix/opt/news/etc.

          Note that there are some useful shortcuts already.  Accessing your local host as root user, is possible just by C-x C-f
          prefix
          supostfixhop
          postfix.

      2. Use configuration options of the access method:

          Programs used for access methods already offer powerful configurations (see Customizing Completion).  For ssh, configure the file ~/.ssh/config:

               Host xy
                    HostName news.my.domain
                    User news

          The reduced typing: C-x C-f prefix
          sshpostfixhop
          xypostfix/opt/news/etc.

          Depending on the number of files in the directories, host names completion can further reduce key strokes: C-x C-f
          prefixsshpostfixhopx TAB.

      3. Use environment variables to expand long strings

          For long file names, set up environment variables that are expanded in the minibuffer.  Environment variables are set either outside Emacs or inside Emacs with Lisp:

               (setenv "xy" "prefix
               sshpostfixhop
               news@news.my.domainpostfix/opt/news/etc/")

          The reduced typing: C-x C-f $xy RET.

          Note that file name cannot be edited here because the environment variables are not expanded during editing in the minibuffer.

      4. Define own keys:

          Redefine another key sequence in Emacs for C-x C-f:

               (global-set-key
                [(control x) (control y)]
                (lambda ()
                  (interactive)
                  (find-file
                   (read-file-name
                    "Find Tramp file: "
                    "prefix
               sshpostfixhop
               news@news.my.domainpostfix/opt/news/etc/"))))

          Simply typing C-x C-y would prepare minibuffer editing of file name.

          See the Emacs Wiki (http://www.emacswiki.org/cgi-bin/wiki/TrampMode) for a more comprehensive example.

      5. Define own abbreviation (1):

          Abbreviation list expansion can be used to reduce typing long file names:

               (add-to-list
                'directory-abbrev-alist
                '("^/xy" . "prefix
               sshpostfixhop
               news@news.my.domainpostfix/opt/news/etc/"))

          The reduced typing: C-x C-f /xy RET.

          Note that file name cannot be edited here because the environment variables are not expanded during editing in the minibuffer.

      6. Define own abbreviation (2):

          The abbrev-mode gives additional flexibility for editing in the minibuffer:

               (define-abbrev-table 'my-tramp-abbrev-table
                 '(("xy" "prefix
               sshpostfixhop
               news@news.my.domainpostfix/opt/news/etc/")))

               (add-hook
                'minibuffer-setup-hook
                (lambda ()
                  (abbrev-mode 1)
                  (setq local-abbrev-table my-tramp-abbrev-table)))

               (defadvice minibuffer-complete
                 (before my-minibuffer-complete activate)
                 (expand-abbrev))

               ;; If you use partial-completion-mode
               (defadvice PC-do-completion
                 (before my-PC-do-completion activate)
                 (expand-abbrev))

          The reduced typing: C-x C-f xy TAB.

          The minibuffer expands for further editing.

      7. Use bookmarks:

          Use bookmarks to save Tramp file names. see Bookmarks (emacs).

          Upon visiting a location with tramp, save it as a bookmark with menu-bar edit bookmarks set.

          To revisit that bookmark: menu-bar edit bookmarks jump.

      8. Use recent files:

          recentf remembers visited places. see File Conveniences (emacs).

          Keep remote file names in the recent list without have to check for their accessibility through remote access:

               (recentf-mode 1)

          Reaching recently opened files: menu-bar file Open Recent.

      9. Use filecache:

          Since filecache remembers visited places, add the remote directory to the cache:

               (eval-after-load "filecache"
                 '(file-cache-add-directory
                   "prefix
               sshpostfixhop
               news@news.my.domainpostfix/opt/news/etc/"))

          Then use directory completion in the minibuffer with C-x C-f C-TAB.

      10. Use bbdb:

          bbdb has a built-in feature for Ange FTP files, which also works for tramp file names. see Storing FTP sites in the BBDB (bbdb).

          Load bbdb in Emacs:

               (require 'bbdb)
               (bbdb-initialize)

          Create a BBDB entry with M-x bbdb-create-ftp-site.  Then specify a method and user name where needed.  Examples:

               M-x bbdb-create-ftp-site RET
               Ftp Site: news.my.domain RET
               Ftp Directory: /opt/news/etc/ RET
               Ftp Username: sshpostfixhopnews RET
               Company: RET
               Additional Comments: RET

          In BBDB buffer, access an entry by pressing the key F.

     Thanks to tramp users for contributing to these recipes.

  * Why saved multi-hop file names do not work in a new Emacs session?

     When saving ad-hoc multi-hop tramp file names (see Ad-hoc multi-hops) via bookmarks, recent files, filecache, bbdb, or another package, use the full ad-hoc file name including all hops, like prefix
     sshpostfixhop
     bird@bastion|sshpostfixhopnews.my.domainpostfix/opt/news/etc.

     Alternatively, when saving abbreviated multi-hop file names prefix
     sshpostfixhop
     news@news.my.domainpostfix/opt/news/etc, the custom option tramp-save-ad-hoc-proxies must be set non-nil value.

  * How to connect to a remote Emacs session using tramp?

     Configure Emacs Client (see Emacs Server (emacs)).

     Then on the remote host, start the Emacs Server:

          (require 'server)
          (setq server-host (system-name)
                server-use-tcp t)
          (server-start)

     If (system-name) of the remote host cannot be resolved on the local host, use IP address instead.

     Copy from the remote host the resulting file ~/.emacs.d/server/server to the local host, to the same location.

     Then start Emacs Client from the command line:

          emacsclient prefix
          sshpostfixhop
          user@hostpostfix/file/to/edit

     user and host refer to the local host.

     To make Emacs Client an editor for other programs, use a wrapper script emacsclient.sh:

          #!/bin/sh
          emacsclient prefix
          sshpostfixhop
          $(whoami)@$(hostname --fqdn)postfix$1

     Then change the environment variable EDITOR to point to the wrapper script:

          export EDITOR=/path/to/emacsclient.sh

  * How to disable other packages from calling tramp?

     There are packages that call tramp without the user ever entering a remote file name.  Even without applying a remote file syntax, some packages enable tramp on their own.  How can users disable such features.

       - ido.el

          Disable tramp file name completion:

               (custom-set-variables
                '(ido-enable-tramp-completion nil))

       - rlogin.el

          Disable remote directory tracking mode:

               (rlogin-directory-tracking-mode -1)

  * How to disable tramp?

       - To keep Ange FTP as default the remote files access package, set this in .emacs:

               (setq tramp-default-method "ftp")

       - To disable both tramp (and Ange FTP), set tramp-mode to nil in .emacs.

               (setq tramp-mode nil)

       - To unload tramp, type M-x tramp-unload-tramp.  Unloading tramp resets Ange FTP plugins also.

How file names, directories and localnames are mangled and managed.
*******************************************************************

Splitting a localname into its component parts
==============================================

tramp package redefines lisp functions file-name-directory and file-name-nondirectory to accommodate the unique file naming syntax that tramp requires.

The replacements dissect the file name, use the original handler for the localname, take that result, and then re-build the tramp file name.  By relying on the original handlers for localnames, tramp benefits from platform specific hacks to the original handlers.

Integrating with external Lisp packages
=======================================

File name completion.
---------------------

For name completions in the minibuffer, tramp depends on the last input character to decide whether to look for method name completion or host name completion.  For example, C-x C-f
prefixsshpostfixhop TAB is not entirely clear if ssh is a method or a host name.  But if the last input character was either TAB, SPACE or ?, then tramp favors file name completion over host name completion.

What about external packages using other characters to trigger file name completions? They must somehow signal this to tramp.  Use the variable non-essential temporarily and bind it to non-nil value.

     (let ((non-essential t))
       ...)

File attributes cache.
----------------------

Keeping a local cache of remote file attributes in sync with the remote host is a time-consuming operation.  Flushing and re-querying these attributes can tax tramp to a grinding halt on busy remote servers.

To get around these types of slow-downs in tramp's responsiveness, set the process-file-side-effects to nil to stop tramp from flushing the cache.  This is helpful in situations where callers to process-file know there are no file attribute changes.  The let-bind form to accomplish this:

     (let (process-file-side-effects)
       ...)

For asynchronous processes, tramp uses a process sentinel to flush file attributes cache.  When callers to start-file-process know beforehand no file attribute changes are expected, then the process sentinel should be set to the default state.  In cases where the caller defines its own process sentinel, tramp's process sentinel is overwritten.  The caller can still flush the file attributes cache in its process sentinel with this code:

     (unless (memq (process-status proc) '(run open))
       (dired-uncache remote-directory))

Since tramp traverses subdirectories starting with the root-directory, it is most likely sufficient to make the default-directory of the process buffer as the root directory.

How to Customize Traces
***********************

tramp messages are raised with verbosity levels ranging from 0 to 10.  tramp does not display all messages; only those with a verbosity level less than or equal to tramp-verbose.

The verbosity levels are

 0  silent (no tramp messages at all)

 1  errors

 2  warnings

 3  connection to remote hosts (default verbosity)

 4  activities

 5  internal

 6  sent and received strings

 7  file caching

 8  connection properties

 9  test commands

10  traces (huge)

With tramp-verbose greater than or equal to 4, messages are also written to a tramp debug buffer.  Such debug buffers are essential to bug and problem analyses.  For tramp bug reports, set the tramp-verbose level to 6 (see Bug Reports).

The debug buffer is in Outline Mode (emacs). In this buffer, messages can be filtered by their level.  To see messages up to verbosity level 5, enter C-u 6 C-c C-q. Other navigation keys are described in Outline Visibility (emacs).

tramp handles errors internally.  But to get a Lisp backtrace, both the error and the signal have to be set as follows:

     (setq debug-on-error t
           debug-on-signal t)

To enable stepping through tramp function call traces, they have to be specifically enabled as shown in this code:

     (require 'trace)
     (dolist (elt (all-completions "tramp-" obarray 'functionp))
       (trace-function-background (intern elt)))
     (untrace-function 'tramp-read-passwd)
     (untrace-function 'tramp-gw-basic-authentication)

The buffer *trace-output* contains the output from the function call traces.  Disable tramp-read-passwd and tramp-gw-basic-authentication to stop password strings from being written to *trace-output*.

GNU Free Documentation License
******************************

     [file doclicense.texi not included]