How can I trick ssh to connect using different configurations based on current location?

Posted by Sorin Sbarnea on Server Fault See other posts from Server Fault or by Sorin Sbarnea
Published on 2012-04-07T23:09:19Z Indexed on 2012/04/08 17:34 UTC
Read the original article Hit count: 199

Filed under:

Here is the following use case: wanting to ssh server1 in 3 scenarios:

  • server1 is on current network, go for it
  • server1 is not on current network and you need to use a gateway (gw1) to access it, not a big problem as you can use ~/.ssh/config to define tunnelling for this
  • you are on a network that does not allow you to access the first gw1, so you'll use gw2 for that.

Desired outcome: be able to use the same command and be able to connect to the server.

© Server Fault or respective owner

Related posts about ssh