Timeline for Can an .ssh/config Host have multiple HostName entries?
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 13 at 14:48 | comment | added | Testare |
Thank you everyone for this info! To get around the issue of there possibly being a 192.168.1.11, I just check if my public IP matches the one for the domain with Match Host example exec '[ "$(curl -4 icanhazip.com 2>/dev/null)" = "$(dig +short A my.no-ip.dynamic)" ]' for the LAN match block, and just Match Host example for the WAN block.
|
|
| Jul 16, 2018 at 21:21 | comment | added | Corey Ogburn |
So it turns out that ~/.ssh/config couldn't care less about indentation. Certain commands reset the scope, i.e. each new Host line says "previous lines were for the previous Host, the following lines are for this new Host." Turns out Match has the same "scope resetting" power as Host. To account for this, I replaced my Host line with Match Host mycomputer exec "nc -w 1 -z 192.168.X.X 22" and defined all the custom values for my local network. I then added a matching line except !exec and added all the values for when I'm off network. Now it works fine for all hosts.
|
|
| Jul 16, 2018 at 18:42 | comment | added | Corey Ogburn |
Yeah, using your Match exec... Match !exec is causing ssh'ing to other domains to trigger the Match !exec and rewrite the HostName.
|
|
| Jul 16, 2018 at 18:01 | comment | added | Corey Ogburn |
So I ran into an issue with this approach. I also run a site, say xyz.com, and when I tried to ssh xyz.com my Match exec "true" caught that and redirected me into my home server using my remote HostName. I will try with your exec but I think the same thing will happen.
|
|
| Jul 11, 2018 at 18:38 | comment | added | steeldriver |
@CoreyOgburn ah yes I was trying to think of a nicer way to do the alternate condition (pity Match doesn't have an Else)
|
|
| Jul 11, 2018 at 18:36 | comment | added | Corey Ogburn |
I did have to add a -w 1 or else nc seemed to wait forever. What could be simpler is the second Match can Match exec "true" because if the first match failed, just blindly try the second choice.
|
|
| Jul 11, 2018 at 17:14 | history | answered | steeldriver | CC BY-SA 4.0 |