Ansible如何通过跳板机连接目标机器
Ansible如何通过跳板机连接目标机器
修改本地机器ssh的配置文件~/.ssh/config
没有就手动创建一个
本地IP: 192.255.235.20
# 方法一
Host bastion
HostName 192.255.235.63 # 跳板机IP
BatchMode yes
User ubuntu
Host prod1
HostName 172.16.105.45
ServerAliveInterval 60
TCPKeepAlive yes
IdentityFile ~/.ssh/keys/bastion_id_rsa # 跳板机上的 免密 文件
ProxyCommand ssh bastion 'nc -w 14400 %h %p' # or ProxyCommand ssh -W %h:%p bastion
User ubuntu
Port 22
# 方法二
Host prod2
HostName 150.138.xx.xxx
IdentityFile ~/.ssh/id_rsa # 跳板机上的 免密 文件
ProxyCommand ssh -qaY -i ~/.ssh/id_rsa -p 22 跳板机用户@跳板机IP 'nc -w 14400ms %h %p'
Port 10666
User root测试
另一种方式
Last updated