How to specify multiple HostName/Port combinations in .ssh/config

Posted by leoluk on Server Fault See other posts from Server Fault or by leoluk
Published on 2012-06-22T08:28:25Z Indexed on 2012/06/22 9:17 UTC
Read the original article Hit count: 220

Filed under:

I have multiple notebooks and workstations which pull and push from multiple Mercurial repositories on a central server. I usually use .ssh/config to set an alias:

Host repo-server
HostName server.somedomain
User user143
IdentityOnly yes
IdentityFile ~/hgkey
Port 156

... and some more options, you get the idea. I can then simply do a hg push ssh://repo-server//hgroot/someproject on every local repository, and I can change the server address and port in one place.

For workstations, this works fine, but the notebooks can access the server either from inside the network or from outside, using a different address and a different port. Is there any way I can specify multiple HostName/Port combinations so that SSH automatically tries them in order? This way, the users could push and pull without having to care about the correct address.

(of course, using a VPN would be the most correct solution)

© Server Fault or respective owner

Related posts about ssh