The server sent an unexpected packet. received:3,expected:20

This problem generally occurs because the new version of sshd may have compatibility problems with XShell (this problem happened when XShell was connected to the machine recently, according to my own solution, write a little bit).

Solution: Add the following line at the end of /etc/ssh/sshd_config on the machine where XShell cannot connect:

KexAlgorithms [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1

then:

systemctl restart sshd

Of course, you may be more doubtful? I can't log in, how can I enter the settings?

In fact, at this time, ssh can be used on other machines, in a format like the following (or it is a good choice to log in with a tool such as MobaXterm first) :

[root@master ~]# ssh -p xxxxx [email protected]

Authorized users only. All activities may be monitored and reported.
[email protected]'s password: 

[root@localhost ~]# vim /etc/ssh/sshd_config 

If there are already KexAlgorithms curve25519-sha256, *** in the last line of /etc/ssh/sshd_config, you should not repeat the KexAlgorithms keyword again.

Wrong operation (I wrote it repeatedly at first, but it didn't solve the problem):

Correct operation:

Just append the content you want to add directly to the original content (the other thing is, don't add a space after the comma, otherwise your sshd will not be able to restart normally) .

Of course, after the modification, remember:

systemctl restart sshd

Generally, after the above command is typed, if there is no error, it will basically restart normally. When the XShell is connected again, you should be prompted to enter the user password normally. 

Guess you like

Origin blog.csdn.net/TomorrowAndTuture/article/details/114375293