更新时间:2023-02-02 17:27:56
鉴于您没有将 Paramiko 用于 ssh (transport = ssh
),Ansible 将完全使用您的 ~/.ssh/config
.因此,您可以在 ssh 配置中全局定义所有连接规则.
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