Wiki‎ > ‎

SSH Tunneling between R1 and savor

posted Oct 18, 2011, 10:03 AM by Dong Xu
Simplest form:
ssh user@host -L <in port>:<destination>:<out port>
ssh user@host -R <in port>:<destination>:<out port>

Using L will forward any connections to localhost through the ssh tunnel out of the host to where ever destination points on the out port. The in and out ports don't have to match. R will do the opposite, any connects to the remote host, usually only localhost only, will be brought back to the local host and sent to destination on the out port. On Linux the in port has to be greater than 1024 most of the time as 0 to 1024 are privileged.

Examples:

ssh cocoa.boisestate.edu -L 12345:r1.boisestate.edu:22 Connect to cocoa opening a tunnel that you can use to ssh directly to r1.
ssh r1.boisestate.edu -R 12345:savor.boisestate.edu:22 Connect to r1 opening a tunnel back to cocoa that points to savor.

Once you have those you can connect to them in a second terminal by: ssh localhost -p 12345 or scp -P 12345 file localhost:file
Comments