     [file trampver.texi not included]

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

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

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

The difference is that ftppackagename 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-2011 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.  Buying copies from the FSF supports it in developing GNU and promoting software freedom.''

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

After the installation of tramp into your emacsname, you will be able to access files on remote machines as though they were local.  Access to the remote file system for editing files, version control, and dired are transparently enabled.

Your access to the remote machine can be with the rsh, rlogin, telnet programs or with any similar connection method.  This connection must pass ASCII successfully to be usable but need not be 8-bit clean.

The package provides support for ssh connections out of the box, one of the more common uses of the package.  This allows relatively secure access to machines, especially if ftp access is disabled.

Under Windows, tramp is integrated with the PuTTY package, using the plink program.

The majority of activity carried out by tramp requires only that the remote login is possible and is carried out at the terminal.  In order to access remote files tramp needs to transfer their content to the local machine temporarily.

tramp can transfer files between the machines in a variety of ways. The details are easy to select, depending on your needs and the machines in question.

The fastest transfer methods for large files rely on a remote file transfer package such as rcp, scp, rsync or (under Windows) pscp.

If the remote copy methods are not suitable for you, tramp also supports the use of encoded transfers directly through the shell. This requires that the mimencode or uuencode tools are available on the remote machine.  These methods are generally faster for small files.

tramp is still under active development and any problems you encounter, trivial or major, should be reported to the tramp developers. See Bug Reports.

Behind the scenes
.................

This section tries to explain what goes on behind the scenes when you access a remote file through tramp.

Suppose you type C-x C-f and enter part of an tramp file name, then hit TAB for completion.  Suppose further that this is the first time that tramp is invoked for the host in question.  Here's what happens:

  * tramp discovers that it needs a connection to the host.  So it invokes telnet HOST or rsh HOST -l USER or a similar tool to connect to the remote host. Communication with this process happens through an emacsname buffer, that is, the output from the remote end goes into a buffer.

  * The remote host may prompt for a login name (for telnet). The login name is given in the file name, so tramp sends the login name and a newline.

  * The remote host may prompt for a password or pass phrase (for rsh or for telnet after sending the login name). tramp displays the prompt in the minibuffer, asking you for the password or pass phrase.

     You enter the password or pass phrase.  tramp sends it to the remote host, followed by a newline.

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

     If tramp sees neither of them after a certain period of time (a minute, say), then it issues an error message saying that it couldn't find the remote shell prompt and shows you what the remote host has sent.

     If tramp sees a login failed message, it tells you so, aborts the login attempt and allows you to try again.

  * Suppose that the login was successful and tramp sees the shell prompt from the remote host.  Now tramp invokes /bin/sh because Bourne shells and C shells have different command syntaxes. (Invoking /bin/sh will fail if your login shell doesn't recognize exec /bin/sh as a valid command. Maybe you use the Scheme shell scsh...)

     After the Bourne shell has come up, tramp sends a few commands to ensure a good working environment.  It turns off echoing, it sets the shell prompt, and a few other things.

  * Now the remote shell is up and it good working order.  Remember, what was supposed to happen is that tramp tries to find out what files exist on the remote host so that it can do filename completion.

     So, tramp basically issues cd and ls commands and also sometimes echo with globbing.  Another command that is often used is test to find out whether a file is writable or a directory or the like.  The output of each command is parsed for the necessary operation.

  * Suppose you are finished with filename completion, have entered C-x C-f, a full file name and hit RET.  Now comes the time to transfer the file contents from the remote host to the local host so that you can edit them.

     See above for an explanation of how tramp transfers the file contents.

     For inline transfers, tramp issues a command like mimencode -b
     /path/to/remote/file, waits until the output has accumulated in the buffer that's used for communication, then decodes that output to produce the file contents.

     For external transfers, tramp issues a command like the following:

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

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

  * You now edit the buffer contents, blithely unaware of what has happened behind the scenes.  (Unless you have read this section, that is.)  When you are finished, you type C-x C-s to save the buffer.

  * Again, tramp transfers the file contents to the remote host either inline or external.  This is the reverse of what happens when reading the file.

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 freely available on the Internet and the latest release may be downloaded from ftp://ftp.gnu.org/gnu/tramp/. This release includes the full documentation and code for tramp, suitable for installation.  But Emacs (22 or later) includes tramp already, and there is a tramp package for XEmacs, as well.  So maybe it is easier to just use those.  But if you want the bleeding edge, read on......

For the especially brave, tramp is available from CVS.  The CVS version is the latest version of the code and may contain incomplete features or new issues.  Use these versions at your own risk.

Instructions for obtaining the latest development version of tramp from CVS can be found by going to the Savannah project page at the following URL and then clicking on the CVS link in the navigation bar at the top.

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

Or follow the example session below:

     ] cd ~/emacsdir
     ] export CVS_RSH="ssh"
     ] cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/tramp co tramp

You should now have a directory ~/emacsdir/tramp containing the latest version of tramp.  You can fetch the latest updates from the repository by issuing the command:

     ] cd ~/emacsdir/tramp
     ] export CVS_RSH="ssh"
     ] cvs update -d

Once you've got updated files from the CVS repository, you need to run autoconf in order to get an up-to-date configure script:

     ] cd ~/emacsdir/tramp
     ] autoconf

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

Development was started end of November 1998.  The package was called rssh.el, back then.  It only provided one method to access a file, using ssh to log in to a remote host and using scp to transfer the file contents.  After a while, the name was changed to rcp.el, and now it's tramp.  Along the way, many more methods for getting a remote shell and for transferring the file contents were added.  Support for VC was added.

After that, there were added the multi-hop methods in April 2000 and the unification of tramp and Ange-FTP filenames in July 2002. In July 2004, multi-hop methods have been replaced by proxy hosts. Running commands on remote hosts was introduced in December 2005.

In December 2001, tramp has been added to the XEmacs package repository.  Being part of the Emacs repository happened in June 2002, the first release including tramp was Emacs 22.1.

tramp is also a Debian GNU/Linux package since February 2001.

Configuring tramp for use
*************************

tramp is (normally) fully functional when it is initially installed.  It is initially configured to use the scp program to connect to the remote host.  So in the easiest case, you just type C-x C-f and then enter the filename prefix,postfixhopuser,@machinepostfix/path/to.file.

On some hosts, there are problems with opening a connection.  These are related to the behavior of the remote shell.  See Remote shell setup, for details on this.

If you do not wish to use these commands to connect to the remote host, you should change the default connection and transfer method that tramp uses.  There are several different methods that tramp can use to connect to remote machines and transfer files (see Connection types).

If you don't know which method is right for you, see Default Method.

Types of connections made to remote machines.
=============================================

There are two basic types of transfer methods, each with its own advantages and limitations.  Both types of connection make use of a remote shell access program such as rsh, ssh or telnet to connect to the remote machine.

This connection is used to perform many of the operations that tramp requires to make the remote file system transparently accessible from the local machine.  It is only when visiting files that the methods differ.

Loading or saving a remote file requires that the content of the file be transfered between the two machines.  The content of the file can be transfered using one of two methods: the inline method over the same connection used to log in to the remote machine, or the external method through another connection using a remote copy program such as rcp, scp or rsync.

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 transfer 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, see method scpc.  If it isn't possible, you should consider Password handling, otherwise you will be prompted for a password every copy action.

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

The inline methods in tramp are quite powerful and can work in situations where you cannot use an external transfer program to connect. Inline methods are the only methods that work when connecting to the remote machine via telnet.  (There are also strange inline methods which allow you to transfer files between user identities rather than hosts, see below.)

