Recovering lost SSH access to an instance¶
- Shut down the locked-out instance.
- Detach the affected boot volume (or clone it first if you want to keep the original untouched).
-
Create a new instance and attach the volume as Additional storage:
-
Find the right partition. SSH into the new instance and run:
Your old volume appears as
/dev/vdb. Look for the partition holding the root filesystem. -
Mount the volume. Replace the partition name if yours differs:
-
Log in as root:
-
Add your key. The file you need to edit depends on which user you log in as. Open the correct file and add your new public key on its own line:
- Logging in as root, edit:
/mnt/your-old-volume/root/.ssh/authorized_keys - Logging in as any other user (for example ubuntu), edit:
/mnt/your-old-volume/home/USER/.ssh/authorized_keys
If you aren't sure, run the following command to see which users exist on the old volume:
- Logging in as root, edit:
-
-
Unmount the volume, detach it from the temporary instance, and reattach it to the original instance in place of its boot volume, then boot it and try SSH again.
Still locked out?¶
If the instance still won't accept your key afterward, contact support through the chat in the console or by email.