SSH ProxyCommand
May 04 2016
1 minute read

Problem : Some servers in my university are beind firewall and it is difficult to ssh to those servers as I always use a VPN service on my primary laptop. To be able to ssh, one must be inside the university or use the university VPN.

It is possible to ssh to a public facing server and go through that to any server inside of the unversity. It is almost like running a campus VPN, but it is a 2 step process. So in search for a better solution I found this:

Host <host-alias>
        User <username>
        Hostname <hostname>
        ProxyCommand ssh <hostname:port for public facing server> exec nc %h %p
        IdentityFile <private-key>
        Port 22
        Compression yes
        CompressionLevel 6

This configuration allows you to run nc on the public facing server and ssh directly to the server behind the firewall. Note that the magic happend in the 4th line of the configuratoin with ProxyCommand. Pretty neah eh?

Back to posts