SSH Tunneling handy one-liners

Published on — Filed under protip

Edit: If you have all the ssh keys and hosts properly set up, you can just do ssh -t intermediary_host ssh -t target_host

If you need SSH access to a machine that's either behind a NAT or in a network ran by a paranoid sysadmin, you'll need a third machine with public SSH access (hereby referred to as intermediary).

At the target machine (the one you can't access directly via SSH) run:

$ ssh -v -R 12345: user@intermediary_host

Then SSH to the intermediary and run:

ssh -v user@ -p 12345

Et voilà! You can ditch the -v flag to avoid verbose output.