Fel*_*lix 4 linux ssh amazon-web-services
我在亚马逊云中运行 Centos 机器。突然间,我无法通过 ssh 进入它。幸运的是,正在运行的 R Studio 包括运行 BASH shell 的能力。所以,我在 /var/log/boot.log 中看到 sshd 无法启动。
当我从命令行运行它时,sudo service sshd start我收到一个错误Starting sshd: /etc/ssh/sshd_config: Permission denied。我试图将 sshd_config 权限设置为 644 或 600 - 但我得到了同样的错误。我也试过sudo su -然后开始服务。
而且这不是 shell 本身的限制:我可以毫无问题地启动 httpd。
我什至不知道还能尝试什么......
小智 6
我遇到了同样的问题,感谢 Felix 的回答,我可以确认这也是一个 SELINUX 错误:
# grep "sshd_config" /var/log/audit/audit.log
...
type=AVC msg=audit(1585907328.579:143): avc: denied { read } for pid=1207 comm="sshd" name="sshd_config" dev="dm-0" ino=443439 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:unlabeled_t:s0 tclass=file
...
Run Code Online (Sandbox Code Playgroud)
然后我能够通过恢复默认上下文来解决错误:
# restorecon /etc/ssh/sshd_config
Run Code Online (Sandbox Code Playgroud)
这样就不需要禁用 SELINUX。
这就是发生的事情......图像有问题(具体信息: https: //bugzilla.redhat.com/show_bug.cgi?id = 956531)。因此,作为故障排除的一部分,我将 EBS 驱动器安装在另一台计算机上,并“清理”了 sshd_config。导致SELINUX拒绝访问该文件,错误信息是SELINUX引起的;不是通过文件权限。当我禁用 SELINUX 后,sshd 就正常了。
世界得救了:)