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


通過ansible命令直接ping多台機器的網絡狀態,提示報錯:

 

 192.168.0.103 | UNREACHABLE! => {

    "changed": false, 

    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", 

    "unreachable": true

}

 

解決方式:單向的ssh驗證

ssh-keygen一路回車,主要是用來免密通信的

ssh-copy-id 192.168.0.103 需要輸入對應主節的root密碼

 

 再次驗證,成功:

 

 

 

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

通過ansible命令直接ping多台機器的網絡狀態,提示報錯

  1.  
    172.16.24.220 | UNREACHABLE! => {
  2.  
    "changed": false,
  3.  
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
  4.  
    "unreachable": true
  5.  
    }

解決方式:單向的ssh驗證

ssh-keygen一路回車,主要是用來免密通信的

ssh-copy-id 172.16.24.220 需要輸入對應主節的root密碼

  1.  
    [root@chm log] # ssh-keygen
  2.  
    Generating public/private rsa key pair.
  3.  
    Enter file in which to save the key (/root/.ssh/id_rsa):
  4.  
    Enter passphrase (empty for no passphrase):
  5.  
    Enter same passphrase again:
  6.  
    Your identification has been saved in /root/.ssh/id_rsa.
  7.  
    Your public key has been saved in /root/.ssh/id_rsa.pub.
  8.  
    The key fingerprint is:
  9.  
    7f:69:87:cf:28:fe:8b:19:55:a7:d0:c9:aa:6d:05:0c root@chm
  10.  
    The key 's randomart image is:
  11.  
    +--[ RSA 2048]----+
  12.  
    | E |
  13.  
    | o o . |
  14.  
    | + = .|
  15.  
    | = o |
  16.  
    | S o o |
  17.  
    | . + + |
  18.  
    | + B . |
  19.  
    | .B = |
  20.  
    | .+o+.o |
  21.  
    +-----------------+
  22.  
    [root@chm log]#
  23.  
    [root@chm log]# ssh-copy-id 172.16.24.220
  24.  
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  25.  
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
  26.  
    root@172.16.24.220's password:
  27.  
     
  28.  
    Number of key(s) added: 1
  29.  
     
  30.  
    Now try logging into the machine, with: "ssh '172.16.24.220'"
  31.  
    and check to make sure that only the key(s) you wanted were added.

再次驗證,成功

  1.  
    [root@chm log] # ansible 172.16.24.220 -m ping
  2.  
    172.16.24.220 | SUCCESS => {
  3.  
    "changed": false,
  4.  
    "failed": false,
  5.  
    "ping": "pong"
  6.  
    }

記錄一下,希望可以幫到更多人


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM