Here's the problem: I'm trying to SSH into a system that is accessible from at least 3 different networkssometimes directly, sometimes via a proxyat different times.Connecting directly is far faster and more reliable than connecting via an intermediate host, which is again far faster and more reliable than connecting over the general internet, so I would like SSH to attempt to connect in 3 different ways in a prioritized fashion, picking the first that succeeds.They're all the same machine, obviously, so I don't want to keep having to manually choose between 3 different aliases depending on where I'm connecting from.However, I can't find any mechanism for solving this. Is it possible to do this at all, or no?  If not, what do people generally do in such a situation?
How to use the same SSH alias with multiple host addresses/ports/etc.?
ssh;alias;openssh
Do not use aliases for ssh connections! Use a proper ssh_config in ~/.ssh/config. It has some truly powerful features.Lets say you can identify in which network you are. For example using your IP, which can be pulled for example using hostname -I. So lets write some configuration:# in network1 I am getting ip from 10.168.*.* and I need to connect through proxyMatch Host myalias Exec hostname -I | grep 10\.168\.  Hostname real-host-IP  ProxyCommand ssh -W %h:%p proxy-server# in network2 I am getting IP from 192.168.*.* and I do not need a proxyMatch Host myalias Exec hostname -I | grep 192\.168\.  Hostname real-host-IP# in network3 I am getting something elseI believe you got the point ...