If you need to use one SSH machine to jump over to other hosts, you know the drill. The easiest way is to simply edit
~/.ssh/config and add
Example file above essentially assumes you have your jump point at
192.168.0.1 and you are using it to get into machines in 192.168.1.0/24 network. To go into 192.168.1.100, you would simply use
SSH is then going to use it's config definitions to connect to tunnel machine first (
192.168.0.1) and then to make another connection from that machine to the final destination (
192.168.1.100). Easy enough.
However, what if we want names to be resolved too?
If you have DNS or those names defined on your jump point, all is ok. However, what if your jump point is not under your control or you are too lazy to keep
/etc/hosts up-to-date on both your local machine and the jump one?
Well, you will see the following error message:
ssh: Could not resolve hostname myremotehost.internal: Name or service not know
In that case, you will need
dig magic in
~/.ssh/config to do local IP resolve.
ProxyCommand ssh -W "[`dig +short %h`]:%p" tunnel
Example above will locally resolve all IPs for host names ending in
.internal before using the resolved IP on the jump host.
One thought to “Local Resolve of Proxied SSH Host Names”
thanks. very useful.