Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to SFTP to a remote computer that is behind NAT. I can't modify the NAT router, so I have set up a reverse SSH tunnel using a middleman server.

Here's what my SSH tunnel looks like:

laptop--->nat--->middleman<--nat<--desktop

The full details are here: Remote desktop over SSH reverse tunnel to replace TeamViewer

I am currently using SSH and VNC over this tunnel.

How do I use SFTP over the tunnel?

I assume the command will look something like

sftp://localhost:port

SSH login is via key pair only (no password) so we need to consider that in the solution. And I use KDE, so I need to get this working with Dolphin file manager. I've heard that setting up SFTP authentication in Dolphin can be a pain...

I'll be running Dolphin on the laptop and connecting to the file system on the desktop like this.

laptop(SFTP client)--->nat--->middleman<--nat<--desktop(SFTP server)

P.S. I would consider sshfs too, if that would be easier. I assume it won't because I don't have a domain name or IP address for the server.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

First, this is a prerequesite (at least for me): Remote desktop over SSH reverse tunnel to replace TeamViewer

The reverse SSH tunnel looks like this:

laptop(SFTP client)--->nat--->middleman<--nat<--desktop(SFTP server)

On laptop edit ~/.ssh/config and add this:

Host SftpToDesktop
  HostName localhost
  Port %p
  User admin
  PasswordAuthentication no
  IdentityFile ~/.ssh/my_id_rsa

Then, with an existing SSH leg from laptop to middleman established already (as per above link), do the following:

$ ssh -fNL 1234:localhost:1234 -i ~/.ssh/some_id_rsa admin@middleman.com

Finally, open Dolphin (if using KDE like me) and enter this location:

sftp://SftpToDesktop:1234
share|improve this answer
add comment

Your Answer

 
discard

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.