To change the SSH key associated with your DigitalOcean droplet, you can follow these steps:
- Generate a new SSH key pair on your local machine, if you haven’t already done so. You can use the
ssh-keygen
command to generate a new key pair. Make sure to choose a strong passphrase for your private key. - Log in to the DigitalOcean control panel and navigate to the “Droplets” page.
- Click on the name of the droplet you want to modify.
- Click on the “Settings” tab, and then click on the “Security” tab.
- Scroll down to the “SSH keys” section and click on the “Add SSH Key” button.
- Paste the contents of your new public key into the “Public Key” field. You can find the public key by opening the
.pub
file in the directory where you generated the key pair. - Give your new SSH key a name, and then click on the “Add SSH Key” button.
- Log in to your droplet using your new SSH key. You can use the
ssh
command to connect to your droplet, specifying the new private key file with the-i
option. For example:
ssh -i /path/to/new/private/key username@droplet_ip_address
- Once you have verified that you can log in to your droplet using the new SSH key, you can remove the old SSH key from the droplet’s security settings in the DigitalOcean control panel.
That’s it! You have now changed the SSH key associated with your DigitalOcean droplet.