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