Support both ECDSA + RSA for SSH Server #65
Merged
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.
Purpose
Backup container would like to migrate to an integrated SSH client, unfortunately the easiest option only supports EC-based key exchange rather than both RSA and EC. As it's beneficial to support a broader set of clients anyways, this change adds an EC host key, allowing clients to use either type of key exchange.
Additionally moves the hostKey.pem file to be .hostKey.pem to hide it by default. Backwards compatibility is supported by checking and reading either file, and if the old file was read and/or a missing key was added, writing both keys back out to the new file. This includes handling a pem file that is missing one or both keys.
Validation
Confirmed that with changes, the server side reports supporting ECDSA and RSA key exchange, using an SSH client library (SwiftNIO's SSH client). Also confirmed that using the library achieves the expected result: being able to connect and provide input to the process wrapped by mc-server-runner.
Confirmed that an openssh client can still connect same as without the changes.
Checked backwards compatibility scenarios around the hostKey.pem file: