无法通过Ansible SSH连接到服务器。
$ ansible myserver -m ping -u username\@company.com -vvvvv
Using /etc/ansible/ansible.cfg as config file
Loaded callback minimal of type stdout, v2.0
<ip.ad.dr.es> ESTABLISH SSH CONNECTION FOR USER: username@company.com
<ip.ad.dr.es> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<ip.ad.dr.es> SSH: ANSIBLE_REMOTE_PORT/remote_port/ansible_port set: (-o)(Port=22)
<ip.ad.dr.es> SSH: ANSIBLE_PRIVATE_KEY_FILE/private_key_file/ansible_ssh_private_key_file set: (-o)(IdentityFile="/Users/username/.ssh/id_rsa")
<ip.ad.dr.es> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<ip.ad.dr.es> SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User=username@company.com)
<ip.ad.dr.es> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<ip.ad.dr.es> SSH: PlayContext set ssh_common_args: ()
<ip.ad.dr.es> SSH: PlayContext set ssh_extra_args: (-A)
<ip.ad.dr.es> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/Users/username/.ansible/cp/ansible-ssh-%h-%p-%r)
<ip.ad.dr.es> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o 'IdentityFile="/Users/username/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=username@company.com -o ConnectTimeout=10 -o ControlPath=/Users/username/.ansible/cp/ansible-ssh-%h-%p-%r ip.ad.dr.es '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1469804843.87-104204648028091 `" && echo ansible-tmp-1469804843.87-104204648028091="` echo $HOME/.ansible/tmp/ansible-tmp-1469804843.87-104204648028091 `" ) && sleep 0'"'"''
ip.ad.dr.es | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh.",
"unreachable": true
}
可以通过从我的Mac手动执行SSH来登录同一台服务器。
ssh -p 22 -A -i ~/.ssh/id_rsa username\@company.com@ip.ad.dr.es -X -C
有关如何进一步排除故障的任何想法?
在此服务器上查找/var/log/auth.log,但未找到该文件。不确定要查看哪个其他文件以查看正在发生的事情。
编辑#1: 也这样做了 -
ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)(-o)(ForwardAgent=yes)
即。将forwardAgent = yes添加到ssh_args,并删除了--ssh-extra-args =“ - A”。这也没有帮助。
答案 0 :(得分:0)
请参阅有关ControlPath的评论太长。这个页面 - http://docs.ansible.com/ansible/intro_configuration.html#control-path - 有修复。