ssh分發秘鑰時出現錯誤“Permission denied (publickey,gssapi-keyex,gssapi-with-mic)”


因為公司的服務器連接是通過xshell公鑰和密碼連接的,今天在ssh分發秘鑰的時候出現了,下面的錯誤:

 

[root@iZ2ze97cumk8opqm28h8Z .ssh]# ssh-copy-id -i /root/.ssh/id_dsa.pub "root@123.56.82.168 -p 52808"
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

  

於是上網上搜索,網上其他人提供的解決方案為:

(1)創建用戶: ansible

(2)修改sshd_config文件

# vi /etc/ssh/sshd_config    //開啟以下內容

HostKey /etc/ssh/ssh_host_rsa_key

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile      .ssh/authorized_keys

# /etc/init.d/sshd restart

(3)權限設置

# mkdir /home/ansible/.ssh

# chown -R ansible:ansible /home/ansible

# chmod 700 /home/ansible

# chmod 700 /home/ansible/.ssh

# chmod 644 /home/ansible/.ssh/authorized_keys  //公鑰文件的所有權限

# chmod 600 /home/ansible/.ssh/id_rsa        //私鑰文件的所有權限

### 可以測試遠程連接了……

 

 

但是經過的我的測試還是不行,於是經過一番排查,得出來結果

其中這兩項PubkeyAuthentication yes   和PasswordAuthentication no的值都要為yes,即公鑰認證和密碼認證都要為yes,因為我連接的方式是通過這兩種方式來連接的,

 

[root@iZ2ze97cgcumk8opq8h8Z .ssh]# egrep "PubkeyAuthentication" /etc/ssh/sshd_config
#PubkeyAuthentication yes
PubkeyAuthentication yes
[root@iZ2ze97cgcuopqm28h8Z .ssh]# egrep "PasswordAuthentication" /etc/ssh/sshd_config
PasswordAuthentication no

  

 

於是將PasswordAuthentication的no替換為yes,結果沒有出現那個錯誤了。但是密碼好像不對。額。

 

[root@iZ2ze97cgcumopqm28h8Z .ssh]# ssh-copy-id -i /root/.ssh/id_dsa.pub "root@123.56.82.168 -p 52808"
root@123.56.82.168's password: 
Permission denied, please try again.
root@123.56.82.168's password: 
Permission denied, please try again.
root@123.56.82.168's password: 

  結果:清空/root/.ssh/目錄下的known_hosts下即可。


免責聲明!

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



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