I have two machines: my laptop and a remote server. The server sits behind a firewall that only allows incoming ssh connections. I can use ssh on my laptop to login to the server without any issues. Since I don't want to (can't) change the firewall, I'd still like to be able to run apt-get upgrade and similar commands on the server, and thought that I could easily do the "reverse" of ssh -D 1234 user@remote - ie change the -D to something else so that I get a "reverse socks proxy" available on the remote end. (This I could later use, after setting up the right environment variables.)

Both machines run Ubuntu 15.04 and I'm using OpenSSH.

What command (or commands) should I issue in order to setup a tunnel with SSH, which has a proxy on my end (the laptop with internet access) and the remote server (which only accepts incoming tcp on port 22)?


OpenSSH 7.6 introduced reverse dynamic proxy as a native option. It is implemented entirely in the client, so the server does not need to be updated.

ssh -R 1080 server

I just realized I could solve this with two commands. On the laptop, establish a port with a tunnel back to the laptop:

ssh -R 10002:localhost:22 user_server@server

and on the server open a proxy, using that tunnel:

ssh -D 8080 -p 10002 user_laptop@localhost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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