These methods depend on the existence of a suitable encoding and decoding command on remote machine.  Locally, tramp may be able to use features of emacsname to decode and encode the files or it may require access to external commands to perform that task.

tramp checks the availability and usability of commands like mimencode (part of the metamail package) or uuencode on the remote host.  The first reliable command will be used.  The search path can be customized, see Remote Programs.

If both commands aren't available on the remote host, tramp transfers a small piece of Perl code to the remote host, and tries to apply it for encoding and decoding.

The variable TRAMP-INLINE-COMPRESS-START-SIZE controls, whether a file shall be compressed before encoding.  This could increase transfer speed for large text files.

rsh

     Connect to the remote host with rsh.  Due to the unsecure connection it is recommended for very local host topology only.

     On operating systems which provide the command remsh instead of rsh, you can use the method remsh.  This is true for HP-UX or Cray UNICOS, for example.

ssh

     Connect to the remote host with ssh.  This is identical to the previous option except that the ssh package is used, making the connection more secure.

     There are also two variants, ssh1 and ssh2, that call ssh -1 and ssh -2, respectively.  This way, you can explicitly select whether you want to use the SSH protocol version 1 or 2 to connect to the remote host.  (You can also specify in ~/.ssh/config, the SSH configuration file, which protocol should be used, and use the regular ssh method.)

     All the methods based on ssh have an additional feature: you can specify a host name which looks like host#42 (the real host name, then a hash sign, then a port number).  This means to connect to the given host but to also pass -p 42 as arguments to the ssh command.

telnet

     Connect to the remote host with telnet.  This is as unsecure as the rsh method.

su

     This method does not connect to a remote host at all, rather it uses the su program to allow you to edit files as another user. That means, the specified host name in the file name must be either localhost or the host name as returned by the function (system-name).  For an exception of this rule see Multi-hops.

sudo

     This is similar to the su method, but it uses sudo rather than su to become a different user.

     Note that sudo must be configured to allow you to start a shell as the user.  It would be nice if it was sufficient if ls and mimencode were allowed, but that is not easy to implement, so I haven't got around to it, yet.

sshx

     As you would expect, this is similar to ssh, only a little different.  Whereas ssh opens a normal interactive shell on the remote host, this option uses ssh -t -t HOST -l USER /bin/sh to open a connection.  This is useful for users where the normal login shell is set up to ask them a number of questions when logging in.  This procedure avoids these questions, and just gives tramp a more-or-less `standard' login shell to work with.

     Note that this procedure does not eliminate questions asked by ssh itself.  For example, ssh might ask ``Are you sure you want to continue connecting?'' if the host key of the remote host is not known.  tramp does not know how to deal with such a question (yet), therefore you will need to make sure that you can log in without such questions.

     This is also useful for Windows users where ssh, when invoked from an emacsname buffer, tells them that it is not allocating a pseudo tty.  When this happens, the login shell is wont to not print any shell prompt, which confuses tramp mightily.

     This supports the -p argument.

krlogin

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

ksu

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

plink

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

     This supports the -P argument.

     Additionally, the methods plink1 and plink2 are provided, which call plink -1 -ssh or plink -2 -ssh in order to use SSH protocol version 1 or 2 explicitly.

     CCC: Do we have to connect to the remote host once from the command line to accept the SSH key?  Maybe this can be made automatic?

     CCC: Say something about the first shell command failing.  This might be due to a wrong setting of tramp-rsh-end-of-line.

plinkx

     Another method using PuTTY on Windows.  Instead of host names, it expects PuTTY session names, calling plink -load SESSION -t".  User names are relevant only in case the corresponding session hasn't defined a user name.  Different port numbers must be defined in the session.

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

The external methods operate through multiple channels, using the remote shell connection for many actions while delegating file transfers to an external transfer utility.

This saves the overhead of encoding and decoding that multiplexing the transfer through the one connection has with the inline methods.

Since external methods need their own overhead opening a new channel, all files which are smaller than TRAMP-COPY-SIZE-LIMIT are still transferred with the corresponding inline method.  It should provide a fair trade-off between both approaches.

rcp  ---  rsh and rcp

     This method uses the rsh and rcp commands to connect to the remote machine and transfer files.  This is probably the fastest connection method available.

     The alternative method remcp uses the remsh and rcp commands.  It should be applied on machines where remsh is used instead of rsh.

scp  ---  ssh and scp

     Using ssh to connect to the remote host and scp to transfer files between the machines is the best method for securely connecting to a remote machine and accessing files.

     The performance of this option is also quite good.  It may be slower than the inline methods when you often open and close small files however. The cost of the cryptographic handshake at the start of an scp session can begin to absorb the advantage that the lack of encoding and decoding presents.

     There are also two variants, scp1 and scp2, that call ssh -1 and ssh -2, respectively.  This way, you can explicitly select whether you want to use the SSH protocol version 1 or 2 to connect to the remote host.  (You can also specify in ~/.ssh/config, the SSH configuration file, which protocol should be used, and use the regular scp method.)

     All the ssh based methods support the -p feature where you can specify a port number to connect to in the host name. For example, the host name host#42 tells tramp to specify -p 42 in the argument list for ssh, and to specify -P 42 in the argument list for scp.

sftp  ---  ssh and sftp

     That is mostly the same method as scp, but using sftp as transfer command.  So the same remarks are valid.

     This command does not work like ftppackagename, where ftp is called interactively, and all commands are send from within this session.  Instead of, ssh is used for login.

     This method supports the -p argument.

rsync  ---  ssh and rsync

     Using the ssh command to connect securely to the remote machine and the rsync command to transfer files is almost identical to the scp method.

     While rsync performs much better than scp when transferring files that exist on both hosts, this advantage is lost if the file exists only on one side of the connection.  A file can exists on both the remote and local host, when you copy a file from/to a remote host.  When you just open a file from the remote host (or write a file there), a temporary file on the local side is kept as long as the corresponding buffer, visiting this file, is alive.

     This method supports the -p argument.

scpx --- ssh and scp

     As you would expect, this is similar to scp, only a little different.  Whereas scp opens a normal interactive shell on the remote host, this option uses ssh -t -t HOST -l USER /bin/sh to open a connection.  This is useful for users where the normal login shell is set up to ask them a number of questions when logging in.  This procedure avoids these questions, and just gives tramp a more-or-less `standard' login shell to work with.

     This is also useful for Windows users where ssh, when invoked from an emacsname buffer, tells them that it is not allocating a pseudo tty.  When this happens, the login shell is wont to not print any shell prompt, which confuses tramp mightily.

     This method supports the -p argument.

scpc --- ssh and scp

     Newer versions of ssh (for example OpenSSH 4) offer an option ControlMaster.  This allows scp to reuse an existing ssh channel, which increases performance.

     Before you use this method, you shall check whether your ssh implementation does support this option.  Try from the command line

          ssh localhost -o ControlMaster=yes

     This method supports the -p argument.

rsyncc  ---  ssh and rsync

     Like the scpc method, rsyncc improves the underlying ssh connection by the option ControlMaster.  This allows rsync to reuse an existing ssh channel, which increases performance.

     This method supports the -p argument.

pscp --- plink and pscp

     This method is similar to scp, but it uses the plink command to connect to the remote host, and it uses pscp for transferring the files.  These programs are part of PuTTY, an SSH implementation for Windows.

     This method supports the -P argument.

