Question

Deleting SSH key with lost passphrase and adding new?

I’m new to this so please be kind. Despite noting down my SSH key passphrase, it isn’t working. I just want to enable the droplet console but can’t log in to my Droplet via SSH to do it.

Is it possible to delete or replace my local SSH key pair and the key on my droplet, and regenerate from scratch?

I set up my website fine, but not being able to access the file structure means I’m now stuck. I’ve read as much as I can to fix it but I’m clearly completely out of my depth… Unfortunately my developer has shut up shop, hence trying to navigate it myself.


Submit an answer
Answer a question...

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.

KFSys
Site Moderator
Site Moderator badge
May 26, 2022

Hi @lewisshark,

Yes, that’s pretty straightforward. First, make sure to create a new SSH key on your Laptop/Computer. Use the following procedure to generate an SSH key pair on UNIX and UNIX-like systems:

Run the ssh-keygen command.

You can use the -t option to specify the type of key to create.

For example, to create an RSA key, run:

  1. ssh-keygen -t rsa

You can use the -b option to specify the length (bit size) of the key, as shown in the following example:

  1. ssh-keygen -b 2048 -t rsa

Once you have an SSH key, you just need to enter your Droplet and replace them. Apart from the article about SSH keys being mentioned, you can use the following one as well:

https://docs.digitalocean.com/products/droplets/resources/recovery-console/

Bobby Iliev
Site Moderator
Site Moderator badge
May 25, 2022

Hi there,

I recently answered a similar question here.

You can change the passphrase of your SSH key by following the steps here:

To change the passphrase for your SSH key, you could use the following command:

ssh-keygen -p -f ~/.ssh/id_rsa

You will be asked to enter the old passphrase first followed by your new passphrase. The output would look something like this:

Enter old passphrase: ****
Enter new passphrase (empty for no passphrase): ****
Enter same passphrase again:                    ****
Your identification has been saved with the new passphrase.

In case that you prefer to generate a new SSH key and add it to your Droplet, you can follow the steps here:

https://docs.digitalocean.com/products/droplets/resources/lost-ssh-key/

Hope that this helps!

Regards,

Bobby

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.