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

aes256-ctr not supported for private keys #742

Closed
brohee opened this issue Nov 9, 2020 · 13 comments
Closed

aes256-ctr not supported for private keys #742

brohee opened this issue Nov 9, 2020 · 13 comments
Milestone

Comments

@brohee
Copy link

brohee commented Nov 9, 2020

Hi,

Newer OpenSSH versions seem to create private keys enciphered with aes256-ctr by default, at least for ed25519 keys, making them impossible to load with SSH.NET. Given than ssh-keygen doesn't provide a handy way to reencode the key, it's pretty annoying.

Stacktrace of an attempt at loading such a key:

Renci.SshNet.Common.SshException: cipher name aes256-ctr for openssh key file is not supported
   . Renci.SshNet.PrivateKeyFile.ParseOpenSshV1Key(Byte[] keyFileData, String passPhrase)
   . Renci.SshNet.PrivateKeyFile.Open(Stream privateKey, String passPhrase)
   . Renci.SshNet.PrivateKeyFile..ctor(Stream privateKey, String passPhrase)
@darinkes
Copy link
Collaborator

darinkes commented Nov 9, 2020

This PR includes this: #614

@MAGICCC
Copy link

MAGICCC commented Oct 6, 2021

Seems we need to have a release so other programs can update their dependencies against the new release

@lilhoser
Copy link

lilhoser commented Jan 7, 2022

When will this fix be available?

@darkoperator
Copy link

darkoperator commented Jan 7, 2022 via email

@kcadduk
Copy link

kcadduk commented Feb 17, 2022

I don't suppose you have an update on the next release to fix this issue?

@Dean-NC
Copy link

Dean-NC commented Apr 7, 2022

I'm using the main branch (version 2020.0.1) so I also get this error. I know it's fixed in the develop branch, but I decided to not use a password on the key right now, which avoids the error. Hopefully a new main release will get put out soon.

@icedream
Copy link

This specific cipher is currently not implemented in the case of decrypting OpenSSH V1 keys:

https://github.com/sshnet/SSH.NET/blob/2020.0.2/src/Renci.SshNet/PrivateKeyFile.cs#L427-L455

The code simply assumes the encryption is either aes256-cbc or non-existent, otherwise it fails. So someone needs to implement aes256-ctr (and preferably other possible ciphers for this case).

@MAGICCC
Copy link

MAGICCC commented Jul 11, 2022

If you want to use ed25519 keys you may change the encryption cipher using the -Z parameter

-Z cipher
Specifies the cipher to use for encryption when writing an OpenSSH-format private key file. The list of available ciphers may be >obtained using "ssh -Q cipher". The default is “aes256-ctr”.

ssh-keygen -t ed25519 -b 384 -C "<comment>" -f <output_keyfile> -Z aes256-cbc

@ming86
Copy link

ming86 commented Oct 27, 2022

If you want to use ed25519 keys you may change the encryption cipher using the -Z parameter

-Z cipher
Specifies the cipher to use for encryption when writing an OpenSSH-format private key file. The list of available ciphers may be >obtained using "ssh -Q cipher". The default is “aes256-ctr”.

ssh-keygen -t ed25519 -b 384 -C "<comment>" -f <output_keyfile> -Z aes256-cbc

If you want to change passphrase and cipher of an existing ed25519 key

ssh-keygen -f <private_keyfile> -p -Z aes256-cbc

enter the passphrase as prompts.

@tparikka
Copy link

Is there a release date planned for this fix?

@Dean-NC
Copy link

Dean-NC commented Jun 27, 2023

I think a release should be made. It's been a while.

@nandostyle
Copy link

nandostyle commented Jul 15, 2023

So basically, you have to force the cipher to be aes256-cbc?

@Rob-Hague
Copy link
Collaborator

Fixed by #614 which is in the 2023.0.0 release

@WojciechNagorski WojciechNagorski added this to the 2023.0.0 milestone Nov 2, 2023
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