Is it possible to "automatically" configure ssh to use a gateway to connect to a remote machine based on the client's IP address or something in the likes?
Suppose I'm at my
laptop, which I can plug (via a wired connection) into the university network and have direct access to the
cluster.uni.edu, but if I'm at home, I must hop through the
gateway.uni.edu. So, to connect to the cluster from home, I can have my
~/.ssh/config like this:
Host cluster Host cluster.uni.edu ProxyCommand ssh -W %h:%p gateway.uni.edu
So I can just
ssh cluster and access it transparently hopping though the gateway. The downside is that if I'm plugged to the university network, I don't need to go through the gateway, so to avoid it I would have to do something like
Is it possible to set up this so ssh doesn't hop though the gateway it it's not needed? The criterion would be something like: If eth0 is connected and the IP is xxx.yyy.zzz.www, connect directly, otherwise use the gateway.
I think this might be a lot to ask from the configuration file and standard ssh options alone, but I would really like to avoid wrapper scripts. (Side note: I used LocalFowrard to do this kind of thing before I learned about
ssh -W because I didn't like the idea of using