Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password

Centos7.5 执行ansible命令报错

问题:

[root@m01 ~]# ansible servers -a "hostname" -i ./hosts -u root
172.16.1.7 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
    "unreachable": true
}
172.16.1.8 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", 
    "unreachable": true
}

原因:

之前测试的时候把家目录的权限给改了

解决方法:

把被控制端的密钥权限改成600
[root@web01 ~]# chmod -R 600 .
[root@m01 ~]# ansible servers -a "hostname" -i ./hosts 
172.16.1.7 | CHANGED | rc=0 >>
web01
posted @ 2019-02-26 21:51  吕涵之  阅读(8089)  评论(0编辑  收藏  举报