Ubuntu 16.04.2 - 重启后 ssh 立即被对端重置连接

Ubuntu 16.04.2 - 重启后 ssh 立即被对端重置连接

在重启之前,我能够通过 ssh 连接到 Ubuntu 16.04.2 服务器。因此,在重启之后,我尝试使用 ssh,但失败并显示消息ssh_exchange_identification: read: Connection reset by peer

奇怪的是,等待 10 分钟左右后,我就可以 ssh 到服务器了。有时间锁吗?如果有,如何重置?


以下是我在服务器上的配置:

  • sshd: ALL在 /etc/hosts.allow

  • /etc/hosts.deny 中为空

  • 防火墙处于非活动状态ufw status Status: inactive

  • root使用公钥ssh 到服务器

  • 启用以下/etc/ssh/sshd_config

    允许无密码登录

    公钥认证 是

    StrictModes 没有

    密码验证 是

  • 在 /root/.ssh/config 中我有以下内容:

    主持人 *

    StrictHostKeyChecking 否

  • 客户端的公钥在服务器中/root/.ssh/authorized_keys


详细日志在这里: ssh -vvv [email protected] OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /root/.ssh/config debug1: /root/.ssh/config line 6: Applying options for * debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: resolving "192.168.0.100" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to 192.168.0.100 [192.168.0.100] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 ssh_exchange_identification: read: Connection reset by peer

谢谢你!

答案1

我解决问题的方法是进入主机并运行一些命令。

sudo mkdir /var/run/sshd
sudo chmod 755 -R /var/run/sshd
sudo service ssh restart

之后我就连接到了机器。

相关内容