SecureCRT远程连接The remote system refused the connection问题
今天用SecureCRT远程连接Linux(Centos 7)时,连不上,报错The remote system refused the connection.
于是就百度,首先查看sshd服务有没有启动
只有ssh-agent,于是去启动sshd
执行如下命令
cd /etc/init.d
systemctl restart sshd.service
没有成功,报错
Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.
。
再使用这个命令journalctl -xe
看错误信息,具体报错信息如下。
[root@localhost ssh]# systemctl restart sshd.service Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details. [root@localhost ssh]# journalctl -xe 12月 05 10:45:01 localhost.localdomain sshd[11508]: Permissions 0715 for '/etc/ssh/ssh_host_rsa_key' are too open. 12月 05 10:45:01 localhost.localdomain sshd[11508]: It is required that your private key files are NOT accessible by others. 12月 05 10:45:01 localhost.localdomain sshd[11508]: This private key will be ignored. 12月 05 10:45:01 localhost.localdomain sshd[11508]: key_load_private: bad permissions 12月 05 10:45:01 localhost.localdomain sshd[11508]: Could not load host key: /etc/ssh/ssh_host_rsa_key 12月 05 10:45:01 localhost.localdomain sshd[11508]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12月 05 10:45:01 localhost.localdomain sshd[11508]: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ 12月 05 10:45:01 localhost.localdomain sshd[11508]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12月 05 10:45:01 localhost.localdomain sshd[11508]: Permissions 0715 for '/etc/ssh/ssh_host_ecdsa_key' are too open. 12月 05 10:45:01 localhost.localdomain sshd[11508]: It is required that your private key files are NOT accessible by others. 12月 05 10:45:01 localhost.localdomain sshd[11508]: This private key will be ignored. 12月 05 10:45:01 localhost.localdomain sshd[11508]: key_load_private: bad permissions 12月 05 10:45:01 localhost.localdomain sshd[11508]: Could not load host key: /etc/ssh/ssh_host_ecdsa_key 12月 05 10:45:01 localhost.localdomain systemd[1]: sshd.service: main process exited, code=exited, status=1/FAILURE 12月 05 10:45:01 localhost.localdomain sshd[11508]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12月 05 10:45:01 localhost.localdomain sshd[11508]: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ 12月 05 10:45:01 localhost.localdomain sshd[11508]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 12月 05 10:45:01 localhost.localdomain sshd[11508]: Permissions 0715 for '/etc/ssh/ssh_host_ed25519_key' are too open. 12月 05 10:45:01 localhost.localdomain sshd[11508]: It is required that your private key files are NOT accessible by others. 12月 05 10:45:01 localhost.localdomain sshd[11508]: This private key will be ignored. 12月 05 10:45:01 localhost.localdomain sshd[11508]: key_load_private: bad permissions 12月 05 10:45:01 localhost.localdomain sshd[11508]: Could not load host key: /etc/ssh/ssh_host_ed25519_key 12月 05 10:45:01 localhost.localdomain sshd[11508]: sshd: no hostkeys available -- exiting. 12月 05 10:45:01 localhost.localdomain systemd[1]: Failed to start OpenSSH server daemon. -- Subject: Unit sshd.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit sshd.service has failed. -- -- The result is failed. 12月 05 10:45:01 localhost.localdomain systemd[1]: Unit sshd.service entered failed state. 12月 05 10:45:01 localhost.localdomain systemd[1]: sshd.service failed. 12月 05 10:45:01 localhost.localdomain polkitd[7760]: Unregistered Authentication Agent for unix-process:11502:197209 (system bus name :1.14 lines 1492-1525/1525 (END)
看到很多Permissions
这个词,权限。
诸如;Permissions 0715 for '/etc/ssh/ssh_host_rsa_key' are too open.
key_load_private: bad permissions
的错,这是一些密钥文件,也就是说没有权限访问这几个文件,可我用的root啊也没权限,奇怪了。
那么我们看看这三个文件现在的权限是什么。切到/etc/ssh
下ll
查看,这三个文件的权限是755,感觉没啥问题啊。继续百度吧。
搜了好久,有篇博文说执行这个命令
chmod 600 /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key
也就是修改这个三个文件的权限为600
再执行systemctl restart sshd.service
重启sshd服务
再查看是否启动,果然起来了。
再用SecureCRT连接就连上了。
太曲折了。期间还执行了sudo yum install openssh-server
安装ssh服务,修改了ifcfg-eth0,centos没有这个文件只有ifcfg-ens33,不知有用没,还有查看端口的、/etc/ssh/sshd_config文件的Post是不是22等等。最后终于解决了。
说的再好,不如行动。不怕慢,就怕站。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?