tags:

views:

908

answers:

3

My campus only lets ssh access through a gateway server. So to access the cluster I am coding on I have to ssh to the gateway and then ssh to the machine I am working on. The connection is very slow at times and is frustrating to work on.

I would love to use something like tramp which I understand would have the buffer open on my local machine and only talk through the network when I save to disk. I am not very familiar with tramp at all and struggling to get it to work, especially through the double hop. The documentation says this is accomplished through defining proxies in tramp, but I am unable to understand the syntax.

Does anyone know how to use emacs to code through a double hop or have an alternate workaround for editing code through two ssh hops?

+5  A: 

You should use ssh to do the double hop. In your .ssh/config:

Host <host that must be proxied too>
ProxyCommand ssh -qxT <gateway host> nc %h %p
fuzzy-waffle
I have never gotten that to work. I trid it just now and it prompts me for my password on the gateway and says:"ssh_exchange_identification: Connection closed by remote host"Then quits
f4hy
Keep in mind that you'll need netcat installed on the hop machine. However, you should be able to compile it yourself and keep it in ~/bin/ You may have to put the full path in the proxycommand (... /home/yourname/bin/nc %h %p)
Benson
Oh, and keep in mind that this will work best if you have keys set up, or you'll end up typing your password a lot (i.e. twice per login).
Benson
+2  A: 

Tramp has a multi method. On GNU Emacs, you could use it like this:

/multi:ssh:user1@host1:ssh:user2@host2:/foo/bar/baz

to open /foo/bar/baz on host2. The same thing is possible on XEmacs, but with a somewhat different syntax. You can use different access methods, too.

hillu
multi doesn't work using this for me. Hasn't it been removed in recent versions of Emacs?
Legooolas
How recent? I am using Emacs 22.3 on Debian/unstable boxes and it works just fine.
hillu
They took out the support. I tried it on GNU Emacs 23.2.1 (i686-pc-cygwin, GTK+ Version 2.18.6) and got: "tramp-dissect-file-name: `multi' method is no longer supported, see (info "(tramp)Multi-hops")."
User1
+3  A: 

If you have the latest version of Emacs then multi is no longer supported.

In you .emacs config file add the following:

(add-to-list 'tramp-default-proxies-alist
                 '("HOSTB" nil "/ssh:USERA@HOSTA:"))

Where HOSTB is the destination host behind HOSTA.

Then type /ssh:USERB@HOSTB: and emacs will prompt for the HOSTA password then the HOSTB password.

Tom
Any idea why multi has been removed? It was awesome :(
Legooolas