Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs Tramp ssh double hop

Tags:

emacs

ssh

tramp

Could somebody please help me setup Emacs Tramp to do a double hop? I want to work on machine2.abc.def.edu to which I can connect only through machine1.abc.def.edu. My username is myname, on both machines same.

I've tried to add .emacs:

(add-to-list 'tramp-default-proxies-alist
          '("\\`machine2\\.abc\\.def\\.edu\\'"
            "\\`myname\\'"
            "/ssh:machine1\\.abc\\.def\\.edu:"))

This is my best guess interpretation of what's in the manual. Then I do: C-x C-f /ssh:machine2.abc.def.edu or: C-x C-f /ssh:[email protected]

But both give:

ssh: Could not resolve hostname ssh: nodename nor servname provided, or not known
Process *tramp/scpc ssh* exited abnormally with code 255

And my Aquamacs can't be quitted and have to killed from shell... There is a 2 years thread here with same question. I've tried the answer from there:

(add-to-list 'tramp-default-proxies-alist
          '("machine2.abc.def.edu"
            nil
            "/ssh:[email protected]:"))

With same results... also for all combinations I could come up with... Remote editing on machine1.abc.def.edu works fine, though.

like image 653
user673592 Avatar asked May 01 '11 10:05

user673592


1 Answers

The answer it to use the ssh_proxy command available in ssh_config. Documented here and here. Basically you create a config file in your ssh folder that you can write shortcuts in. One of your shortcuts is to use a proxy through another end point. All of your shortcuts work for any tool that uses ssh including git and emacs.

Host endpoint2
     User myusername
     HostName mysite.com
     Port 3000
     ProxyCommand ssh endpoint1 nc -w300 %h %p

Host endpoint1
     User somename
     HostName otherdomainorip.com
     Port 6893

In this example running ssh endpoint2 will automatically hop through endpoint1.

like image 75
Mauvis Ledford Avatar answered Sep 30 '22 04:09

Mauvis Ledford