问题原文
原帖链接 · Jeff Widman · CC BY-SA 3.0
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?
社区高分解答
原帖链接 · mbrandeis · CC BY-SA 3.0
I add a fake suffix to the hostname with different proxy hosts
Host *.dc1
ProxyCommand ssh -q %r@dc1 -W %h:%p
Host *.dc2
ProxyCommand ssh -q %r@dc2 -W %h:%p
Then do something like ssh server1.dc1 and it will use the proxy host.
You can add Host entries for custom settings like this:
Host server1.*
User jeff
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