psftp --- plink and psftp

     As you would expect, this method is similar to sftp, but it uses the plink command to connect to the remote host, and it uses psftp for transferring the files.  These programs are part of PuTTY, an SSH implementation for Windows.

     This method supports the -P argument.

fcp --- fsh and fcp

     This method is similar to scp, but it uses the fsh command to connect to the remote host, and it uses fcp for transferring the files.  fsh/fcp are a front-end for ssh which allow for reusing the same ssh session for submitting several commands.  This avoids the startup overhead of scp (which has to establish a secure connection whenever it is called).  Note, however, that you can also use one of the inline methods to achieve a similar effect.

     This method uses the command fsh HOST -l USER /bin/sh -i to establish the connection, it does not work to just say fsh HOST -l USER.

     There is no inline method using fsh as the multiplexing provided by the program is not very useful in our context.  tramp opens just one connection to the remote host and then keeps it open, anyway.

ftp

     This is not a native tramp method.  Instead, it forwards all requests to ftppackagename.

smb --- smbclient

     This is another not natural tramp method.  It uses the smbclient command on different Unices in order to connect to an SMB server.  An SMB server might be a Samba (or CIFS) server on another UNIX host or, more interesting, a host running MS Windows.  So far, it is tested against MS Windows NT, MS Windows 2000, and MS Windows XP.

     The first directory in the localname must be a share name on the remote host.  Remember that the $ character, in which default shares usually end, must be written $$ due to environment variable substitution in file names.  If no share name is given (i.e. remote directory /), all available shares are listed.

     Since authorization is done on share level, you will always be prompted for a password if you access another share on the same host. This can be suppressed by Password handling.

     For authorization, MS Windows uses both a user name and a domain name. Because of this, the tramp syntax has been extended: you can specify a user name which looks like user%domain (the real user name, then a percent sign, then the domain name).  So, to connect to the machine melancholia as user daniel of the domain BIZARRE, and edit .emacs in the home directory (share daniel$) I would specify the filename prefixsmb,postfixhopdaniel%BIZARRE,@melancholiapostfix/daniel$$/.emacs.

     Depending on the Windows domain configuration, a Windows user might be considered as domain user per default.  In order to connect as local user, the WINS name of that machine must be given as domain name. Usually, it is the machine name in capital letters.  In the example above, the local user daniel would be specified as prefixsmb,postfixhopdaniel%MELANCHOLIA,@melancholiapostfix/daniel$$/.emacs.

     The domain name as well as the user name are optional.  If no user name is specified at all, the anonymous user (without password prompting) is assumed.  This is different from all other tramp methods, where in such a case the local user name is taken.

     The smb method supports the -p argument.

     Please note: If emacsname runs locally under MS Windows, this method isn't available.  Instead, you can use UNC file names like //melancholia/daniel$$/.emacs.  The only disadvantage is that there's no possibility to specify another user name.

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

When you select an appropriate transfer method for your typical usage you should set the variable tramp-default-method to reflect that choice.  This variable controls which method will be used when a method is not specified in the tramp file name.  For example:

     (setq tramp-default-method "ssh")

You can also specify different methods for certain user/host combinations, via the 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 machine 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 more details.

External methods are normally preferable to inline methods, giving better performance.

See Inline methods. See External methods.

Another consideration with the selection of transfer methods is the environment you will use them in and, especially when used over the Internet, the security implications of your preferred method.

The rsh and telnet methods send your password as plain text as you log in to the remote machine, as well as transferring the files in such a way that the content can easily be read from other machines.

If you need to connect to remote systems that are accessible from the Internet, you should give serious thought to using ssh based methods to connect.  These provide a much higher level of security, making it a non-trivial exercise for someone to obtain your password or read the content of the files you are editing.

Which method is the right one for me?
-------------------------------------

Given all of the above, you are probably thinking that this is all fine and good, but it's not helping you to choose a method!  Right you are. As a developer, we don't want to boss our users around but give them maximum freedom instead.  However, the reality is that some users would like to have some guidance, so here I'll try to give you this guidance without bossing you around.  You tell me whether it works ...

My suggestion is to use an inline method.  For large files, external methods might be more efficient, but I guess that most people will want to edit mostly small files.  And if you access large text files, compression (driven by TRAMP-INLINE-COMPRESS-START-SIZE) shall still result in good performance.

I guess that these days, most people can access a remote machine by using ssh.  So I suggest that you use the ssh method.  So, type C-x C-f prefixssh,postfixhoproot,@otherhostpostfix/etc/motd RET to edit the /etc/motd file on the other host.

If you can't use ssh to log in to the remote host, then select a method that uses a program that works.  For instance, Windows users might like the plink method which uses the PuTTY implementation of ssh.  Or you use Kerberos and thus like krlogin.

For the special case of editing files on the local host as another user, see the su or sudo methods.  They offer shortened syntax for the root account, like prefixsu,postfixhop,@postfix/etc/motd.

People who edit large files may want to consider scpc instead of ssh, or pscp instead of plink.  These external methods are faster than inline methods for large files. Note, however, that external methods suffer from some limitations. Please try first whether you really get a noticeable speed advantage from using an external method!  Maybe even for large files, inline methods are fast enough.

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

The user part of a tramp file name can be omitted.  Usually, it is replaced by the user name you are logged in.  Often, this is not what you want.  A typical use of tramp might be to edit some files with root permissions on the local host.  This case, you should set the variable tramp-default-user to reflect that choice. For example:

     (setq tramp-default-user "root")

tramp-default-user is regarded as obsolete, and will be removed soon.

You can also specify different users for certain method/host combinations, via the variable tramp-default-user-alist.  For example, if you always have to use the user john in the domain somewhere.else, you can specify the following:

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

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

One trap to fall in must be known.  If tramp finds a default user, this user will be passed always to the connection command as parameter (for example ssh here.somewhere.else -l john.  If you have specified another user for your command in its configuration files, tramp cannot know it, and the remote access will fail. If you have specified in the given example in ~/.ssh/config the lines

     Host here.somewhere.else
          User lily

than you must discard selecting a default user by tramp.  This will be done by setting it to nil (or lily, likewise):

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

The last entry in tramp-default-user-alist could be your default user you'll apply predominantly.  You shall append it to that list at the end:

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

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

Finally, it is even possible to omit the host name part of a tramp file name.  This case, the value of the variable tramp-default-host is used.  Per default, it is initialized with the host name your local emacsname is running.

If you, for example, use tramp mainly to contact the host target as user john, you can specify:

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

Then the simple file name prefixssh,postfixhop,@postfix will connect you to John's home directory on target.

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

Sometimes, the methods described before are not sufficient.  Sometimes, it is not possible to connect to a remote host using a simple command. For example, if you are in a secured network, you might have to log in to a `bastion host' first before you can connect to the outside world. Of course, the target host may also require a bastion host.

In order to specify such multiple hops, it is possible to define a proxy host to pass through, via the variable tramp-default-proxies-alist.  This variable keeps a list of triples (HOST USER PROXY).

The first matching item specifies the proxy host to be passed for a file name located on a remote target matching USER@HOST. HOST and USER are regular expressions or nil, which is interpreted as a regular expression which always matches.

PROXY must be a Tramp filename which localname part is ignored. Method and user name on PROXY are optional, which is interpreted with the default values. The method must be an inline method (see Inline methods). If PROXY is nil, no additional hop is required reaching USER@HOST.

If you, for example, must pass the host bastion.your.domain as user bird for any remote host which is not located in your local domain, you can set

     (add-to-list 'tramp-default-proxies-alist
                  '("\\." nil "prefixssh,postfixhopbird,@bastion.your.domainpostfix"))
     (add-to-list 'tramp-default-proxies-alist
                  '("\\.your\\.domain\\'" nil nil))

Please note the order of the code.  add-to-list adds elements at the beginning of a list.  Therefore, most relevant rules must be added last.

Proxy hosts can be cascaded.  If there is another host called jump.your.domain, which is the only one in your local domain who is allowed connecting bastion.your.domain, you can add another rule:

     (add-to-list 'tramp-default-proxies-alist
                  '("\\`bastion\\.your\\.domain\\'"
                    "\\`bird\\'"
                    "prefixssh,postfixhop,@jump.your.domainpostfix"))

