简体   繁体   English

sshd 连接问题:通过 [ip] 端口 x [preauth] 重置连接

[英]sshd connection issue: Connection reset by [ip] port x [preauth]

I'm seeing the following error messages when trying to sftp from a windows client to my redhat server:尝试从 Windows 客户端 sftp 到我的 redhat 服务器时,我看到以下错误消息:

Client:客户:

C:\Users\Administrator\.ssh>sftp -P 7822 -v user@x.x.x.x
.
.
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:FczboY8BDSWtdA87euFDWSDrwBNRMbYzHUR3VmMpbk 
C:\\Users\\Administrator/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Trying private key: C:\\Users\\Administrator/.ssh/id_dsa
debug1: Trying private key: C:\\Users\\Administrator/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\Administrator/.ssh/id_ed25519
debug1: Trying private key: C:\\Users\\Administrator/.ssh/id_xmss
debug1: No more authentication methods to try.
user@x.x.x.x Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Server:服务器:

Aug  4 23:27:09 3oy1jxwr1k81l.xxx.io sshd[16064]: Connection reset by x.x.x.x port 65256 [preauth]
Aug  4 23:27:14 3oy1jxwr1k81l.xxx.io sshd[16117]: Did not receive identification string from x.x.x.x port 12593
Aug  4 23:27:24 3oy1jxwr1k81l.xxx.io sshd[16259]: Did not receive identification string from x.x.x.x port 48329
Aug  4 23:27:34 3oy1jxwr1k81l.xxx.io sshd[16394]: Did not receive identification string from x.x.x.x port 2040

I'm positive that all ports open in firewall, and authorized_keys are setup up correctly.我确信防火墙中的所有端口都已打开,并且已正确设置了authorized_keys。 So i stop the sshd service, and run from cmd line with -ddd hoping to get more information.所以我停止了 sshd 服务,并从带有 -ddd 的 cmd 行运行,希望获得更多信息。

However when running in debug mode, the connection succeeds !?!?但是在调试模式下运行时,连接成功!?!?

/user/sbin/sshd -D -ddd

Client:客户:

C:\Users\Administrator\.ssh>sftp -P 7822 user@x.x.x.x
Connected to user@x.x.x.x.
sftp> exit

Any ideas what could be happening?任何想法可能会发生什么? (Note this is 100% reproducible, fails every time when sshd is run normally, and succeeds always when run with -ddd) (请注意,这是 100% 可重现的,每次 sshd 正常运行时都会失败,而使用 -ddd 运行时总是会成功)

So looks like the problem was due to a missing .bash_profile in the user home dir on the server.所以看起来问题是由于服务器上的用户主目录中缺少 .bash_profile 。

After adding the user profile back, it seems to resolve the issue.添加回用户配置文件后,似乎解决了问题。

Why sshd didn't care it was missing when run in debug mode seems like a bug in sshd.为什么 sshd 在调试模式下运行时不关心它是否丢失似乎是 sshd 中的一个错误。

I was also getting the Connection reset by [ip] port x [preauth] message.我还Connection reset by [ip] port x [preauth]消息获得了Connection reset by [ip] port x [preauth]

For me, however, it was a firewall issue on the client side.然而,对我来说,这是客户端的防火墙问题。 The IT department had blocked SSH outside the network. IT 部门阻止了网络外的 SSH。 After updating the firewall, the connection worked.更新防火墙后,连接正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM