3 ms·
Jump hosts are fantastic! With a little bit of sed magic you can also setup wildcard jump hosts, eg: Host *-via-dc1 ProxyCommand ssh you@jump-01.ex
by itsjloh 6y ago
Jump hosts are fantastic! With a little bit of sed magic you can also setup wildcard jump hosts, eg:
Host *-via-dc1
ProxyCommand ssh you@jump-01.example.com nc $(echo %h | sed 's/-via-dc1$//') %p
I wrote about it ages ago here https://jloh.co/posts/dynamic-ssh-jump-hosts/ https://jloh.co/posts/dynamic-ssh-jump-hosts/
- Piskvorrr 6y agoWhoa! Now that's mighty useful, thanks! (Note that this works even without the ProxyJump option, but requires a sane netcat on the jumphost; older busyboxes only had a netcat)
- davb 6y agoThat's really smart! I'd maybe even reverse it, having: Host my-jump-host Hostname my-jump-host.mydomain.example User myuser Host my-jump-host-* User myuser ProxyCommand ssh my-jump-host nc $(echo %h | sed 's/^my-jump-host-//') %p This way, autocomplete in bash would work. Typing "ssh m<tab>", assuming m* doesn't match anything else, would suggest "ssh my-jump-host" (which I often ssh directly to anyway). Then just add "-myotherhost" so the whole sequence becomes "ssh m<tab><bs>-myotherhost". Not a huge saving but I'm lazy and like autocomplete in the shell.
- davidcollantes 6y agoLet's say all machines are named in the form "vm12345," but the jump server itself is also named in the same form. How would you go to include all vm in a wildcard, but the jump server itself?