PROXY can contain the patterns %h or %u.  These patterns are replaced by the strings matching HOST or USER, respectively.

If you, for example, wants to work as root on hosts in the domain your.domain, but login as root is disabled for non-local access, you might add the following rule:

     (add-to-list 'tramp-default-proxies-alist
                  '("\\.your\\.domain\\'" "\\`root\\'" "prefixssh,postfixhop,@%hpostfix"))

Opening prefixsudo,postfixhop,@randomhost.your.domainpostfix would connect first randomhost.your.domain via ssh under your account name, and perform sudo -u root on that host afterwards.  It is important to know that the given method is applied on the host which has been reached so far.  sudo -u root, applied on your local host, wouldn't be useful here.

HOST, USER and PROXY can also be Lisp forms.  These forms are evaluated, and must return a string, or nil.  The previous example could be generalized then: For all hosts except my local one connect via ssh first, and apply sudo -u root afterwards:

     (add-to-list 'tramp-default-proxies-alist
                  '(nil "\\`root\\'" "prefixssh,postfixhop,@%hpostfix"))
     (add-to-list 'tramp-default-proxies-alist
                  '((regexp-quote (system-name)) nil nil))

This is the recommended configuration to work as root on remote Ubuntu hosts.

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

There is a variable tramp-methods which you can change if the predefined methods don't seem right.

For the time being, I'll refer you to the Lisp documentation of that variable, accessible with C-h v tramp-methods RET.

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

The variable tramp-completion-function-alist is intended to customize which files are taken into account for user and host name completion (see Filename completion).  For every method, it keeps a set of configuration files, accompanied by a Lisp function able to parse that file.  Entries in tramp-completion-function-alist have the form (METHOD PAIR1 PAIR2 ...).

Each PAIR is composed of (FUNCTION FILE). FUNCTION is responsible to extract 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 style files.  It returns host names only.

tramp-parse-passwd

     A function which parses /etc/passwd like files.  Obviously, it can return user names only.

tramp-parse-netrc

     Finally, a function which parses ~/.netrc like files.  This includes also ~/.authinfo-style files.

If you want to keep your own data in a file, with your own structure, you might provide such a function as well.  This function must meet the following conventions:

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

     Example:

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

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

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

Sometimes it is necessary to connect to the same remote host several times.  Reentering passwords again and again would be annoying, when the chosen method does not support access without password prompt through own configuration.

The best recommendation is to use the method's own mechanism for password handling. Consider ssh-agent for ssh-like methods, or pageant for plink-like methods.

However, if you cannot apply such native password handling, tramp offers alternatives.

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

The package auth-source.el, originally developed in No Gnus, offers the possibility to read passwords from a file, like FTP does it from ~/.netrc.  The default authentication file is ~/.authinfo.gpg, this can be changed via the variable auth-sources.

A typical entry in the authentication file would be

     machine melancholia port scp login daniel password geheim

The port can be any tramp method (see Inline methods, see External methods), to match only this method.  When you omit the port, you match all tramp methods.

In case of problems, setting auth-source-debug to t gives useful debug messages.

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

If there is no authentication file, tramp caches the passwords entered by you.  They will be reused next time if a connection needs them for the same user name and host name, independently of the connection method.

Passwords are not saved permanently, that means the password caching is limited to the lifetime of your emacsname session.  You can influence the lifetime of password caching by customizing the variable password-cache-expiry.  The value is the number of seconds how long passwords are cached.  Setting it to nil disables the expiration.

If you don't like this feature for security reasons, password caching can be disabled totally by customizing the variable password-cache (setting it to nil).

Implementation Note: password caching is based on the package password-cache.el.  For the time being, it is activated only when this package is seen in the load-path while loading tramp.

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

In order to reduce initial connection time, tramp stores connection related information persistently.  The variable tramp-persistency-file-name keeps the file name where these information are written.  Its default value is It is recommended to choose a local file name.

tramp reads this file during startup, and writes it when exiting emacsname.  You can simply remove this file if tramp shall be urged to recompute these information next emacsname startup time.

Using such persistent information can be disabled by setting tramp-persistency-file-name to nil.

Once consequence of reusing connection related information is that TRAMP needs to distinguish hosts.  If you, for example, run a local sshd on port 3001, which tunnels ssh to another host, you could access both prefixssh,postfixhop,@localhostpostfix and prefixssh,postfixhop,@localhost#3001postfix.  TRAMP would use the same host related information (like paths, Perl variants, etc) for both connections, although the information is valid only for one of them.

In order to avoid trouble, you must use another host name for one of the connections, like introducing a Host section in ~/.ssh/config (see Frequently Asked Questions) or applying multiple hops (see Multi-hops).

When tramp detects a changed operating system version on a remote host (via the command uname -sr), it flushes all connection related information for this host, and opens the connection again.

How tramp finds and uses programs on the remote machine.
========================================================

tramp depends on a number of programs on the remote host in order to function, including ls, test, find and cat.

In addition to these required tools, there are various tools that may be required based on the connection method.  See Inline methods and External methods for details on these.

Certain other tools, such as perl (or perl5) and grep will be used if they can be found.  When they are available, they are used to improve the performance and accuracy of remote file access.

 -- User Option: tramp-remote-path
     When tramp connects to the remote machine, it searches for the programs that it can use.  The variable tramp-remote-path controls the directories searched on the remote machine.

     By default, this is set to a reasonable set of defaults for most machines.  The symbol tramp-default-remote-path is a place holder, it is replaced by the list of directories received via the command getconf PATH on your remote machine.  For example, on Debian GNU/Linux this is /bin:/usr/bin, whereas on Solaris this is /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin. It is recommended to apply this symbol on top of tramp-remote-path.

     It is possible, however, that your local (or remote ;) system administrator has put the tools you want in some obscure local directory.

     In this case, you can still use them with tramp.  You simply need to add code to your .emacs to add the directory to the remote path.  This will then be searched by tramp when you connect and the software found.

     To add a directory to the remote search path, you could use code such as:

          ;; We load tramp to define the variable.
          (require 'tramp)
          ;; We have perl in "/usr/local/perl/bin"
          (add-to-list 'tramp-remote-path "/usr/local/perl/bin")

     Another possibility is to reuse the path settings of your remote account when you log in.  Usually, these settings are overwritten, because they might not be useful for tramp.  The place holder tramp-own-remote-path preserves these settings.  You can activate it via

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

tramp caches several information, like the Perl binary location.  The changed remote search path wouldn't affect these settings.  In order to force tramp to recompute these values, you must exit emacsname, remove your persistency file (see Connection caching), and restart emacsname.

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

As explained in the Overview section, tramp connects to the remote host and talks to the shell it finds there.  Of course, when you log in, the shell executes its init files.  Suppose your init file requires you to enter the birth date of your mother; clearly tramp does not know this and hence fails to log you in to that host.

There are different possible strategies for pursuing this problem.  One strategy is to enable tramp to deal with all possible situations. This is a losing battle, since it is not possible to deal with all situations.  The other strategy is to require you to set up the remote host such that it behaves like tramp expects.  This might be inconvenient because you have to invest a lot of effort into shell setup before you can begin to use tramp.

The package, therefore, pursues a combined approach.  It tries to figure out some of the more common setups, and only requires you to avoid really exotic stuff.  For example, it looks through a list of directories to find some programs on the remote host.  And also, it knows that it is not obvious how to check whether a file exists, and therefore it tries different possibilities.  (On some hosts and shells, the command test -e does the trick, on some hosts the shell builtin doesn't work but the program /usr/bin/test -e or /bin/test -e works.  And on still other hosts, ls -d is the right way to do this.)

Below you find a discussion of a few things that tramp does not deal with, and that you therefore have to set up correctly.

SHELL-PROMPT-PATTERN

     After logging in to the remote host, tramp has to wait for the remote shell startup to finish before it can send commands to the remote shell.  The strategy here is to wait for the shell prompt.  In order to recognize the shell prompt, the variable shell-prompt-pattern has to be set correctly to recognize the shell prompt on the remote host.

     Note that tramp requires the match for shell-prompt-pattern to be at the end of the buffer.  Many people have something like the following as the value for the variable: "^[^>$][>$] *".  Now suppose your shell prompt is a <b> c $ .  In this case, tramp recognizes the > character as the end of the prompt, but it is not at the end of the buffer.

TRAMP-SHELL-PROMPT-PATTERN

     This regular expression is used by tramp in the same way as shell-prompt-pattern, to match prompts from the remote shell. This second variable exists because the prompt from the remote shell might be different from the prompt from a local shell --- after all, the whole point of tramp is to log in to remote hosts as a different user.  The default value of tramp-shell-prompt-pattern is the same as the default value of shell-prompt-pattern, which is reported to work well in many circumstances.

TRAMP-PASSWORD-PROMPT-REGEXP

     During login, tramp might be forced to enter a password or a passphrase.  The difference between both is that a password is requested from the shell on the remote host, while a passphrase is needed for accessing local authentication information, like your ssh key.

     TRAMP-PASSWORD-PROMPT-REGEXP handles the detection of such requests for English environments.  When you use another localization of your (local or remote) host, you might need to adapt this. Example:

          (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)
                ".*:? *"))

     In parallel, it might also be necessary to adapt TRAMP-WRONG-PASSWD-REGEXP.

tset and other questions

     Some people invoke the tset program from their shell startup scripts which asks the user about the terminal type of the shell. Maybe some shells ask other questions when they are started. tramp does not know how to answer these questions.  There are two approaches for dealing with this problem.  One approach is to take care that the shell does not ask any questions when invoked from tramp.  You can do this by checking the TERM environment variable, it will be set to dumb when connecting.

     The variable tramp-terminal-type can be used to change this value to dumb.

     The other approach is to teach tramp about these questions.  See the variable 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))

Environment variables named like users in .profile

     If you have a user named frumple and set the variable FRUMPLE in your shell environment, then this might cause trouble.  Maybe rename the variable to FRUMPLE_DIR or the like.

     This weird effect was actually reported by a tramp user!

Non-Bourne commands in .profile

     After logging in to the remote host, tramp issues the command exec /bin/sh.  (Actually, the command is slightly different.)  When /bin/sh is executed, it reads some init files, such as ~/.shrc or ~/.profile.

     Now, some people have a login shell which is not /bin/sh but a Bourne-ish shell such as bash or ksh.  Some of these people might put their shell setup into the files ~/.shrc or ~/.profile. This way, it is possible for non-Bourne constructs to end up in those files.  Then, exec /bin/sh might cause the Bourne shell to barf on those constructs.

     As an example, imagine somebody putting export FOO=bar into the file ~/.profile.  The standard Bourne shell does not understand this syntax and will emit a syntax error when it reaches this line.

     Another example is the tilde (~) character, say when adding ~/bin to PATH.  Many Bourne shells will not expand this character, and since there is usually no directory whose name consists of the single character tilde, strange things will happen.

     What can you do about this?

     Well, one possibility is to make sure that everything in ~/.shrc and ~/.profile on all remote hosts is Bourne-compatible.  In the above example, instead of export FOO=bar, you might use FOO=bar; export FOO instead.

     The other possibility is to put your non-Bourne shell setup into some other files.  For example, bash reads the file ~/.bash_profile instead of ~/.profile, if the former exists.  So bash aficionados just rename their ~/.profile to ~/.bash_profile on all remote hosts, and Bob's your uncle.

     The tramp developers would like to circumvent this problem, so if you have an idea about it, please tell us.  However, we are afraid it is not that simple: before saying exec /bin/sh, tramp does not know which kind of shell it might be talking to.  It could be a Bourne-ish shell like ksh or bash, or it could be a csh derivative like tcsh, or it could be zsh, or even rc.  If the shell is Bourne-ish already, then it might be prudent to omit the exec /bin/sh step.  But how to find out if the shell is Bourne-ish?

Interactive shell prompt

     tramp redefines the shell prompt in order to parse the shell's output robustly.  When calling an interactive shell by M-x shell, this doesn't look nice.

     You can redefine the shell prompt by checking the environment variable INSIDE_EMACS, which is set by tramp, in your startup script ~/.emacs_SHELLNAME. SHELLNAME might be the string bash or similar, in case of doubt you could set it the environment variable ESHELL in your .emacs:

          (setenv "ESHELL" "bash")

     Your file ~/.emacs_SHELLNAME could contain code like

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

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

Normally, emacsname writes backup files to the same directory as the original files, but this behavior can be changed via the variable In connection with tramp, this can have unexpected side effects.  Suppose that you specify that all backups should go to the directory ~/.emacs.d/backups/, and then you edit the file prefixsu,postfixhoproot,@localhostpostfix/etc/secretfile.  The effect is that the backup file will be owned by you and not by root, thus possibly enabling others to see it even if they were not intended to see it.

When is nil (the default), such problems do not occur.

Therefore, it is useful to set special values for tramp files.  For example, the following statement effectively `turns off' the effect of for tramp files:

Another possibility is to use the tramp variable This variable has the same meaning like If a tramp file is backed up, and DIRECTORY is an absolute local file name, DIRECTORY is prepended with the tramp file name prefix of the file to be backed up.

Example:

The backup file name of prefixsu,postfixhoproot,@localhostpostfix/etc/secretfile would be

The same problem can happen with auto-saving files.

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

This section needs a lot of work!  Please help.

The recent Cygwin installation of ssh works only with a Cygwinized emacsname.  You can check it by typing M-x
eshell, and starting ssh test.machine.  The problem is evident if you see a message like this:

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

Older ssh versions of Cygwin are told to cooperate with tramp selecting sshx as the connection method.  You can find information about setting up Cygwin in their FAQ at http://cygwin.com/faq/.

If you wish to use the scpx connection method, then you might have the problem that emacsname calls scp with a Windows filename such as c:/foo.  The Cygwin version of scp does not know about Windows filenames and interprets this as a remote filename on the host c.

One possible workaround is to write a wrapper script for scp which converts the Windows filename to a Cygwinized filename.

If you want to use either ssh based method on Windows, then you might encounter problems with ssh-agent.  Using this program, you can avoid typing the pass-phrase every time you log in. However, if you start emacsname from a desktop shortcut, then the environment variable SSH_AUTH_SOCK is not set and so emacsname and thus tramp and thus ssh and scp started from tramp cannot communicate with ssh-agent.  It works better to start emacsname from the shell.

If anyone knows how to start ssh-agent under Windows in such a way that desktop shortcuts can profit, please holler.  I don't really know anything at all about Windows...

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

Once you have installed tramp it will operate fairly transparently.  You will be able to access files on any remote machine that you can log in to as though they were local.

Files are specified to tramp using a formalized syntax specifying the details of the system to connect to.  This is similar to the syntax used by the ftppackagename package.

Something that might happen which surprises you is that emacsname remembers all your keystrokes, so if you see a password prompt from emacsname, say, and hit RET twice instead of once, then the second keystroke will be processed by emacsname after tramp has done its thing.  Why, this type-ahead is normal behavior, you say.  Right you are, but be aware that opening a remote file might take quite a while, maybe half a minute when a connection needs to be opened.  Maybe after half a minute you have already forgotten that you hit that key!

tramp filename conventions
==========================

To access the file LOCALNAME on the remote machine MACHINE you would specify the filename prefix,postfixhop,@machinepostfixlocalname.  This will connect to MACHINE and transfer the file using the default method.  See Default Method.

Some examples of tramp filenames are shown below.

prefix,postfixhop,@melancholiapostfix.emacs
     Edit the file .emacs in your home directory on the machine melancholia.

prefix,postfixhop,@melancholia.danann.netpostfix.emacs
     This edits the same file, using the fully qualified domain name of the machine.

prefix,postfixhop,@melancholiapostfix~/.emacs
     This also edits the same file --- the ~ is expanded to your home directory on the remote machine, just like it is locally.

prefix,postfixhop,@melancholiapostfix~daniel/.emacs
     This edits the file .emacs in the home directory of the user daniel on the machine melancholia.  The ~<user> construct is expanded to the home directory of that user on the remote machine.

prefix,postfixhop,@melancholiapostfix/etc/squid.conf
     This edits the file /etc/squid.conf on the machine melancholia.

MACHINE can also be an IPv4 or IPv6 address, like in prefix,postfixhop,@127.0.0.1postfix.emacs or prefix,postfixhop,@ipv6prefix::1ipv6postfixpostfix.emacs.

Unless you specify a different name to use, tramp will use the current local user name as the remote user name to log in with.  If you need to log in as a different user, you can specify the user name as part of the filename.

To log in to the remote machine as a specific user, you use the syntax prefix,postfixhopuser,@machinepostfixpath/to.file.  That means that connecting to melancholia as daniel and editing .emacs in your home directory you would specify prefix,postfixhopdaniel,@melancholiapostfix.emacs.

It is also possible to specify other file transfer methods (see Inline methods, see External methods) as part of the filename. The user, machine and file specification remain the same.

So, to connect to the machine melancholia as daniel, using the ssh method to transfer files, and edit .emacs in my home directory I would specify the filename prefixssh,postfixhopdaniel,@melancholiapostfix.emacs.

Finally, for some methods it is possible to specify a different port number than the default one, given by the method.  This is specified by adding #<port> to the host name, like in prefixssh,postfixhopdaniel,@melancholia#42postfix.emacs.

URL-like filename syntax
========================

Additionally to the syntax described in the previous chapter, it is possible to use a URL-like syntax for tramp.  This can be switched on by customizing the variable tramp-syntax.  Please note that this feature is experimental for the time being.

The variable tramp-syntax must be set before requiring tramp:

     (setq tramp-syntax 'url)
     (require 'tramp)

Then, a tramp filename would look like this: /METHOD://USER@MACHINE:PORT/PATH/TO.FILE. /METHOD:// is mandatory, all other parts are optional. :PORT is useful for methods only who support this.

The last example from the previous section would look like this: /ssh://daniel@melancholia/.emacs.

For the time being, tramp-syntax can have the following values:

Filename completion
===================

Filename completion works with tramp for completion of method names, of user names and of machine names as well as for completion of file names on remote machines.

If you, for example, type C-x C-f prefixt
TAB, tramp might give you as result the choice for

prefixhoptelnetpostfixhop is a possible completion for the respective method, and prefixhoptotopostfix might be a host tramp has detected in your ~/.ssh/known_hosts file (given you're using default method ssh).

If you go on to type e TAB, the minibuffer is completed to prefixtelnetpostfixhop. Next TAB brings you all machine names tramp detects in your /etc/hosts file, let's say

     prefixtelnet,postfixhop,@127.0.0.1postfix prefixtelnet,postfixhop,@192.168.0.1postfix
     prefixtelnet,postfixhop,@ipv6prefix::1ipv6postfixpostfix prefixtelnet,postfixhop,@localhostpostfix
     prefixtelnet,postfixhop,@melancholia.danann.netpostfix prefixtelnet,postfixhop,@melancholiapostfix

Now you can choose the desired machine, and you can continue to complete file names on that machine.

If the configuration files (see Customizing Completion), which tramp uses for analysis of completion, offer user names, those user names will be taken into account as well.

Remote machines which have been visited in the past and kept persistently (see Connection caching) will be offered too.

Once the remote machine identification is completed, it comes to filename completion on the remote host.  This works pretty much like for files on the local host, with the exception that minibuffer killing via a double-slash works only on the filename part, except that filename part starts with //. See Minibuffer File (emacsdir).

Example:

A remote directory might have changed its contents out of emacsname control, for example by creation or deletion of files by other processes.  Therefore, during filename completion, the remote directory contents are reread regularly in order to detect such changes, which would be invisible otherwise (see Connection caching).

 -- User Option: tramp-completion-reread-directory-timeout
     This variable defines the number of seconds since last remote command before rereading a directory contents.  A value of 0 would require an immediate reread during filename completion, nil means to use always cached values for the directory contents.

Integration with other emacsname packages.
==========================================

tramp supports running processes on a remote host.  This allows to exploit emacsname packages without modification for remote file names.  It does not work for the ftp and smb methods.  Association of a pty, as specified in start-file-process, is not supported.

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 *"))

Remote processes are started when a corresponding command is executed from a buffer belonging to a remote file or directory.  Up to now, the packages compile.el (commands like compile and grep) and gud.el (gdb or perldb) have been integrated.  Integration of further packages is planned, any help for this is welcome!

When your program is not found in the default search path tramp sets on the remote machine, you should either 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")

The environment for your program can be adapted by customizing tramp-remote-process-environment.  This variable is a list of strings.  It is structured like process-environment.  Each element is a string of the form ENVVARNAME=VALUE.  An entry ENVVARNAME= disables the corresponding environment variable, which might have been set in your init file like ~/.profile.

Adding an entry can be performed via add-to-list:

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

Changing or removing an existing entry is not encouraged.  The default values are chosen for proper tramp work.  Nevertheless, if for example a paranoid system administrator disallows changing the HISTORY environment variable, you can customize tramp-remote-process-environment, or you can apply the following code in your .emacs:

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

If you use other emacsname packages which do not run out-of-the-box on a remote host, please let us know.  We will try to integrate them as well.  See Bug Reports.

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

If you want to run a remote program, which shall connect the X11 server you are using with your local host, you can set the DISPLAY environment variable on the remote host:

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

(getenv "DISPLAY") shall return a string containing a host name, which can be interpreted on the remote host; otherwise you might use a fixed host name.  Strings like :0 cannot be used properly on the remote host.

Another trick might be that you put ForwardX11 yes or ForwardX11Trusted yes to your ~/.ssh/config file for that host.

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

Calling M-x shell in a buffer related to a remote host runs the local shell as defined in shell-file-name.  This might be also a valid path name for a shell to be applied on the remote host, but it will fail at least when your local and remote hosts belong to different system types, like windows-nt and gnu/linux.

You must set the variable explicit-shell-file-name to the shell path name on the remote host, in order to start that shell on the remote host.

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

shell-command allows to execute commands in a shell, either synchronously, either asynchronously.  This works also on remote hosts.  Example:

     C-x C-f prefixsudo,postfixhop,@postfix RET
     M-! tail -f /var/log/syslog.log & RET

You will see the buffer *Async Shell Command*, containing the continuous output of the tail command.

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

tramp is integrated into eshell.el.  That is, you can open an interactive shell on your remote host, and run commands there. After you have started M-x eshell, you could perform commands like this:

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

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

gud.el offers an unified interface to several symbolic debuggers With tramp, it is possible to debug programs on remote hosts.  You can call gdb with a remote file name:

     M-x gdb RET
     Run gdb (like this): gdb --annotate=3 prefixssh,postfixhop,@hostpostfix~/myprog RET

The file name can also be relative to a remote default directory. Given you are in a buffer that belongs to the remote directory prefixssh,postfixhop,@hostpostfix/home/user, you could call

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

It is not possible to use just the absolute local part of a remote file name as program to debug, like perl -d /home/user/myprog.pl, though.

Arguments of the program to be debugged are taken literally.  That means, file names as arguments must be given as ordinary relative or absolute file names, without any remote specification.

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

Sometimes it is useful to cleanup remote connections.  The following commands support this.

 -- Command: tramp-cleanup-connection vec
     This command flushes all connection related objects.  vec is the internal representation of a remote connection.  Called interactively, the command offers all active remote connections in the minibuffer as remote file name prefix like prefixmethod,postfixhopuser,@hostpostfix.  The cleanup includes password cache (see Password handling), file cache, connection cache (see Connection caching), connection buffers.

 -- Command: tramp-cleanup-this-connection
     This command flushes all objects of the current buffer's remote connection.  The same objects are removed as in tramp-cleanup-connection.

 -- Command: tramp-cleanup-all-connections
     This command flushes objects for all active remote connections.  The same objects are removed as in tramp-cleanup-connection.

 -- Command: tramp-cleanup-all-buffers
     Like in tramp-cleanup-all-connections, all remote connections are cleaned up.  Additionally all buffers, which are related to a remote connection, are killed.

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

Bugs and problems with tramp are actively worked on by the development team.  Feature requests and suggestions are also more than welcome.

The tramp mailing list is a great place to get information on working with tramp, solving problems and general discussion and advice on topics relating to the package.  It is moderated so non-subscribers can post but messages will be delayed, possibly up to 48 hours (or longer in case of holidays), until the moderator approves your message.

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

Subscribing to the list is performed via the tramp Mail Subscription Page (http://lists.gnu.org/mailman/listinfo/tramp-devel/).

To report a bug in tramp, you should execute M-x
tramp-bug.  This will automatically generate a buffer with the details of your system and tramp version.

When submitting a bug report, please try to describe in excruciating detail the steps required to reproduce the problem, the setup of the remote machine and any special conditions that exist.  You should also check that your problem is not described already in see Frequently Asked Questions.

If you can identify a minimal test case that reproduces the problem, include that with your bug report.  This will make it much easier for the development team to analyze and correct the problem.

Before reporting the bug, you should set the verbosity level to 6 (see Traces) in the ~/.emacs file and repeat the bug.  Then, include the contents of the *tramp/foo* and *debug tramp/foo* buffers in your bug report.  A verbosity level greater than 6 will produce a very huge debug buffer, which is mostly not necessary for the analysis.

Please be aware that, with a verbosity level of 6 or greater, the contents of files and directories will be included in the debug buffer.  Passwords you've typed will never be included there.

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

  * Where can I get the latest tramp?

     tramp is available under the URL below.

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

     There is also a Savannah project page.

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

  * Which systems does it work on?

     The package has been used successfully on Emacs 22, Emacs 23, Emacs 24, XEmacs 21 (starting with 21.4), and SXEmacs 22.

     The package was intended to work on Unix, and it really expects a Unix-like system on the remote end (except the smb method), but some people seemed to have some success getting it to work on MS Windows XP/Vista/7 emacsname.

  * How could I speed up tramp?

     In the backstage, tramp needs a lot of operations on the remote host.  The time for transferring data from and to the remote host as well as the time needed to perform the operations there count. In order to speed up tramp, one could either try to avoid some of the operations, or one could try to improve their performance.

     Use an external method, like scpc.

     Use caching.  This is already enabled by default.  Information about the remote host as well as the remote files are cached for reuse.  The information about remote hosts is kept in the file specified in tramp-persistency-file-name.  Keep this file.  If you are confident that files on remote hosts are not changed out of emacsname' control, set remote-file-name-inhibit-cache to nil.

     Disable version control.  If you access remote files which are not under version control, a lot of check operations can be avoided by disabling VC.  This can be achieved by

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

     Disable excessive traces.  The default trace level of tramp, defined in the variable tramp-verbose, is 3.  You should increase this level only temporarily, hunting bugs.

  * tramp does not connect to the remote host

     When tramp does not connect to the remote host, there are three reasons heading the bug mailing list:

       - Unknown characters in the prompt

          tramp needs to recognize the prompt on the remote machine after execution any command.  This is not possible when the prompt contains unknown characters like escape sequences for coloring.  This should be avoided on the remote side.  See Remote shell setup. for setting the regular expression detecting the prompt.

          You can check your settings after an unsuccessful connection by switching to the tramp connection buffer *tramp/foo*, setting the cursor at the top of the buffer, and applying the expression

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

          If it fails, or the cursor is not moved at the end of the buffer, your prompt is not recognized correctly.

          A special problem is the zsh, which uses left-hand side and right-hand side prompts in parallel.  Therefore, it is necessary to disable the zsh line editor on the remote host.  You shall add to ~/.zshrc the following command:

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

          Furthermore it has been reported, that tramp (like sshfs, incidentally) doesn't work with WinSSHD due to strange prompt settings.

       - Echoed characters after login

          When the remote machine opens an echoing shell, there might be control characters in the welcome message.  tramp tries to suppress such echoes via the stty -echo command, but sometimes this command is not reached, because the echoed output has confused tramp already.  In such situations it might be helpful to use the sshx or scpx methods, which allocate a pseudo tty. See Inline methods.

       - tramp doesn't transfer strings with more than 500 characters correctly

          On some few systems, the implementation of process-send-string seems to be broken for longer strings.  It is reported for HP-UX, FreeBSD and Tru64 Unix, for example.  This case, you should customize the variable tramp-chunksize to 500.  For a description how to determine whether this is necessary see the documentation of tramp-chunksize.

          Additionally, it will be useful to set file-precious-flag to t for tramp files.  Then the file contents will be written into a temporary file first, which is checked for correct checksum. see Saving Buffers (elisp)

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

  * tramp does not recognize hung ssh sessions

     When your network connection is down, ssh sessions might hang.  tramp cannot detect it safely, because it still sees a running ssh process.  Timeouts cannot be used as well, because it cannot be predicted how long a remote command will last, for example when copying very large files.

     Therefore, you must configure the ssh process to die in such a case.  The following entry in ~/.ssh/config would do the job:

          Host *
               ServerAliveInterval 5

  * File name completion does not work with tramp

     When you log in to the remote machine, do you see the output of ls in color? If so, this may be the cause of your problems.

     ls outputs ANSI escape sequences that your terminal emulator interprets to set the colors.  These escape sequences will confuse tramp however.

     In your .bashrc, .profile or equivalent on the remote machine you probably have an alias configured that adds the option --color=yes or --color=auto.

     You should remove that alias and ensure that a new login does not display the output of ls in color.  If you still cannot use filename completion, report a bug to the tramp developers.

  * File name completion does not work in large directories

     tramp uses globbing for some operations.  (Globbing means to use the shell to expand wildcards such as `*.c'.)  This might create long command lines, especially in directories with many files.  Some shells choke on long command lines, or don't cope well with the globbing itself.

     If you have a large directory on the remote end, you may wish to execute a command like ls -d * ..?* > /dev/null and see if it hangs. Note that you must first start the right shell, which might be /bin/sh, ksh or bash, depending on which of those supports tilde expansion.

  * How can I get notified when tramp file transfers are complete?

     The following snippet can be put in your ~/.emacs file.  It makes emacsname beep after reading from or writing to the remote host.

          (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))

  * There's this ~/.sh_history file on the remote host which keeps growing and growing.  What's that?

     Sometimes, tramp starts ksh on the remote host for tilde expansion.  Maybe ksh saves the history by default. tramp tries to turn off saving the history, but maybe you have to help.  For example, you could put this in your .kshrc:

          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

  * There are longish file names to type.  How to shorten this?

     Let's say you need regularly access to prefixssh,postfixhopnews,@news.my.domainpostfix/opt/news/etc, which is boring to type again and again.  The following approaches can be mixed:

      1. Use default values for method 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 file name left to type would be C-x C-f prefix,postfixhop,@news.my.domainpostfix/opt/news/etc.

          Note that there are some useful settings already.  Accessing your local host as root user, is possible just by C-x C-f
          prefixsu,postfixhop,@postfix.

      2. Use configuration possibilities of your method:

          Several connection methods (i.e. the programs used) offer powerful configuration possibilities (see Customizing Completion).  In the given case, this could be ~/.ssh/config:

               Host xy
                    HostName news.my.domain
                    User news

          The file name left to type would be C-x C-f prefixssh,postfixhop,@xypostfix/opt/news/etc.  Depending on files in your directories, it is even possible to complete the host name with C-x C-f
          prefixsshpostfixhopx TAB.

      3. Use environment variables:

          File names typed in the minibuffer can be expanded by environment variables.  You can set them outside emacsname, or even with Lisp:

               (setenv "xy" "prefixssh,postfixhopnews,@news.my.domainpostfix/opt/news/etc/")

          Then you need simply to type C-x C-f $xy RET, and here you are.  The disadvantage is that you cannot edit the file name, because environment variables are not expanded during editing in the minibuffer.

      4. Define own keys:

          You can define your own key sequences in emacsname, which can be used instead of C-x C-f:

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

          Simply typing C-x C-y would initialize the minibuffer for editing with your beloved file name.

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

      5. Define own abbreviation (1):

          It is possible to define an own abbreviation list for expanding file names:

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

          This shortens the file opening command to C-x C-f /xy RET.  The disadvantage is, again, that you cannot edit the file name, because the expansion happens after entering the file name only.

      6. Define own abbreviation (2):

          The abbrev-mode gives more flexibility for editing the minibuffer:

               (define-abbrev-table 'my-tramp-abbrev-table
                 '(("xy" "prefixssh,postfixhopnews,@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))

          After entering C-x C-f xy TAB, the minibuffer is expanded, and you can continue editing.

      7. Use bookmarks:

          Bookmarks can be used to visit Tramp files or directories. see Bookmarks (emacsdir)

          When you have opened prefixssh,postfixhopnews,@news.my.domainpostfix/opt/news/etc/, you should save the bookmark via

          Later on, you can always navigate to that bookmark via

      8. Use recent files:

          remembers visited places.

          You could keep remote file names in the recent list without checking their readability through a remote access:

          The list of files opened recently is reachable via

     I would like to thank all tramp users who have contributed to the different recipes!

  * There are packages which call tramp although I haven't entered a remote file name ever.  I dislike it, how could I disable it?

     In general, tramp functions are used only when you apply remote file name syntax.  However, some packages enable tramp on their own.

       - ido.el

          You could disable tramp file name completion:

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

       - rlogin.el

          You could disable remote directory tracking mode:

               (rlogin-directory-tracking-mode -1)

  * How can I disable tramp at all?

     Shame on you, why did you read until now?

       - In order to disable you must set tramp-mode to nil:

               (setq tramp-mode nil)

       - Unloading tramp can be achieved by applying M-x
          tramp-unload-tramp.

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

Breaking a localname into its components.
=========================================

tramp file names are somewhat different, obviously, to ordinary file names.  As such, the lisp functions file-name-directory and file-name-nondirectory are overridden within the tramp package.

Their replacements are reasonably simplistic in their approach.  They dissect the filename, call the original handler on the localname and then rebuild the tramp file name with the result.

This allows the platform specific hacks in the original handlers to take effect while preserving the tramp file name information.

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

All tramp messages are raised with a verbosity level.  The verbosity level can be any number between 0 and 10.  Only messages with a verbosity level less than or equal to tramp-verbose are displayed.

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)

When tramp-verbose is greater than or equal to 4, the messages are also written into a tramp debug buffer.  This debug buffer is useful for analyzing problems; sending a tramp bug report should be done with tramp-verbose set to a verbosity level of at least 6 (see Bug Reports).

The debug buffer is in Outline Mode (emacsdir). That means, you can change the level of messages to be viewed.  If you want, for example, see only messages up to verbosity level 5, you must enter C-u 6 C-c C-q. Other keys for navigating are described in Outline Visibility (emacsdir).

tramp errors are handled internally in order to raise the verbosity level 1 messages.  When you want to get a Lisp backtrace in case of an error, you need to set both

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

Sometimes, it might be even necessary to step through tramp function call traces.  Such traces are enabled by the following code:

     (require 'tramp)
     (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 function call traces are inserted in the buffer *trace-output*.  tramp-read-passwd and tramp-gw-basic-authentication shall be disabled when the function call traces are added to tramp, because both functions return password strings, which should not be distributed.

Debatable Issues and What Was Decided
*************************************

  * The uuencode method does not always work.

     Due to the design of tramp, the encoding and decoding programs need to read from stdin and write to stdout.  On some systems, uudecode -o - will read stdin and write the decoded file to stdout, on other systems uudecode -p does the same thing. But some systems have uudecode implementations which cannot do this at all---it is not possible to call these uudecode implementations with suitable parameters so that they write to stdout.

     Of course, this could be circumvented: the begin foo 644 line could be rewritten to put in some temporary file name, then uudecode could be called, then the temp file could be printed and deleted.

     But I have decided that this is too fragile to reliably work, so on some systems you'll have to do without the uuencode methods.

  * The tramp filename syntax differs between Emacs and XEmacs.

     The Emacs maintainers wish to use a unified filename syntax for Ange-FTP and tramp so that users don't have to learn a new syntax.  It is sufficient to learn some extensions to the old syntax.

     For the XEmacs maintainers, the problems caused from using a unified filename syntax are greater than the gains.  The XEmacs package system uses EFS for downloading new packages.  So, obviously, EFS has to be installed from the start.  If the filenames were unified, tramp would have to be installed from the start, too.

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

     [file doclicense.texi not included]