---
title: "SSH登录时提示Read from socket failed: Connection reset by peer."
author: "AILIKES"
date: "2017-09-22T18:00:35Z"
tags: []
categories: ["操作系统"]
slug: "ssh-read-from-socket-failed-connection-reset-by-peer"
draft: false
lastmod: "2017-09-22T18:00:35Z"
id: 2394173
url: "https://ailikes.iteye.com/blog/2394173"
---

首先查看日志   
tail -f /var/log/auth.log   
添加参数 -v 获得更详细的连接信息   
ssh user@computerB -v   
1.如果是 rsa and dsa keys 丢失产生的问题, 可以通过下面的方式进行修复:   
ssh-keygen -t rsa1 -f /etc/ssh/ssh\_host\_rsa\_key   
ssh-keygen -t dsa  -f /etc/ssh/ssh\_host\_dsa\_key

 

2./etc/ssh文件夹的权限问题，执行下面的操作更改权限：

```
# cd /etc/ssh
# chmod 0644 *
# chmod 0600 ssh_host_dsa_key ssh_host_rsa_key
```

再重新启动sshd服务，复制成功，并且可以ssh登录。

 

打开centos系统，使用root登录。在命令行中执行

```
#service sshd status
```

- 1

检查ssh服务是否启动。   
如果ssh没有启动   
使用如下命令进行启动

```
#service sshd start
```

- 1

或者

```
#/etc/init.d/sshd start
```

- 1

PS:centos设置ssh开机启动，在命令行中执行

```
#chkconfig --add sshd
#chkconfig sshd on
```