1 minute, 0 seconds

Some internal servers are not available outside company network, and we can use the ~/.ssh/config file to make an optional jump through some servers which are available from the internet.

This is how:

Explanation

The "Match Host" line is a condition which is true if "nc" cannot start a connection to "internal.only.server" and therefore executes the line(s) beneath it.

What is this good for?

My use-case was git related. I use ssh to use my git repositories. When I am in the company network (either locally or by VPN) I do not need extra hoops to talk to the internal server. When I am working outside company network (for example from HomeOffice), I need to jump through an externally available server (or multiple) to make the connection work. (Without having the need to stay in the VPN).

cat ~/.ssh/config

Host internal.only.server
        HostName internal.only.server

Match Host internal.only.server !Exec "nc -w1 %h %p < /dev/null"
        ProxyJump server.available.from.the.internet