You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法SSH连接远程服务器:ssh_exchange_identification连接重置问题求助

Troubleshooting SSH Connection Issues After Modifying /etc/ssh Config & Permissions

Let’s break down what’s happening here: your SSH client successfully establishes a TCP connection to port 22, but gets cut off immediately during the initial protocol exchange. This almost always points to the sshd service on the remote server failing to start properly (or crashing right after accepting the connection) — which lines up with the changes you made to sshd_config and /etc/ssh directory permissions.

Since you don’t have root access, your approach needs to focus on actionable steps you can take, even without elevated privileges:

1. Contact your server administrator first (this is your fastest fix)

Explain exactly what you modified:

  • You edited /etc/ssh/sshd_config (mention any specific settings you changed if you remember them)
  • You adjusted permissions on files/directories inside /etc/ssh
  • Share the full debug log from ssh username@remoteserverIP -vv and the PuTTY error message (Server unexpectedly closed network connection)

The admin can:

  • Check the sshd service status with systemctl status sshd (or service sshd status on older systems)
  • Review system logs (usually /var/log/auth.log or /var/log/secure) to see why sshd is failing to start or crashing
  • Revert invalid sshd_config changes or correct syntax errors
  • Fix critical permission issues in /etc/ssh (more on that below)

2. Understand the permission mistakes that likely caused this

Even without root, it’s helpful to know what correct permissions for /etc/ssh should look like, so you can guide the admin:

  • /etc/ssh directory: Must be 755 (drwxr-xr-x) — readable by all, writable only by root
  • sshd_config file: Should be 600 or 644 (root-only write access is mandatory; 600 is more secure)
  • Host key files (e.g., ssh_host_rsa_key, ssh_host_ecdsa_key): Must be 600 (rw-------) — no public read/write access allowed, otherwise sshd will refuse to initialize

If you set any of these to overly permissive values (like 777) or changed ownership away from root, sshd will fail to start.

3. Check for alternative server access methods

If you have another way to connect (e.g., a web-based console through your hosting provider, or a separate user account with sudo access), use that to revert your changes:

  • If you have sudo access, restore a backup of sshd_config (if you made one) with:
    sudo cp /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
    
  • Reset permissions on /etc/ssh with:
    sudo chmod 755 /etc/ssh
    sudo chmod 600 /etc/ssh/sshd_config
    sudo chmod 600 /etc/ssh/ssh_host_*_key
    sudo chown root:root /etc/ssh /etc/ssh/*
    
  • Restart the sshd service with sudo systemctl restart sshd

Why this error happens

The ssh_exchange_identification: read: Connection reset by peer message means the server’s sshd process either couldn’t start at all, or crashed instantly after accepting your connection. The most common triggers after modifying /etc/ssh are:

  • Invalid syntax in sshd_config (typos, missing keywords, or invalid values)
  • Incorrect security permissions on /etc/ssh or its files (sshd is extremely strict about this)
  • Accidentally deleted or moved host key files required for sshd to run

内容的提问来源于stack exchange,提问作者sachin thakur

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:37:54