Restoring access to a VM with a lost SSH key
Written by
Updated at December 17, 2025
Issue description
You lost the SSH key you used to connect to a VM.
Solution
There are various options to recover a VM to which you have lost SSH keys.
If your Linux user has no password, you can create a disk snapshot from the VM in question, and then create a new VM from this snapshot, selecting Add disk → Snapshot on the VM creation page.
If the above method did not solve the issue, follow these steps:
- Create a new disk from the snapshot of the VM in question.
- Attach it as a secondary disk to a different VM.
- Change the root directory using
chroot. - Modify the configuration files that affect VM accessibility, e.g., set a new password using the
sudo passwd $USERNAMEcommand, where$USERNAMEis the name of the Linux user to set a password for. - Detach the secondary disk from the auxiliary VM and create a new VM from it using the modified disk as the boot disk.
If you previously set a password for the Linux user on your VM, you can use the serial console. For detailed information, follow this guide.
After enabling the serial console, connect to the VM in question. We recommend connecting through the CLI.