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
x/crypto/ssh: add ServerConfig.HostKeyAlgorithms #52132
Comments
This proposal has been added to the active column of the proposals project |
Adding support for restricting the algorithms seems reasonable. I'd err on the side of doing this at the point of adding a host key, rather than adding a configurable list in ServerConfig though, since it would allow us to prevent the circumstance where the user configures a server which has no supported algorithms for the set of configured host keys. Something along the lines of cc @FiloSottile who most recently mucked around in the SSH code, and likely has stronger opinions about the cleanest way to do this. |
@rolandshoemaker only for info, currently the library does not perform any consistency check, for example we can start an ssh server without host keys (well get the I could try to write a patch to add the @FiloSottile do you have other suggestions? Thanks |
The core issue is that Signer doesn't advertise what algorithms it supports. This is also a backwards compatibility issue because if we add support for an algorithm, all Signers with a compatible public key need to get updated or they'll break. A better solution I think would be to extend the AlgorithmSigner interface with another interface upgrade (MultiAlgorithmSigner? AlgorithmSignerWithAlgorithms?) that includes a method that reports the algorithms supported by that signer. It would also solve #36261 because the order of the returned algorithms would allow specifying a preference order. This previously came up in #39885 (comment). See also https://github.com/golang/crypto/blob/2c7772ba30643b7a2026cbea938420dce7c6384d/ssh/handshake.go#L461-L469 and golang/crypto@1baeb1c. |
Thanks, so we could add a new interface like this:
and a new method to get an
library users who want to restrict algorithms can use this new method and pass the returned signer to the existing We could also implement the This way in the server handshake we should be able do something like this:
alternatively we can check for both If this is ok I can send a new patch, thanks |
I'm not sure this discussion is converging. @rolandshoemaker or @FiloSottile any thoughts on whether we want to add more implicit interfaces here? |
#52132 (comment) is consistent with what I was suggesting in #52132 (comment) and I like the |
@FiloSottile thanks. A patch is here: https://go-review.googlesource.com/c/crypto/+/409215 it would be great if someone could also review my patch that adds server side support for RFC 8308: https://go-review.googlesource.com/c/crypto/+/396714 This patch is included in SFTPGo since v2.2.3, no complaints so far. Thanks! |
It's a little odd to see both Algorithms and Algos (spellings) in the API. There are no "Algos" in the current go/api/*.txt files. Probably we should spell it out? Otherwise, it sounds like people are OK with #52132 (comment)? |
@rsc thanks. I have renamed |
@drakkan I don't see where you renamed NewSignerWithAlgos. #52132 (comment) still says that. Can you post a new comment below with the full list of API changes? Thanks! |
@rsc I updated the patch implementing this proposal https://go-review.googlesource.com/c/crypto/+/409215 here are the (public) API changes
thanks |
Any reason for |
No particular reason. I will update the patch, thanks |
@FiloSottile patch updated, here are the updated API:
|
Thanks @drakkan. Does anyone object to this API? |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. |
Currently Go's SSH package doesn't permit a server to disable some host keys algorithms, for example if you provide an RSA host key we can't disable
ssh-rsa
which use sha1 and is disabled by default in recent versions of OpenSSH.I propose adding a
HostKeyAlgorithms
string list to the ServerConfig similar to the one already available for the ClientConfig:I have submitted a PR that implement this new feature. This is the proposal for the API change.
The text was updated successfully, but these errors were encountered: