0

I'm talking about ssh_config(5). I wonder if you can define a config section or file based on the currently connected network.

I'm thinking about that scenario where the corporate firewall blocks port 22, but your home network doesn't. So, you have this configuration, but it's technically unnecessary at home.

Host github.com
  Hostname ssh.github.com
  Port 443

I'm sure this isn't the most interesting scenario, but I hope you can see what I'm getting at.

  • If the corporate firewall is blocking Github then you have bigger problems. :) – Michael Hampton Jun 15 '15 at 15:03
  • 1
    Simply duplicate that config using a name like github.com@stoopid ? – moebius_eye Jun 15 '15 at 15:09
  • @MichaelHampton Starbucks wifi blocks port 22 outbound, in general, too. – Anthony Mastrean Jun 15 '15 at 18:27
  • @moebius_eye You're suggesting to use a per-network Host rule in the same file then? That's interesting, but then I still have to remember to use it. – Anthony Mastrean Jun 15 '15 at 18:28
  • Really? They didn't when I was there last week! – Michael Hampton Jun 15 '15 at 18:36
0

One answer, hinted at in a comment, suggested simply to maintain per-network rules in the user SSH config file. For example...

Host foo@work
  Hostname ssh.foo.com
  Port 443

That would probably work where I have more control over the commands and entering the hostname, but git's push and pull commands read straight from the configured remotes.

I would have to configure work/home remotes as well, it seems :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.