大网数据广告活动
服务器运维问答

starting sshd: /etc/ssh/sshd_config: permission denied

· 52CE 我爱测

I am running a Centos machine in Amazon cloud. Suddenly, I can't ssh into it. Fortunately, there is R Studio running that includes an ability to run BASH shell. So, I see in /var/log/boot.log that sshd failed to start. When I run…

问题原文

原帖链接 · Felix · CC BY-SA 3.0

I am running a Centos machine in Amazon cloud. Suddenly, I can't ssh into it. Fortunately, there is R Studio running that includes an ability to run BASH shell. So, I see in /var/log/boot.log that sshd failed to start.

When I run it from the command line sudo service sshd start I get an error that Starting sshd: /etc/ssh/sshd_config: Permission denied. I tried to set sshd_config permissions to either 644 or 600 - but I get the same error. Also I tried sudo su - and then start service.

And it is not the limitation of the shell itself: I can start httpd without any problems.

I don't even know what else to try...

社区高分解答

原帖链接 · Mike Perdide · CC BY-SA 4.0

I was faced with the same issue, and thanks to Felix answer, I could confirm that it was also an SELINUX error :

# 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
...

I was then able to solve the error by restoring the default contexts:

# restorecon /etc/ssh/sshd_config

That way SELINUX didn't need to be disabled.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-08-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。