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

Bug with ssh key encrypted with a passphrase #57

Open
egrosner opened this issue Sep 20, 2024 · 8 comments
Open

Bug with ssh key encrypted with a passphrase #57

egrosner opened this issue Sep 20, 2024 · 8 comments

Comments

@egrosner
Copy link

The SSH key i want to use is encrypted with a passkey.

It looks like the library you are using has the option to pass a passkey in but throws an exception if one is not provided at code time.

KeyEncryptedError: The OpenSSH format key (unnamed) is encrypted (password-protected), and no passphrase was provided in options at Object.readSSHPrivate (/cloudypad/node_modules/sshpk/lib/formats/ssh-private.js:78:11) at Object.read (/cloudypad/node_modules/sshpk/lib/formats/pem.js:209:19) at Object.read (/cloudypad/node_modules/sshpk/lib/formats/ssh-private.js:26:14) at Key.parse (/cloudypad/node_modules/sshpk/lib/key.js:252:27) at parseSshPrivateKeyToPublic (/cloudypad/dist/src/tools/ssh.js:169:42) at parseSshPrivateKeyFileToPublic (/cloudypad/dist/src/tools/ssh.js:166:12) at AwsProvisioner.provision (/cloudypad/dist/src/providers/aws/provisioner.js:68:85) at processTicksAndRejections (node:internal/process/task_queues:95:5) at AwsInstanceInitializer.runProvisioning (/cloudypad/dist/src/providers/aws/initializer.js:27:9) at AwsInstanceInitializer.initializeInstance (/cloudypad/dist/src/core/initializer.js:106:9) { format: 'OpenSSH', keyName: '(unnamed)' }

@PierreBeucher
Copy link
Owner

Indeed Cloudy Pad does not handle SSH key passphrase for now.

However you should be able to use ssh-agent ;)

Fix incoming anyway !

@egrosner
Copy link
Author

Yeah I think the library sshpk doesn't seem to care about ssh-agent, which I do have my key set and loaded into with the passphrase.

@perler
Copy link

perler commented Dec 26, 2024

ok, I am missing something here. my ssh key is loaded with ssh-agent and is offered when creating an instance. but the error pops up anyway. I created another passwordless keypair but this one isn't offered (does it need to be loaded with ssh-agent?)

@PierreBeucher
Copy link
Owner

SSH key handling has to be improved, in its current state it has limitations: only keys under $HOME/.ssh are shown and they must not be protected by passphrase.

@perler where is your new keypair located in machine? Alternatively you can use cloudypad create aws --private-ssh-key <path> flag to specify a custom key path

@perler
Copy link

perler commented Dec 27, 2024

ok, this is strange, the key is in $HOME/.ssh but is not offered when adding a new pad.. will try it with the command line option.

@PierreBeucher
Copy link
Owner

PierreBeucher commented Dec 27, 2024

... and only files starting with id_* and not ending with *.pub are shown, what's the name of you key?

The then-me knew it was not ideal:

.filter(file => file.startsWith('id_') && !file.endsWith('.pub')) // TODO A bit naive method. Maybe we can read all files and check if they are private keys

@perler
Copy link

perler commented Dec 27, 2024

haha, ok, yes, that's the problem, the key is simply named "cloudypad". Which doesn't follow conventions, so it's more or less my fault. I changed the name, now it works (this part at least, don't have the time now to test the whole thing..)

@PierreBeucher
Copy link
Owner

Great, let me know

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

No branches or pull requests

3 participants