两台机器传输秘钥问题的解决方法

因为公司的服务器连接是通过xshell公钥和密码连接的,今天在ssh分发秘钥的时候出现了,下面的错误:

 

1
2
[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,因为我连接的方式是通过这两种方式来连接的,

 

1
2
3
4
5
[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,结果没有出现那个错误了。但是密码好像不对。额。

 

1
2
3
4
5
6
[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:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值