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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "use ed25519 to generate ec2 ssh key pair"
Copy link
Contributor

@justinmk3 justinmk3 Sep 19, 2024

Choose a reason for hiding this comment

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

it's usually a good idea to prefix these items with a topic, that makes them easy to read in a list, and also makes it clear which part of the app they refer to. Other notes are here.

Suggested change
"description": "use ed25519 to generate ec2 ssh key pair"
"description": "EC2 connect: use ed25519 to generate ec2 ssh key pair"

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. */)) {

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