search by tags

for the user

adventures into the land of the command line

persistent ssh tunnels

on a daily basis, i usually have to log in and out of a bunch of remote hosts, which are reachable by going thru a jumphost. when i first started, i would use putty to log into a jumphost, then i would ssh to the remote server from there. but after a while, i started becoming really impatient, especially when trying to copy files over, as i’d have to do everything twice. then i discovered tunneling. the idea is to create a connection to the jumphost from your localhost, that is always up, and then you can go directly to the remote hosts from your localhost, thru this tunnel. to do it with ssh, its just a simple

$ ssh -f -N jumphost -D port

where ‘jumphost’ is the address of the host you want to tunnel thru, and 'port’ is the port on your localhost you want to forward. the -f command tells ssh to run in the background so you can continue to do other things, and -N is for not executing remote commands

this ssh connection will be up in the background until you kill it, or unplug your network connection. i haven’t found a way to cleanly disconnect yet though :/