Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Errno 54] Connection reset by peer with asyncssh>=2.2 #276

Closed
jarhainx opened this issue Apr 25, 2020 · 3 comments
Closed

[Errno 54] Connection reset by peer with asyncssh>=2.2 #276

jarhainx opened this issue Apr 25, 2020 · 3 comments

Comments

@jarhainx
Copy link

Hello,

I have a problem with asyncssh >=2.2

I make SSH connections with modems.
On some models I have reset problems.

Asyncssh 2.2.0 or 2.2.1
Modem A : Ok
Modem B : [Errno 54] Connection reset by peer

Asyncssh 2.1.0
Modem A : Ok
Modem B : Ok

So the problem depends on the version of asyncssh and the modem model....

No logs on modem. The connection is reseted before login

Code is very simple
async with asyncssh.connect(ip, port=port, username=username, password=password, known_hosts=None) as conn:
return await conn.run("/usr/sbin/gsmctl -i -q -f -J -t -c -F -a -w -m")

Wireshark Asyncssh 2.2.1
Capture d’écran 2020-04-25 à 18 34 29

Wireshark Asyncssh 2.1.0
Capture d’écran 2020-04-25 à 18 39 15

Have you an idea ?

MacOS Catalina 10.15.4
Python 3.7.4

@ronf
Copy link
Owner

ronf commented Apr 25, 2020

There was a recent issue related to AsyncSSH 2.2.0 and later not working with dropbear SSH, when RSA keys are used. The problem had to do with Dropbear giving up if it doesn't find a matching server host key algorithm in the first 20 algorithms sent by the client, and AsyncSSH 2.2.0 now having 22 algorithms that it supports, with ssh-rsa being one of the last in the list. So, dropbear stops before it finds a matching algorithm.

If this is the problem you're seeing, the workaround is to explicitly set server_host_key_algs=['ssh-rsa'] when you call asyncssh.connect(), or at least move that algorithm closer to the front of the list. See #263 for more details.

If this doesn't solve your problem, you may be seeing something related to #274, but I haven't been able to reproduce that one yet. So, I'm not sure what is happening there.

@jarhainx
Copy link
Author

Thank you for your efficient response!
Searching on the modem manufacturer's website, he uses indeed dropbear and ssh-rsa ([https://wiki.teltonika-networks.com/view/SSH_RSA_key_authentication_(Windows))]).

The server_host_key_algs=["ssh-rsa"] solution works well with my 2 modems!

I close the issue.
Thanks again

@ronf
Copy link
Owner

ronf commented Apr 26, 2020

Glad to hear that worked - thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants