hallazzang / hallazzang.github.io

Hanjun Kim's Dev Blog
https://hallazzang.github.io/
1 stars 0 forks source link

post/troubleshooting-puttygen-key-format-error/ #3

Open utterances-bot opened 10 months ago

utterances-bot commented 10 months ago

Troubleshooting PuTTYgen "Couldn't load private key (not a recognized key file format)" Error - Hanjun Kim's Dev Blog

https://hallazzang.github.io/post/troubleshooting-puttygen-key-format-error/

zippydan commented 10 months ago

I'm dying here. I've been trying to import an RSA private key that starts with BEGIN OPENSSH PRIVATE KEY and ends with END OPENSSH PRIVATE KEY. No matter what I tried, PuttyGen was giving me the "Couldn't load private key (not a recognized key file format)" error upon import. I've been thinking it was the file format, or the encryption version, or the PuttyGen version, or ANYTHING.

Then I came across this post of yours and - huzzah! - my file is also encoded in UTF-8. That must be the issue! But I saved it in Notepad++, not Notepad. I tried converting to ANSI and... IT STILL DIDN'T WORK.

In a moment of near-suicidal desperation, inspiration and extreme attention to detail came through. I was missing ONE DASH at the beginning of the key header. I must have missed it when highlighting the key in order to copy it into Notepad++.

That's right, the problem was my file had this:

----BEGIN OPENSSH PRIVATE KEY-----

Instead of this:

-----BEGIN OPENSSH PRIVATE KEY-----

I went back and confirmed by testing that PuttyGen actually doesn't care if the file is encoded as UTF-8 or as ANSI, at least when I'm using Notepad++ to save. Maybe you're right that (Microsoft's) Notepad does have an issue with UTF-8 encoding.