我尝试使用ansible连接到服务器。我用openssh安装了ubuntu服务器。我在服务器上添加公钥,当我尝试使用ssh连接到服务器时,它可以工作:
ssh ubuntu@92.168.0.14
所以我创建了一个ansible清单文件hosts
[dbservers]
192.16.0.14 ansible_ssh_port=22 ansible_ssh_user=ubuntu
然后我尝试运行命令:
ansible all -i hosts -m ping -vvvv
但是当我运行它时会出现错误:
<192.16.0.14> ESTABLISH CONNECTION FOR USER: ubuntu
<192.16.0.14> REMOTE_MODULE ping
<192.16.0.14> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/karol/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'IdentityFile=/home/karol/.ssh/id_rsa', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=ubuntu', '-o', 'ConnectTimeout=10', '192.16.0.14', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1431369235.84-48071922815331 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1431369235.84-48071922815331 && echo $HOME/.ansible/tmp/ansible-tmp-1431369235.84-48071922815331'"]
192.16.0.14 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/karol/.ansible/cp/ansible-ssh-192.16.0.14-22-ubuntu" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.16.0.14 [192.16.0.14] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 192.16.0.14 port 22: Connection timed out
ssh: connect to host 192.16.0.14 port 22: Connection timed out
我使用相同的身份文件,为什么ansible无法连接到服务器?
答案 0 :(得分:0)
也许,麻烦就在这里:
ubuntu@**92.168.0.14**
[dbservers]
**192.16**.0.14 ansible_ssh_port=22 ansible_ssh_user=ubuntu
以下是具有不同fors八位字节的不同ip地址: 92.168和192.16