Question

SSH Invalid when using ssh-keygen -p

Posted June 1, 2020 1.2k views
Security

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/idrsa):
/root/.ssh/authorized
keys
Failed to load key /root/.ssh/authorized_keys: invalid format

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

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

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.

×
2 answers

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/authorizedkeys” I get “Failed to load key /root/.ssh/authorizedkeys: invalid format”

but the content of /root/.ssh/authorizedkeys file is exactly the same as that generated by PuTTYgen (Public key for pasting into OpenSSH authorizedkeys 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?

  • Hi @helloSquid,

    In that case you can run the following command on your computer with Putty to regenerate the SSH key with a passphrase

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    

    This creates a new ssh key, using the provided email as a label.

     Generating public/private rsa key pair.
    

    When you’re prompted to “Enter a file in which to save the key,” press Enter. This accepts the default file location.

    > Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa)"
    

    At the prompt, type a secure passphrase.

    > Enter passphrase (empty for no passphrase): [Type a passphrase]
    > Enter same passphrase again: [Type passphrase again]
    

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

Submit an Answer