| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
TRAMP is (normally) fully functional when it is initially
installed. It is initially configured to use the ssh program
to connect to the remote host and to use base-64 encoding (on the
remote host, via mimencode, and on the local host via the
built-in support for base-64 encoding in Emacs).
On some hosts, there are problems with opening a connection. These are related to the behavior of the remote shell. See See section 6.9 Remote shell setup hints, 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 section 6.1 Types of connections made to remote machines.).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 over the same connection used to log in to the remote
machine or the file can be transfered through another connection using
a remote copy program such as rcp, scp or
rsync. The former are called inline methods, the
latter are called out-of-band methods or external transfer
methods (external methods for short).
The performance of the external transfer 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 transfer methods do require that the remote copy command is not interactive -- that is, the command does not prompt you for a password. If you cannot perform remote copies without a password, you will need to use an inline transfer method to work with TRAMP.
A variant of the inline methods are the multi-hop methods. These methods allow you to connect a remote host using a number `hops', each of which connects to a different host. This is useful if you are in a secured network where you need to go through a bastion host to connect to the outside world.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 Emacs to decode and encode the files or it may require access to external commands to perform that task.
TRAMP supports the use of uuencode to transfer files.
This is not recommended. The uuencode and
uudecode commands are not well standardized and may not
function correctly or at all on some machines, notably AIX and IRIX.
These systems do not work with uuencode at all. (But do see
the note about AIX in the documentation for tramp-methods.)
In summary, if possible use the mimencode methods to transfer
the data base64 encoded. This has the advantage of using a built-in
command in every modern Emacs, improving performance.
rsh with mimencode
Connect to the remote host with rsh and use base64 encoding to
transfer files between the machines.
This requires the mimencode command that is part of the
metamail packages. This may not be installed on all remote
machines.
ssh with mimencode
Connect to the remote host with ssh and use base64 encoding to
transfer files between the machines.
This is identical to the previous option except that the ssh
package is used, making the connection more secure.
There are also two variants, `sm1' and `sm2', 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 `sm' method.)
There are also two variants, `sm-ssh1' and `sm-ssh2'
that use the ssh1 and ssh2 commands explicitly. If
you don't know what these are, you do not need these options.
All the methods based on ssh have an additional kludgy
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 with mimencode
Connect to the remote host with telnet and use base64 encoding
to transfer files between the machines.
This requires the mimencode command that is part of the
metamail packages.
rsh with uuencode
Connect to the remote host with rsh and use the
uuencode and uudecode commands to transfer files
between the machines.
ssh with uuencode
Connect to the remote host with ssh and use the
uuencode and uudecode commands to transfer files
between the machines.
As with the ssh and base64 option (`sm') above, this
provides the `su1' and `su2' methods to explicitly
select an SSH protocol version, and the `su-ssh1' and
`su-ssh2' variants to call specific SSH binaries.
Note that this method does not invoke the su program, see
below for methods which use that.
This supports the `-p' kludge.
telnet with uuencode
Connect to the remote host with telnet and use the
uuencode and uudecode commands to transfer files
between the machines.
su with mimencode
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. Uses
base64 encoding to transfer the file contents.
su with uuencode
Like `sum', this uses the su program to allow you to
edit files on the local host as another user. Uses uuencode
and uudecode to transfer the file contents.
sudo with mimencode
This is similar to the `sum' 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.
sudo with uuencode
This is similar to the `suu' method, but it uses sudo
rather than su to become a different user.
ssh with mimencode
As you expect, this is similar to `sm', only a little different. Whereas `sm' 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 Emacs 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. For reasons
unknown, some Windows ports for ssh (maybe the Cygwin one)
require the doubled `-t' option.
This supports the `-p' kludge.
krlogin with mimencode
This method is also similar to `sm'. It only uses the
krlogin -x command to log in to the remote host.
plink with uuencode
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.
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: Does plink support the `-p' option? Tramp
will support that, anyway.
plink with mimencode
Like `plinku', but uses base64 encoding instead of uu encoding.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The external transfer 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.
If you want to use an external transfer method you must be able to execute the transfer utility to copy files to and from the remote machine without any interaction.
This means that you will need to use ssh-agent if you use the
scp program for transfers, or maybe your version of
scp accepts a password on the command line.(2)
If you use rsync via ssh then the same rule must
apply to that connection.
If you cannot get scp to run without asking for a password but
would still like to use ssh to secure your connection, have a
look at the ssh based inline methods.
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.
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.
All the ssh based methods support the kludgy `-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.
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.
The rsync based method may be considerably faster than the
rcp based methods when writing to the remote system. Reading
files to the local machine is no faster than with a direct copy.
This method supports the `-p' hack.
ssh and scp
As you 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 Emacs 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. Maybe this
applies to the Cygwin port of SSH.
This method supports the `-p' hack.
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.
CCC: Does plink support the `-p' hack?
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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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. The format of multi-hop filenames is slightly different than the format of normal TRAMP methods.
A multi-hop file name specifies a method, a number of hops, and a path name on the remote system. The method specifies how the file is transferred through the inline connection. The following two multi-hop methods are available:
mimencode
The file is transferred through the connection in base64 encoding. Uses
the mimencode program for doing encoding and decoding, but
uses an Emacs internal implementation on the local host if available.
uuencode and uudecode
The file is transferred through the connection in `uu' encoding. Uses
the uuencode and uudecode programs for encoding and
decoding, but uses a Lisp implementation for decoding on the local host
if available.
Each hop consists of a hop method specification, a user name and a host name. The following hop methods are (currently) available:
Uses the well-known telnet program to connect to the host.
Whereas user name and host name are supplied in the file name, the
user is queried for the password.
This uses rsh to connect to the host. You do not need to
enter a password unless rsh explicitly asks for it.
This uses ssh to connect to the host. You might have to enter
a password or a pass phrase.
This method does not actually contact a different host, but it allows you to become a different user on the host you're currently on. This might be useful if you want to edit files as root, but the remote host does not allow remote root logins. In this case you can use `telnet', `rsh' or `ssh' to connect to the remote host as a non-root user, then use an `su' hop to become root. But `su' need not be the last hop in a sequence, you could also use it somewhere in the middle, if the need arises.
Even though you must specify both user and host with a `su' hop, the host name is ignored and only the user name is used.
This is similar to the `su' hop, except that it uses
sudo rather than su to become a different user.
Some people might wish to use port forwarding with ssh or
maybe they have to use a nonstandard port. This can be accomplished
by putting a stanza in `~/.ssh/config' for the account which
specifies a different port number for a certain host name. But it can
also be accomplished within Tramp, by adding a multi-hop method. For
example:
(add-to-list
'tramp-multi-connection-function-alist
'("sshf" tramp-multi-connect-rlogin "ssh %h -l %u -p 4400%n"))
|
Now you can use an sshf hop which connects to port 4400 instead of
the standard port.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 path. For example:
(setq tramp-default-method "scp") |
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 `sm' method for all user names matching `john' and the `rsync' method for all host names matching `lily'. The third line specifies to use the `sum' method for the user `root' on the machine `localhost'.
(add-to-list 'tramp-default-method-alist '("" "john" "sm"))
(add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
(add-to-list 'tramp-default-method-alist
'("\\`root\\'" "\\`localhost\\'" "sum"))
|
See the documentation for the variable tramp-default-method-alist for more details.
External transfer methods are normally preferable to inline transfer methods, giving better performance. They may not be useful if you use many remote machines where you cannot log in without a password.
See section 6.2 Inline methods. See section 6.3 External transfer methods. See section 6.4 Connecting to a remote host using multiple hops.
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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The variable tramp-completion-function-alist is intended to
customize, which files are taken into account for user and host name
completion (see section 7.3 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:
Example:
(tramp-get-completion-function "rsh")
=> ((tramp-parse-rhosts "/etc/hosts.equiv")
(tramp-parse-rhosts "~/.rhosts"))
|
Example:
(tramp-set-completion-function "ssh"
'((tramp-parse-shosts "/etc/ssh_known_hosts")
(tramp-parse-shosts "~/.ssh/known_hosts")))
=> ((tramp-parse-shosts "/etc/ssh_known_hosts")
(tramp-parse-shosts "~/.ssh/known_hosts"))
|
The following predefined functions parsing configuration files exists:
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 `/etc/ssh_known_hosts'. Since there are no user names specified in such files, it can return host names only.
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.
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:
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"))
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 6.2 Inline methods and 6.3 External transfer 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.
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. 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 |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
As explained in the 1. An overview of TRAMP 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 expect. 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 exist, 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.
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.
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.
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 variables tramp-actions-before-shell and
tramp-multi-actions (for multi-hop connections).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section needs a lot of work! Please help.
If you use the Cygwin installation of ssh (you have to explicitly select
it in the installer), then it should work out of the box to just select
smx as the connection method. You can find information about
setting up Cygwin in their FAQ at http://cygwin.com/faq/.
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |