在一次服务器上的项目复制移到另一台服务器上时,两台服务器都是linux的,因为乱给了etc下面的文件 chmod -R +xxx /etc/* 的权限,因为复制mysql的时候有该目录下的文件需要权限,所以就这样直接给了这个目录下全部文件的这个权限,结果ssh立刻不能访问了。
用 sshd -t 命令检查 发现
Permissions 0777 for '/etc/ssh/ssh_host_rsa_key' are too open 意思是说这个文件给的权限太高了,这样也是不行的,然后把所有的这样与ssh相关的文件权限改成
chmod 600 /etc/ssh/etc/ssh/ssh_host_rsa_key
这样,再运行 systemctl start sshd 就可以启动了。然后再试着远程连接就连上了
相关报错
执行 :systemclt status sshd.service 显示如下错误
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: activating Cauto-restart)(Result: exit-code) since Sun 2021-89-05 09: 30: 18 CST: 12s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 13561 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=1/FAILURE)
Main pid: 13561 (code=exited status=1/FAIlURE)
Sep 85 89: 30: 18 VM-8-16-centos sshd[13561]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sep B5 89: 30: 18 VM-9-16-centos sshd[13561]: Permissions 8644 for/etc/ssh/ssh_host_ed25519_key‘are too open
Sep 05 89: 30: 18 VM-0-16-centos sshd[13561]:It is required that your private key files are NoT accessible by others
Sep 05 89: 30: 18 VM-0-16-centos sshd[13561]: This private key will be ignored
Sep 85 89: 30: 18 UM-0-16-centos sshd[13561]: key_load_private: bad permissions
Sep 05 89: 30: 18 UM-0-16-centos sshd[13561]: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Sep 05 89: 30: 18 VM-8-16-centos sshd[13561]: sshd: no hostkeys available -- exiting
Sep 05 89: 30: 18 UM-0-16-centos system[1]: Failed to start OpenSSH server daemon
Sep 05 89: 30: 18 UM-0-16-centos systemd[1]: Unit sshd.service entered failed state
Sep 05 89: 36: 18 UM-0-16-centos systemd[1]: sshd.service failed
[root@VM-0-16-centos /]#