1. 返回错误信息
SSH服务器拒绝了用户密钥。请尝试其它用户密钥或者其它身份验证方法…
所选的用户密钥未在远程主机上注册。请再试一次…
(tmd)我Ubuntu能连接,为何这个Centos不行
2.解决问题
2.1 方法一(知乎老哥扯皮,搞半天也没成功,我是失败了,你可以试试)
**
#修改selinux的配置文件[root@localhost ~]# vim /etc/selinux/configSELINUX=enforcing #注释这行SELINUXTYPE=targeted #注释这行SELINUX=disabled #新增这行#之后需要重新启动服务器[root@localhost ~]# reboot[root@localhost ~]# /usr/sbin/sestatus -v #查看selinux的状态命令SELinux status: disabled# 关闭防火墙[root@localhost ~]# sudo -i[root@localhost ~]# iptables -F #清空防火墙配置[root@localhost ~]# /etc/init.d/iptables save #清空防火墙配置后,记得保存
2.2 解决了我的问题,我是centos系统
# 开启ssh远程登录[root@localhost ~]# vim /etc/ssh/sshd_config# 然后在无光标状态下 /PermitRootLogin 搜索PermitRootLogin yes # 默认为no,需要开启root用户访问改为yes
:wq 保存退出,重启ssh
systemctl restart sshd

3. SELINUX是啥
SELinux(Security-Enhanced Linux) 是美国国家安全局(NSA)对于强制访问控制的实现,是 Linux历史上最杰出的新安全子系统
SELinux共有3个状态
- enforcing (执行中)
- permissive (不执行但产生警告)
- disabled(关闭)
4.ssh -i key 执行时 Permissions 0644 for ‘你的.pem’ are too open 问题
// 解决办法chmod 600 你的密钥文件// 比如: chmod 600 ekko.pem
参考文献
https://blog.csdn.net/l18637220680/article/details/70231989
https://www.zhihu.com/question/35291523/answer/205691737
