ILi*_*ood 8 ssh selinux centos ssh-keys centos6
我正在尝试使用 SSH 连接到我自己的 CentOS 服务器;我可以用密码正常连接;我正在尝试使用我的公钥连接,但服务器不尝试公钥身份验证。我已按照CentOS wiki 中此页面上的所有说明进行操作,并验证了以下内容:
我正在运行 CentOS 6.0 或更高版本
我的 sshd_config 具有以下内容:
PermitRootLogin no
PubkeyAuthentication Yes
RSAAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)我在客户端主目录的 .ssh/ 文件夹中创建了一个私钥
ssh-keygen
)的全文在服务器主目录中的 .ssh/authorized_keys 文件中占一行。我在客户端和服务器上都设置了以下权限模式:
chmod 700 .ssh
chmod 600 .ssh/*
Run Code Online (Sandbox Code Playgroud)ILi*_*ood 13
根据CentOS 网站上的这个问题报告,这是由 SELinux 中的上游“功能”引起的;如果 SELinux 正在强制执行,它将阻止服务器使用公钥身份验证。没有迹象表明这种行为会在不久的将来改变。要查看此问题是否适用于您,请键入sestatus
并查看它是否将“当前模式”报告为enforcing
.
我知道两种解决方法。
setenforce 0
以立即更改策略,然后打开/etc/selinux/config
并确保SELINUX=permissive
.将文件恢复到正确的安全上下文:
restorecon -R -v ~$USER/.ssh
Run Code Online (Sandbox Code Playgroud)