Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sshd

I'm seeing the following error messages when trying to sftp from a windows client to my redhat server:

Client:

C:\Users\Administrator\.ssh>sftp -P 7822 -v [email protected]
.
.
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.
[email protected] 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. So i stop the sshd service, and run from cmd line with -ddd hoping to get more information.

However when running in debug mode, the connection succeeds !?!?

/user/sbin/sshd -D -ddd

Client:

C:\Users\Administrator\.ssh>sftp -P 7822 [email protected]
Connected to [email protected].
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)

like image 521
brercia Avatar asked Sep 11 '25 01:09

brercia


2 Answers

So looks like the problem was due to a missing .bash_profile in the user home dir on the server.

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.

like image 55
brercia Avatar answered Sep 13 '25 08:09

brercia


I was also getting the Connection reset by [ip] port x [preauth] message.

For me, however, it was a firewall issue on the client side. The IT department had blocked SSH outside the network. After updating the firewall, the connection worked.

like image 39
kbrin-1372 Avatar answered Sep 13 '25 08:09

kbrin-1372