I'm SSH'ing into multiple datacenters that are setup identically. Each datacenter has a jumpbox, and behind that there's access to various db servers etc.
It's a pain to manually specify entries for all these servers, when they're almost identical across datacenters, other than the jumpbox IP. So I'd like to set my .ssh/config
file so that I can type datacenter_name-server_behind_jumpbox
and have SSH grab the datacenter_name
off the front of the host (so that I can re-use it in the ProxyCommand
.
For example, if I want to access the Maria server in datacenter1, I'd create an SSH entry for the jumpbox called datacenter1
. Then for the Maria server behind it, I'd setup something like:
Host %dc%-maria Hostname maria User jeff ProxyCommand ssh -q -W %h:%p %dc
That way I only need to setup a single entry for each type of server that's located behind the jumpbox, and it automatically knows which datacenter jumpbox to hit.
Is something like this possible?
Host *-maria
), but there does not appear to be a way to capture the matching part of the hostname for use in the configuration.