Error key_load_public: invalid format

If you are getting this error

key_load_public: invalid format

 

🔑 1. Check Your Public Key

Check if you have a public key:

ls -l ~/.ssh/id_rsa.pub

If it does not exist, generate a new one:

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

🔧 2. Fix Key Permissions

Ensure your keys have the correct permissions:

chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub

🛠 3. Restart SSH Agent and Add the Key

eval “$(ssh-agent -s)”
ssh-add ~/.ssh/id_rsa