因为公司的服务器连接是通过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下即可。

最新文章

  1. LeetCode 359 Logger Rate Limiter
  2. 【poj1041】 John's trip
  3. ffmpeg - libavutil/attribute.h
  4. 使用git推送代码到开源中国以及IDEA环境下使用git
  5. SVN服务器配置实战
  6. 【LEETCODE OJ】Single Number II
  7. HDU5427
  8. 如何在mac上安装composer(How to install composer on the Mac)
  9. hdu 5745 La Vie en rose DP + bitset优化
  10. HR(人事管理)
  11. A real ROCA using Bootstrap, jQuery, Thymeleaf, Spring HATEOAS and Spring MVC
  12. [记录]使用setTimeout实现不同时间进行切换文本的颜色
  13. 计算json的和
  14. JS线程模型&Web Worker
  15. ASP.Net用jQuery ajax实现页面局部刷新
  16. Jexus web server V5.6.1正式公布
  17. 解决 jQuery.UI.Resizable aspectRatio在init后无法重新设置
  18. spring 动态创建数据源
  19. Java操作符真的简单到易如反掌?
  20. codeforces#1011C. Fly (二分,注意精度)

热门文章

  1. JSTL之c:set
  2. asp.net core后台系统登录的快速构建
  3. Vue路由vue-router
  4. Java并发/多线程系列——线程安全篇(1)
  5. 用python的TK模块实现猜成语游戏(附源码)
  6. jdbc与mybatis区别
  7. [js高手之路] javascript面向对象写法与应用
  8. I/P/B/SI/SP帧和PTS/DTS的关系
  9. C语言判断电脑的大、小端机
  10. yii2-swiftmailer入门