更新时间:2023-02-02 17:45:42
Given that you do not use Paramiko for ssh (transport = ssh
), Ansible will fully use your ~/.ssh/config
. Therefore you can globally define all connection rules in your ssh configuration.
如果出于某种原因您希望Ansible不使用默认的ssh配置,而是提供单独的配置,则可以在ansible.cfg
中定义:
If for some reason you want Ansible to not use your default ssh config but provide an separate configuration, you can define this in your ansible.cfg
:
[ssh_connection]
ssh_args= -F "/path/to/ssh/config/specifically/for/ansible"
然后在您的ssh配置中设置连接规则.坚持您的示例:
In your ssh config then set up the connection rules. To stick with your example:
Host HostA
HostName real-host-name-A.com
Host HostB
HostName real-host-name-B.com
ProxyCommand ssh -q HostA nc %h %p
Host HostC
HostName real-host-name-C.com
ProxyCommand ssh -q HostB nc %h %p