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

New Format Keys are unsupported #11

Closed
kousu opened this issue Mar 1, 2019 · 1 comment
Closed

New Format Keys are unsupported #11

kousu opened this issue Mar 1, 2019 · 1 comment

Comments

@kousu
Copy link

kousu commented Mar 1, 2019

OpenSSH has a new format. Its spec is here. It can encode any type of key openssh supports, but in

bcrypto/lib/ssh.js

Lines 520 to 522 in 934f5ea

case keyTypes.ED25519: {
block.type = 'OPENSSH PRIVATE KEY';
break;

and in

bcrypto/lib/ssh.js

Lines 610 to 612 in 934f5ea

case 'OPENSSH PRIVATE KEY': { // OpenSSH format
return this.decodeSSH(block.data, passwd);
}

which calls

bcrypto/lib/ssh.js

Lines 423 to 424 in 934f5ea

if (rawKey.type !== keyTypes.ED25519)
throw new Error('Invalid key.');

bcrypto is silently assuming that "OPENSSH PRIVATE KEY" <=> ED25519 key. And this isn't true. In fact, recent ssh-keygen now puts all keys in "OPENSSH PRIVATE KEY" format, regardless of the type of key. I've tested on Mac OS Mojave (OpenSSH_7.9p1, LibreSSL 2.7.3) and ArchLinux (OpenSSH_7.9p1, OpenSSL 1.1.1a 20 Nov 2018) and been bitten by this. On the other hand, Debian stable still uses OpenSSH_7.4p1 Debian-10+deb9u5, OpenSSL 1.0.2r 26 Feb 2019, and that defaults RSA keys to the old style, which is compatible with bcrypto.

@kousu
Copy link
Author

kousu commented Mar 2, 2019

For anyone who is stumped by this and needs a workaround until a patch gets written, you can use with any private key.

ssh-keygen -p -m PEM -f ~/.ssh/id_rsa

but beware this:

  • will ask you to change the password on the key (you can just reset it to the same one)
  • is in-place and therefore destructive ; in theory you can change back to the other format after but be careful.

@kousu kousu changed the title New format ssh keys New Format Keys are unsupported Mar 2, 2019
@chjj chjj closed this as completed in 9b0cf70 Mar 12, 2019
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

1 participant