Port forwarding with SSH

April 14, 2010

You can port forward with SSH with the following command:

ssh -L 1234:localhost:1234 user@example.com

This will map port 1234 on your local system with port 1234 on the remote system (example.com). If example.com has access to another system that you dont have on your local system, you can port map from your local system to that remote system through the example.com system:

ssh -L 1234: user@example.com

Now port 1234 is mapped to 1234 on the system with ip address

You can even tunnel twice (or more times) by port mapping port 22 onto the interim systems then mapping the final system to the local system.

ssh -L 22: user@example.com

You can now map port 1234 to which is only visible to using

ssh -L 1234: user@localhost


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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: