目标机 mysql
需要使用 192.168.13.44:1022
机器进行跳转才能登录,想在 ansible
中自动进行跳转,查阅了资料,按以下参数进行配置无效, 不清楚是没配置对还是咋的了:
# inventory [mysql] ansible_host=10.9.13.22 ansible_ssh_user=root ansible_ssh_pass="admin&*()" [mysql:vars] ansible_ssh_common_args='-o ProxyCommand="sshpass -p passwork ssh -W %h:%p -q [email protected]:1022"'
# 测试指令 ansible myql -m ping
# 执行结果 mysql | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: kex_exchange_identification: Connection closed by remote host", "unreachable": true }
请教下各位
通过 ssh -p 10022 ...
的方式,直接连接还不是行,需要先手动 ssh
登录一遍 192.168.13.44
生成 known_hosts
,然后 ansible
就能自动使用代理登录了,但不清楚为啥要不会自动登录中转机自动生成 known_hosts
# inventory mysql:vars] ansible_ssh_common_args='-o ProxyCommand="sshpass -p passwork ssh -p 10022 -W %h:%p -q [email protected]"'
1 NessajCN 2021-05-31 14:57:01 +08:00 via Android ssh 命令那个 root@ip 后面不能跟:端口 |
![]() | 4 css3 OP @NessajCN 改成这样也不行: ansible_ssh_common_args='-o ProxyCommand="sshpass -p passwork ssh -p1022 -W %h:%p -q [email protected]"' |
![]() | 5 css3 OP -p1022 中间有空格的,回帖忘了加 |
![]() | 6 ry_wang 2021-05-31 22:32:13 +08:00 hostvar ansible_port |