1. 程式人生 > >Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password

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

chan conn roo ansible 命令 password msg 1.7 mission

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

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