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

feat(ec2): switch to using ed25519 to generate key pair #5637

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

Hweinstock
Copy link
Contributor

Problem

currently use RSA.

Solution

switch to ed25519


License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

This pull request implements a feature or fix, so it must include a changelog entry. See CONTRIBUTING.md#changelog for instructions.

@Hweinstock Hweinstock changed the title fix(ec2): switch to using ed25519 to generate key pair feat(ec2): switch to using ed25519 to generate key pair Sep 19, 2024
@Hweinstock Hweinstock marked this pull request as ready for review September 19, 2024 19:07
@Hweinstock Hweinstock requested a review from a team as a code owner September 19, 2024 19:07
const process = new ChildProcess(`ssh-keygen`, ['-vvv', '-l', '-f', keyPath])
const result = await process.run()
// Check private key header for algorithm name
assert.strictEqual(result.stdout.includes('[ED25519 256]'), true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always great to see tests exercising actual reality instead of setting up mocks!

@justinmk3
Copy link
Contributor

This might imply that we should check the version of ssh-keygen and show an error or fallback to RSA if it doesn't support ed25519. This file has a bunch of examples using tryRun in order to sniff out whether a CLI tool supports what we expect:

export async function findSshPath(): Promise<string | undefined> {
if (sshPath !== undefined) {
return sshPath
}
const sshSettingPath = Settings.instance.get('remote.SSH.path', String, '')
const paths = [
sshSettingPath,
'ssh', // Try $PATH _before_ falling back to common paths.
'/usr/bin/ssh',
'C:/Windows/System32/OpenSSH/ssh.exe',
'C:/Program Files/Git/usr/bin/ssh.exe',
]
for (const p of paths) {
if (!p || ('ssh' !== p && !(await fs.exists(p)))) {
continue
}
if (await tryRun(p, ['-G', 'x'], 'noresult' /* "ssh -G" prints quasi-sensitive info. */)) {

Co-authored-by: Justin M. Keyes <[email protected]>
@Hweinstock Hweinstock merged commit 4c3e64c into master Sep 20, 2024
23 of 24 checks passed
@Hweinstock Hweinstock deleted the hkobew/ec2/ed25519 branch September 20, 2024 15:05
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

Successfully merging this pull request may close these issues.

2 participants