Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

id_rsa.pub is not a public key file

Tags:

ssh

openssh

I opened my public key in libre office and edited the comment section of the key and then saved. But when I run:

ssh-keygen -l -f id_rsa.pub 

I get:

id_rsa.pub is not a public key file.

The file is no longer recognized as a public key file. How do I solve this?

like image 419
Dobob Avatar asked Aug 22 '16 08:08

Dobob


People also ask

Is id_rsa pub the public key?

Remember id_rsa is the private key and id_rsa. pub is the public key. And that's all there is to viewing your SSH public and private keys on Linux, macOS, and Windows.

Is id_rsa public or private?

The default directory for SSH keys is ~/. ssh with the private key named id_rsa and the public key named id_rsa.

What is id_rsa pub file?

id_rsa. pub contains the public key of your RSA key pair. It may be used to allow you access the machine B over ssh without needing to enter password. To know it works, read this Security SE question.

Where is the id_rsa pub file?

pub file, while the private part is saved in the id_rsa file. Both files can be accessed from this location using Explorer: C:\Users\[your user name]\. ssh . Make sure you replace [your user name] with your user name.


1 Answers

You might not open this file using complex text editor. Use Notepad++ or gedit (something like this) to edit your file.

Then, verify you have a space between 'ssh-rsa' and "AAAA....." at the beginning of your key.

To regenerate your public key, use the -y option as follow :

ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub

I hope it will fix your problem :)

From man ssh-keygen:

-y      This option will read a private OpenSSH format file and print an OpenSSH public key to stdout.

Source : serverfault.com

like image 73
Kapcash Avatar answered Oct 02 '22 04:10

Kapcash