Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can access a server A with SSH, and from there I can access server B, but I can't access B directly.

Is it possible to open a Nautilus folder in server B by clicking in PlacesConnect to Server?

share|improve this question
Quick question... in relation to server 'A', where is server 'B'? On an internal network which Server 'A' shares with Server 'B', or on a separate external network/IP? Also, is Server 'B' restricting connections to it to a selected group of IPs, say the iP that Server A has? – Thomas W. Feb 6 '12 at 15:55
up vote 5 down vote accepted

Yes that is possible. I have the following setup which works, but there might be easier ones.

In the file ~/.ssh/config, add the following lines:

ControlMaster auto
ControlPath   /home/yourusername/.ssh/tmp/%h_%p_%r
Host A
  HostName hostname.of.server.a

Host B
  ProxyCommand ssh -e none A netcat -w 5 hostname.of.server.b 22

You have to replace yourusername, hostname.of.sever.a and hostname.of.server.b After that, you can (in Nautilus) go to Places->Connect to Server (its actually File->Connect to Server on my machine). And then enter B. That should be all to see the server B.

share|improve this answer

One thing to try is to add this to .ssh/config:

Host B
  ProxyCommand ssh A nc -q0 %h %p
  ForwardAgent yes

Once this is in place, you should be able to ssh B directly, and SSH will know to "bounce" the connection through A first.

When this is working, try Nautilus the way you describe and see if the proxying setup works for it as well.

share|improve this answer
I can't post comments yet so I'm writing here. roadmr reply worked perfectly for me but I had to change "-q0" with "-p0". Looking at the man nc, -q should be the waiting time and -p should specify the source port. I don't know why that should be 0, but it worked :) – user279399 May 8 '14 at 12:48

An update on the previous answers: using netcat to forward the connection on the intermediate host works differently than ssh'ing directly, and will fail when you want to e.g. connect to a VNC server that is set to only accept local connections through a jumphost tunnel. In order for the connection to work exactly like a direct one, use the -W option present in newer versions of the client:

Host jumphost
Hostname hostname.of.jumphost

Host target
Port 30022
ProxyCommand ssh -W %h:%p jumphost
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.