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

[bug] SSH Connection: Pubkey auth attempt with unknown algo #643

Closed
nemesifier opened this issue May 3, 2022 · 1 comment · Fixed by #644
Closed

[bug] SSH Connection: Pubkey auth attempt with unknown algo #643

nemesifier opened this issue May 3, 2022 · 1 comment · Fixed by #644

Comments

@nemesifier
Copy link
Member

nemesifier commented May 3, 2022

On some systems the SSH connection to OpenWrt fails with the following error message on the OpenWrt side:

Pubkey auth attempt with unknown algo for 'root' from <ip>:<port>

It happens on OpenWrt 19 with RSA keys.

On the server side the error message is either "Authentication failed" or "Timed out".

@nemesifier nemesifier added bug Important Higher priority or release blocker labels May 3, 2022
@nemesifier nemesifier added this to Backlog in OpenWISP Priorities for next releases via automation May 3, 2022
@nemesifier nemesifier added this to To do (general) in OpenWISP Contributor's Board via automation May 3, 2022
@nemesifier
Copy link
Member Author

I found out the reason, it's explained here: paramiko/paramiko#1961.

nemesifier added a commit that referenced this issue May 4, 2022
Paramiko versions > 2.8 try to use sha2 as a default
pub key algorithm if the target SSH server doesn't
advertise the preferred pub key algorithm used, which
is the case for OpenWrt <= 19.

This causes SSH connections to fail with:
"Pubkey auth attempt with unknown algo".

The fix suggested by Paramiko is to disable sha2 algorithms,
which is not great for systems where newer versions of
OpenWrt and dropbear are in use, for this reason, this
patch disables the sha2 algorithms only if a first
SSH connection attempt fails by raising the exception
paramiko.ssh_exception.AuthenticationException,
initialized with the string 'Authentication failed.'.

Closes #643
nemesifier added a commit that referenced this issue May 4, 2022
Paramiko versions > 2.8 try to use sha2 as a default
HostKeyAlgorithms if the target SSH server doesn't
advertise the preferred HostKeyAlgorithms, which
is the case for OpenWrt <= 19.

This causes SSH connections to fail with:
"Pubkey auth attempt with unknown algo",
because dropbear on OpenWrt <= 19 doesn't
support sha2.

The fix suggested by Paramiko is to disable
the sha2 HostKeyAlgorithms,
which is not great for systems where newer versions of
OpenWrt and dropbear are in use, for this reason, this
patch disables the sha2 HostKeyAlgorithms only if a first
SSH connection attempt fails by raising the exception
paramiko.ssh_exception.AuthenticationException.

As a bonus fix, I found out that it's better
to explicitly close the SSH connection when the authentication
fails, otherwise a lingering SSH connection can stay open
for a while.

Closes #643
nemesifier added a commit that referenced this issue May 4, 2022
Paramiko versions > 2.8 try to use sha2 as a default
HostKeyAlgorithms if the target SSH server doesn't
advertise the preferred HostKeyAlgorithms, which
is the case for OpenWrt <= 19.

This causes SSH connections to fail with:
"Pubkey auth attempt with unknown algo",
because dropbear on OpenWrt <= 19 doesn't
support sha2.

The fix suggested by Paramiko is to disable
the sha2 HostKeyAlgorithms,
which is not great for systems where newer versions of
OpenWrt and dropbear are in use, for this reason, this
patch disables the sha2 HostKeyAlgorithms only if a first
SSH connection attempt fails by raising the exception
paramiko.ssh_exception.AuthenticationException.

As a bonus fix, I found out that it's better
to explicitly close the SSH connection when the authentication
fails, otherwise a lingering SSH connection can stay open
for a while.

Closes #643
nemesifier added a commit that referenced this issue May 4, 2022
Paramiko versions > 2.8 try to use sha2 as a default
HostKeyAlgorithms if the target SSH server doesn't
advertise the preferred HostKeyAlgorithms, which
is the case for OpenWrt <= 19.

This causes SSH connections to fail with:
"Pubkey auth attempt with unknown algo",
because dropbear on OpenWrt <= 19 doesn't
support sha2.

The fix suggested by Paramiko is to disable
the sha2 HostKeyAlgorithms,
which is not great for systems where newer versions of
OpenWrt and dropbear are in use, for this reason, this
patch disables the sha2 HostKeyAlgorithms only if a first
SSH connection attempt fails by raising the exception
paramiko.ssh_exception.AuthenticationException.

As a bonus fix, I found out that it's better
to explicitly close the SSH connection when the authentication
fails, otherwise a lingering SSH connection can stay open
for a while.

Closes #643
OpenWISP Contributor's Board automation moved this from To do (general) to Done May 4, 2022
OpenWISP Priorities for next releases automation moved this from Backlog to Done May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Important Higher priority or release blocker
Development

Successfully merging a pull request may close this issue.

1 participant