CentOS7使用ssh不能登录,报错:Read from socket failed: Connection reset by peer

使用xshell登录CentOS7,不能登录,使用另外一台Linux主机,telent 22端口是同的,ssh连接报以下错误:

Read from socket failed: Connection reset by peer

查看不能登录主机的日志

# cat /var/log/messages

Dec 15 19:38:27 localhost dbus-daemon: dbus[874]: [system] Successfully activated service ‘org.freedesktop.nm_dispatcher‘

Dec 15 19:38:27 localhost systemd: Started Network Manager Script Dispatcher Service.

Dec 15 19:38:27 localhost nm-dispatcher: Dispatching action ‘dhcp4-change‘ for eno16777736

Dec 15 19:38:33 localhost sshd[3125]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key

Dec 15 19:38:33 localhost sshd[3125]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key

Dec 15 19:38:33 localhost sshd[3125]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key

Dec 15 19:39:42 localhost sshd[3127]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key

Dec 15 19:39:42 localhost sshd[3127]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key

Dec 15 19:39:42 localhost sshd[3127]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key

Dec 15 19:44:56 localhost sshd[3136]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key

Dec 15 19:44:56 localhost sshd[3136]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key

Dec 15 19:47:03 localhost sshd[3138]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key

Dec 15 19:47:03 localhost sshd[3138]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key

找到问题所在,用如下命令

ssh-keygen -t dsa -P ‘‘ -f  /etc/ssh/ssh_host_dsa_key

ssh-keygen -t rsa -P ‘‘ -f  /etc/ssh/ssh_host_rsa_key

分别把这两个密钥生成就可以正常启动和使用 ssh了 。到此问题就解决完了。

service ssh restart

重启下服务,这个时候就可以连接了。

总结:遇到问题,不要手足无措,首先看看系统提示和日志,好好分析以下。不行立马百度或Google。

时间: 2024-08-13 22:47:51

CentOS7使用ssh不能登录,报错:Read from socket failed: Connection reset by peer的相关文章

ssh远程的时候出现Read from socket failed: Connection reset by peer

原因:/etc/ssh/下没有ssh*key*文件 解决: ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key 然后再尝试远程连接,显示成功 或者 直接重启服务 systemctl restart sshd

SSH 错误解决案例1:Read from socket failed: Connection reset by peer

今天早上天天连接的开发机突然报出连接错误. 这个错误是SSH最常见错误,造成的原因也是千奇百怪(具体可goole),下面描述我的server的问题: 客户端报错 [[email protected]]# ssh 192.168.1.22 Read from socket failed: Connection reset by peer 换个机器连接也不行,尝试重启server端的sshd,thanks god, 报错了 [[email protected] ssh]# service sshd

友盟登录微信第三方登录报错解决linker command failed with exit code 1

:错误 Undefined symbols for architecture x86_64: "OBJC_CLASS$_UMSocialUtils", referenced from: objc-class-ref in libSocialWechat.a(UMSocialWechatHandler.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with ex

[未解决]报错:ssh_exchange_identification: read: Connection reset by peer

报错代码: ssh_exchange_identification: read: Connection reset by peer fatal: 无法读取远程仓库. 请确认您有正确的访问权限并且仓库存在. FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html 原文地址:https://www.cnblogs.com/hankleo/p/119

ssh远程报错ssh_exchange_identification: read: Connection reset by peer

ssh远程登录报错: [[email protected] ~]$ ssh     198.44.241.34 ssh_exchange_identification: read: Connection reset by peer 初步原因锁定: 1-服务器防火墙限定, 2-是否达到ssh的最大连接数,超过之后会服务器端会拒绝新的连接,直到有新的连接释放出来 3-/etc/hosts.allow和/etc/hosts.deny配置文件限定ip登录 解决方案: 1 firewall-cmd --l

解决spring+shiro cacheManager 登录报错

一.项目启动,登录报错 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource [spring-mvc.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'security

关于spring-data-mongodb用户名密码登录报错问题:Failed to authenticate to database

一.问题 1.spring-data-mongodb用户名密码登录报错问题:Failed to authenticate to database  org.springframework.data.mongodb.CannotGetMongoDbConnectionException: Failed to authenticate to database [ashop], username = [ashop], password = [g***********4] org.springframe

ssh启动报错:org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect

ssh项目启动报错: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect 一开始以为是数据库连接的事,后来发现是hibernate在实体对象映射数据库表的时候出的错 解决: 查看hibernate.jar包里的hibernate-mapping-3.0.dtd里的 <!DOCTYPE hibernate-mapping PUBLIC &qu

Laravel 项目登录报错:The MAC is invalid.

在 Laravel 项目完成部署到服务器.数据库导入成功后 后台登录报错: 谷歌一下,发现好些同样问题,看了看,有个很有意思: 我需要一个笑哭的表情来描述我现在的心情,clear artisan cache, clear composer cache, dump autoload, empty browser cahe -- still nothing.搞了这么一大串竟然是 still nothing. 好的,第一回抱着非常 happy 的心情调 Bug. 继续找,找啊找...... 咦,找到了