Tunneling SSH

There are lots of times when you don't have a direct connection to a machine you want to work with. A way to make that connection is to create a tunnel through an SSH connection to a middle box. There are two ways to do this. The first is directly on the command line:

ssh -N -n -L 12345:host1:2345 host2

This command makes an ssh connection to host2. It then creates a tunnel from your current host, on port 12345, out to port 2345 on host 1.  This way you can connect to port 12345 on the current host and you get tunneled out through host2 to port 2345 on host1.

Hope this is handy.  Let me know how you use this.

No comments:

Post a Comment