) Always connect to 192.168.8.15 (this will work if I am already at the home network)
) Connect instead to devbox.harisund.com , if I am not within the home LAN
I have functional DNS at home, so I /always/ connect to the host name, wherever I am. Outside, away from home, the hostname resolves via
global DNS to my home's external IP. Inside, the name resolves to the internal IP.
I've seen, much less used, the "match" directives like this.Odd, I saw a lot of stackoverflow/unix stackoverflow questions where match was shown to be used this way with the _exec_ parameter.
I have the following set up in my ~/.ssh/config
match host devbox
compression yes
user hari
port 22
hostname 192.168.9.7
match originalhost devbox exec "~/.ssh/check_if_outside_home.sh"
hostname devbox.harisund.com
The idea is this -
) Always connect to 192.168.8.15 (this will work if I am already at the home network)
) Connect instead to devbox.harisund.com , if I am not within the home LAN
The logic behind this is to set defaults for the host (what you'retelling ssh to connect to) and then to re-set the hostname (the IP / DNS
That is fine, but the problem is I work from home. My laptop at home
connects to my employer's VPN, and DNS is subsequently routed through
my employer's VPN.
I do have split DNS setup so devbox.harisund.com resolves differently
when inside and outside my LAN. However, when on my employer's VPN, devbox.harisund.com resolves to _my external_ location, which is fine,
but I want to use my _internal_ address.
Odd, I saw a lot of stackoverflow/unix stackoverflow questions where
match was shown to be used this way with the _exec_ parameter.
That doesn't work. Once the hostname is set, SSH doesn't allow for a
reset of the hostname.
I have the following set up in my ~/.ssh/config
match host devbox
compression yes
user hari
port 22
hostname 192.168.9.7
match originalhost devbox exec "~/.ssh/check_if_outside_home.sh"
hostname devbox.harisund.com
The idea is this -
) Always connect to 192.168.8.15 (this will work if I am already at the home network)
) Connect instead to devbox.harisund.com , if I am not within the home LAN
I have functional DNS at home, so I /always/ connect to the host name, >wherever I am. Outside, away from home, the hostname resolves via
global DNS to my home's external IP. Inside, the name resolves to the >internal IP.
Split DNS is nearly never part of the solution, it's usually part of
the problem.
Then you're likely going to need to use the ProxyCommand wrapper script method I used.
I have mine locked down so that I have to go via the intermediate host.
the problem.Split DNS is nearly never part of the solution, it's usually part of
Yeah, more or less the same situation here. I go through my intermediate
host when "outside", so I have a similar setup.
No. Why do people post such messages anyway?
Just because split DNS doesn't work for you or you haven't configured
it properly, it doesn't imply it is never part of the solution.
For what it is worth, I posted the same question here https://unix.stackexchange.com/questions/474168/changing-hostname-more-than-once-via-ssh-config/474192#474192
and the answer there explains what I was looking for.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 393 |
Nodes: | 16 (2 / 14) |
Uptime: | 35:31:51 |
Calls: | 8,256 |
Files: | 13,132 |
Messages: | 5,877,407 |