ssh jump with ansible

1 – create the ssh config file contains the jump host

cat >> ~/.ssh/config <<EOF
PubKeyAuthentication yes
IdentityFile /path/to/your/private/key/id_rsa
StrictHostKeyChecking no

Host firewall
  HostName 200.221.50.3
  Port 2222
  User mickey
EOF

2 – add the host in the ansible inventory file

cat >>/etc/ansible/hosts <<EOF

internalHost ansible_host=192.168.0.7 ansible_user=root ansible_password=123456 ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q firewall"'
EOF

3 – test connection

ansible internalHost -m ping

Leave a comment