rtrlib/transport/ssh/ssh_transport.c: fix ssh-rsa public key auth #300
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution description
When SSH public key authentication is attempted right after
ssh_connect()
, there's a chanceSSH_MSG_EXT_INFO
message will not be received by the client in timely manner. In case if anssh-rsa
public key is being used, this in turn may lead to libssh picking SHA1 digest algorithm, which is disabled by default:https://github.com/canonical/libssh/blob/f23d1454e50d0dbb314edd9bf4227ab72303484b/src/pki.c#L443-L454 This may cause intermittent SSH public key authentication failures with no clear reason as SSH logging is disabled in rtrlib.
The fix is based on this suggestion:
https://archive.libssh.org/libssh/2025-05/0000023.html
It is possible to work around the problem by using
PubkeyAcceptedAlgorithms
in/etc/ssh/config
or~/.ssh/config
, but there are a couple of issues with this approach:libssh
, you can't usePubkeyAcceptedAlgorithms +ssh-rsa
and you must list all the algos insteadssh-rsa
to the list of pubkey algos weakens security as it also enablesSHA1
digests, weakening SSH securitySupport for
ssh-rsa
public keys is required by RFC8210: https://datatracker.ietf.org/doc/html/rfc8210#section-9.1Testing procedure
In order to reproduce the issue, you need to use
ssh-rsa
key for RPKI SSH authentication.We tested it using downstream FRR version, with StayRTR being used as the server.
It is not easy to trigger reliably b/c the issue is very time-dependent. The issue with
libssh
ssh-rsa
public key authentication is rather known though, it started causing problems afterlibssh
tightened their security defaults and disabledSHA1
digest for auth.