ansible的Q&A:Failed to connect to the host via ssh: ssh_exchange_identification和Authentication or per

本文档记录ansible使用中遇到的错误及解决办法

 问题一:

 

[root@host-10-1-241-158 logs]# ssh 10.1.241.161

ssh_exchange_identification: read: Connection reset by peer

ips10.1.241.159 | UNREACHABLE! => {

    "changed": false,

    "msg": "Failed to connect to the host via ssh: ssh_exchange_identification: read: Connection reset by peer\r\n",

    "unreachable": true

}

[root@host-10-1-241-158 logs]# ansible root10.1.241.161   -m shell  -a 'pwd'

root10.1.241.161 | FAILED | rc=0 >>

MODULE FAILURE

 

[root@host-10-1-241-158 logs]# ansible   ips10.1.241.161    -m shell  -a 'pwd'

ips10.1.241.161 | UNREACHABLE! => {

    "changed": false,

    "msg": "Authentication failure.",

    "unreachable": true

}

 

 

定位是因为:

10.1.241.161主机上

vi /etc/hosts.deny

有sshd,sftp,telnet,ftp: 10.1.241.158

如何解除/etc/hosts.deny

161上执行:

[root@host-10-1-241-161 ~]# service denyhosts stop

sent DenyHosts SIGTERM

vi /etc/hosts.deny中,删除对应的主机信息

 

Authentication failure."报错是因为:/etc/ansible/hosts的用户,在被连接主机上没有sudo权限:

vi /etc/sudoers

添加对应权限即可。

 

Ansible报错:"Failed to connect to the host via ssh: ssh_exchange_identification: read: Connection reset by peer\r\n"

ips10.1.241.159 | UNREACHABLE! => {

    "changed": false,

    "msg": "Failed to connect to the host via ssh: ssh_exchange_identification: read: Connection reset by peer\r\n",

    "unreachable": true

}

 

解决方法:

service denyhosts stop

cat /dev/null  >/etc/hosts.deny

问题二:

ansible执行报错:Authentication or permission failure

+ ansible IPSMachines -m shell -a 'pwd'

root10.1.235.28 | UNREACHABLE! => {

    "changed": false,

    "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1536806706.35-106960540689166 `\" && echo ansible-tmp-1536806706.35-106960540689166=\"` echo $HOME/.ansible/tmp/ansible-tmp-1536806706.35-106960540689166 `\" ), exited with result 1",

    "unreachable": true

}

root10.1.235.27 | UNREACHABLE! => {

    "changed": false,

    "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1536806706.35-1073010745840 `\" && echo ansible-tmp-1536806706.35-1073010745840=\"` echo $HOME/.ansible/tmp/ansible-tmp-1536806706.35-1073010745840 `\" ), exited with result 1",

    "unreachable": true

}

 

 

【定位】原因是,被登录主机上的ansible用户的密码不对了;或者密码过期了;修改下对应用户的密码为正确密码即可;

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值