我想学习可靠,并且遵循o'riley Ansible Up和正在运行的书。错误:无法通过ssh连接到主机
在本书的入门部分,它要求我安装ansible,VirtualBox和流浪者,然后通过CLI运行:
vagrant init ubuntu/trusty64
vagrant up
之后我可以通过无业游民SSH或通过ssh到VM:
ssh [email protected] -p 2222 -i /Users/XXX/playbooks/.vagrant/machines/default/virtualbox/private_key
接下来是创建hosts文件看起来像这样:
testserver ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 \ ansible_ssh_user=vagrant \ ansible_ssh_private_key_file=.vagrant/machines/default/virtualbox/private_key
最后运行此命令:
ansible TESTSERVER -i主机-m平
这让我:
testserver | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh.",
"unreachable": true
}
添加-vvv打动了我:
No config file found; using defaults
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o Port=2222 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/Users/XXX/.ansible/cp/ansible-ssh-%h-%p-%r 127.0.0.1 '/bin/sh -c '"'"'(umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468541275.7-255802522359895 `" && echo ansible-tmp-1468541275.7-255802522359895="` echo $HOME/.ansible/tmp/ansible-tmp-1468541275.7-255802522359895 `") && sleep 0'"'"''
testserver | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh.",
"unreachable": true
}
我试图修改ansible_ssh_private_key_file hosts文件指向私钥的完整路径,但仍不起作用:
ansible testserver -i hosts -m ping -vvv
No config file found; using defaults
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o Port=2222 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/Users/XXX/.ansible/cp/ansible-ssh-%h-%p-%r 127.0.0.1 '/bin/sh -c '"'"'(umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468541370.61-137685863794569 `" && echo ansible-tmp-1468541370.61-137685863794569="` echo $HOME/.ansible/tmp/ansible-tmp-1468541370.61-137685863794569 `") && sleep 0'"'"''
testserver | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh.",
"unreachable": true
}
这是我的Ansible版本:
ansible --version ansible 2.1.0.0 配置文件= 配置模块搜索路径=默认W/O覆盖
任何人有任何想法,为什么ansible ISN连接到我的流浪VM?
如果你需要帮助,你需要用格式清理你的问题。 – Rob
ctrl-k突出显示您的代码。 –
非常感谢你Rob帮助编辑!我还没有用SO编辑器。 – user2221830