Note to self: NAT'd SSH connections

At our company, we have to SSH into a client server via port forwarding on their gateway, like this:

:::shell
ssh gateway -l root -p 1349

Which is, of course, quite troublesome.

Fortunately, SSH (in combination with netcat) can be configured to work around this. You can even make a pretty “alias” for that connection.

Add the following lines to your .ssh/config file:

Host my_alias
    ProxyCommand nc gateway 1349

Now, you can simply connect to the NAT’d server like this:

ssh root@my_alias

Done!