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

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

转载于:https://www.cnblogs.com/lvhanzhi/p/10440451.html

你可能感兴趣的:(运维)