Reverse SSH Tunnel

Just finished playing around with reverse SSH tunnels with my buddy jkit so I figured I’d write this stuff down before I forgot.

ssh -nNT -R 1199:localhost:22 remotehost.com

This command looks pretty confusing if it’s the first time you’re seeing it (at least it did to me), but an intuitive way to phrase it would be: map port 1199 to localhost:22 on remotehost.com.

What’s the use case? For one, this command would allow you to SSH into a machine that is on a network behind a firewall or a router that you don’t have configuration access to. For example, if you’re on your laptop at a random cafe and you want to share a screen session on localhost, the other person would need SSH access.

What the above command would do is allow that person to SSH into your laptop from remotehost.com like so:

ssh -p1199 localhost

If you’re interested in other interesting use cases, check out localtunnel!

Advertisement

About Eugene Kashida
I tell browsers what to do.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.