Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

This is an extension of the question by @Andrei

How to mount remote SSHFS via intermediate machine? Tunneling?

I'm in the same situation that I want to mount a remote directory, however the difference is that both machines A and B are not publicly exposed on the internet. A is my local work station.

So I can neither ssh from A -> B, nor B -> A.

What I regularly do, is establish a reverse connection from B -> C, where C is a rented virtual server (VPS). A script doing this connection (and reconnecting in case of lost connection) is started via the @reboot key of cron.

user@pcB $ ssh -R 2048:localhost:22 -p<port> user@serverC

Then, to go from A -> B I take the intermediate route A -> C -> B.

user@pcA $ ssh serverC
user@serverC $ ssh -p 2048 user@localhost
user@pcB $ # okay, logged in.

I'm looking for a way to mount the directory pcB:/home/user on pcA.

How do I connect to a pc through another pc using ssh is similar, but the solutions provided don't work in this scenario: the connection map in my case is A -> C <- B not A -> C -> B.

share|improve this question
up vote 2 down vote accepted

This was easier than I thought!

All one has to do is bind the port 2048 of serverC to a port on pcA. For simplicity I use the same port number 2048:

user@pcA $ ssh -L 2048:localhost:2048 user@serverC

One needs to keep this terminal window open.

Then, mounting the directory pcB:/home/user locally on pcA looks like this:

sshfs -o port=2048 user@localhost:/home/user/ /mnt/pcB

Nice side-effect: This means you can also use efficient X-server connections, e.g. freeNX or vnc to retrieve a display of pcB. Just connect to localhost:2048 and use the correct credentials (user name/password) for machine pcB!

Note that doing this might violate your employers'/organizational security policy, so make sure to get appropriate permissions.

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.