Question

SSH Invalid when using ssh-keygen -p

I created an SSH key with PuTTY and can use it to successfully login to my droplet.

I tried to change the SSH key passphrase with

ssh-keygen -p Enter file in which the key is (/root/.ssh/id_rsa): /root/.ssh/authorized_keys Failed to load key /root/.ssh/authorized_keys: invalid format

The content of /root/.ssh/authorized_keys file is exactly the same as that generated by PuTTYgen (Public key for pasting into OpenSSH authorized_keys file).

does anyone know why its invalid of am I doing something wrong? or better still can I debug this?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

ok thanks. Can I just make sure I’ve got this right …

I created an SSH key with PuTTY, added the public key to my droplet and can use it to successfully login to my droplet.

I was told I could update the passphrase of the key with “ssh-keygen -p” and when I run this command it asks “Enter file in which the key is (/root/.ssh/idrsa)”

when I enter “/root/.ssh/authorized_keys” I get “Failed to load key /root/.ssh/authorized_keys: invalid format”

but the content of /root/.ssh/authorized_keys file is exactly the same as that generated by PuTTYgen (Public key for pasting into OpenSSH authorized_keys file).

so maybe I’ve misunderstood what’s happening?

“When you run the command ssh-keygen -p it regenerates the key” I can’t run ssh-keygen -p becuase I get "“Failed to load key /root/.ssh/authorized_keys: invalid format”

“Check your public and private key, they should be different that what they where before.” If I get it to run, where will it place the new public & private keys?

KFSys
Site Moderator
Site Moderator badge
June 2, 2020

Hi @helloSquid,

When you run the command ssh-keygen-p it regenerates the key. Check your public and private key, they should be different that what they where before.

In that case, to resolve the issue try to re-add the public ssh key to your ~/.ssh/authorized_keys file.

Regards, KDSys

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel