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

ED25519 private key loading failed: Keys(SshKey(Encoding(CharacterEncoding))) error #10235

Closed
Star-caorui opened this issue Jan 18, 2025 · 7 comments

Comments

@Star-caorui
Copy link

Issue Description: Unable to Use ED25519 Key for SSH Login

When attempting to use an ED25519 private key for SSH login to my server, I encounter the following error:

error: Keys(SshKey(Encoding(CharacterEncoding)))
Could not read the private key

Here is some relevant information about my environment:

Server Information:

  • OS: Arch Linux 6.12.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 10 Jan 2025 00:39:41 +0000 x86_64 GNU/Linux
  • OpenSSH Version: OpenSSH_9.9p1
  • OpenSSL Version: OpenSSL 3.4.0 22 Oct 2024

SSH Private Key Details:

My private key appears to be in the OpenSSH format:

-----BEGIN OPENSSH PRIVATE KEY-----
XXXXXXXXX== (this looks like Base64-encoded content)
-----END OPENSSH PRIVATE KEY-----

I would greatly appreciate your help resolving this issue. If further information or testing is required, please let me know.

Thank you for your help and time.

Version: 1.0.220
Platform: macOS arm64 24.2.0
Plugins: none
Frontend: xterm-webgl

@Eugeny
Copy link
Owner

Eugeny commented Jan 18, 2025

Could you please generate a new key in the same format that reproduces the issue and post it here?

@Star-caorui
Copy link
Author

Sure. I use ssh-keygen command on Arch Linux.

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACBHPVbd5kPw1PHe3T+EEtE4Q21piEHz9z8JpYKJjD2lswAAAJgEjpxkBI6c
ZAAAAAtzc2gtZWQyNTUxOQAAACBHPVbd5kPw1PHe3T+EEtE4Q21piEHz9z8JpYKJjD2lsw
AAAEBjcfJFEf9F+Suc17tZ2kG3cuKLhTP0UeD2u3F5WdhHwkc9Vt3mQ/DU8d7dP4QS0ThD
bWmIQfP3PwmlgomMPaWzAAAAE3N0YXJAYmouaW5ldGVjaC5mdW4BAg==
-----END OPENSSH PRIVATE KEY-----

@Star-caorui
Copy link
Author

In Version: 1.0.215, everything worked perfectly without any errors.

Starting from Version: 1.0.216 and in all later versions, including Version: 1.0.220 , I began to see the following error:

Error: Keys(SshKey(Encoding(CharacterEncoding)))
Could not read the private key

In Version: 1.0.216, despite the error, I was still able to connect successfully using the ED25519 private key.

However, starting from Version: 1.0.218 and including Version: 1.0.220 , the same error occurs, but I am no longer able to connect with the ED25519 private key.

I hope this helps you identify the issue.

Best regards.

@Eugeny
Copy link
Owner

Eugeny commented Jan 22, 2025

@Star-caorui the test key you posted is working fine in the latest release (1.0.220)

@Star-caorui
Copy link
Author

Thank you for the support! I’ve confirmed that the newly generated key works perfectly. However, the previous ed25519 key couldn’t be used, but since the issue is now resolved, I will go ahead and close it.

For reference, I’m attaching the problematic (now deprecated) key here.

Best regards!

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACD2TvUAi4NJBWXBvDkzbLiIjgjeMzhTz9cUleJn2zRWKAAAAJi1GedGtRnn
RgAAAAtzc2gtZWQyNTUxOQAAACD2TvUAi4NJBWXBvDkzbLiIjgjeMzhTz9cUleJn2zRWKA
AAAEDBi49uVXZzDhN8JohiYkBdezFWbCAw6iCS2JRA4J0ujfZO9QCLg0kFZcG8OTNsuIiO
CN4zOFPP1xSV4mfbNFYoAAAAFHN0YXJfQLLcyPHI8cjxtcS158TUAQ==
-----END OPENSSH PRIVATE KEY-----

@Eugeny
Copy link
Owner

Eugeny commented Jan 23, 2025

Found it - the issue was with a key comment string that isn't UTF-8

@Eugeny
Copy link
Owner

Eugeny commented Jan 23, 2025

ref RustCrypto/SSH#331

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

2 participants