pavement

SSH, forwarding ports over

From FreeBSDwiki
Jump to: navigation, search

If you have SSH access to a remote machine, you can use it as a quick-and-dirty way to encrypt-and-tunnel other traffic to that machine.

For example, let's say a remote machine you have SSH access to is running an rsync daemon, but you're on the wrong side of a firewall from it. You can set up an SSH tunnel to forward the local port 8730 to the remote port 873 like so:

me@box:~ ssh -f user@remotemachine -L 8730:remotemachine:873 -N

The -f tells ssh to go into the background just before it executes the command. This is followed by the username and server you are logging into. The -L 8730:remote:873 is in the form of -L local-port:remote-host:remote-port. The -N instructs OpenSSH to not execute a command on the remote system.

After running this command, you're ready to access the remote port 873 by way of local port 8730:

me@box:~ rsync --port=8730 localhost::
remote_share
another_remote_share
yet_another_remote_share
Personal tools