SSH tunnel via another host


Admins at only allow ssh connections from whitelisted IP addresses. I can get my IP whitelisted, but my IP changes. A lot. And I also use several ISPs. So that’s pretty much a no-go for me.


SSH tunneling, of course!

We’ll need another host that has fix IP, let’s call it We also need an open port on to connect to from localhost. Let that be port 9999

After googling and reading the man pages, here is what I came up with. It requires one terminal window to keep the bridge up, but that is intentional, so that I can simply close the bridge when ssh is no longer required.

This opens the bridge:

localhost$ ssh -t "ssh -N -L $(echo $SSH_CLIENT | awk '{ print $1}')"

And this opens an SSH session via that bridge:

localhost$ ssh -p 9999

Note the username, it is for, not for


Todo, sorry 🙂