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. 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
localname (path name on the remote system). The method name is always
`multi'.
Each hop consists of a "hop method" specification, a user name and a
host name. The hop method can be an inline method only. The following
hop methods are (currently) available:
`telnet'
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.
`rsh'
This uses `rsh' to connect to the host. You do not need to enter
a password unless `rsh' explicitly asks for it.
The variant `remsh' uses the `remsh' command. It should be
applied on machines where `remsh' is used instead of `rsh'.
`ssh'
This uses `ssh' to connect to the host. You might have to enter a
password or a pass phrase.
`su'
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 an `su'
hop, the host name is ignored and only the user name is used.
`sudo'
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.