Restoring access to a VM
You may need to restore access to a VM in the following cases:
- VM user credentials are lost.
- An SSH key's public part was changed.
- Unable to connect to a VM via SSH.
- A VM fails to start.
VM user credentials are lost
If you lost your private SSH key for Linux:
- Create a snapshot of the disk of the VM that you want to restore access to.
- Create a VM with the disk from the snapshot specifying it as the boot disk. When creating a VM, enter your new credentials under Access.
- Connect to the VM via SSH using the new credentials.
If the 'cloud-init' or network configuration was changed for the VM, the described method may not work. In this case, see A VM fails to start.
An SSH key's public part was changed
You may have problems accessing a Linux-based VM over SSH if the public part of your SSH key was changed or deleted on the side of the VM.
To recover the public part of your SSH key:
-
Stop the VM.
-
Take a snaphost of the VM's boot disk.
-
Create an auxiliary Linux-based VM. Under Image/boot disk selection, choose the OS for the boot disk. To attach a data disk to an auxiliary VM, select the previously created snapshot in the Disks section.
-
Connect over SSH to the auxiliary VM and mount the disk you created from the snapshot.
-
Replace the SSH key that is stored on this disk with a valid key:
-
Go to the folder that stores the public part of the SSH key in the mounted partition. For example:
cd /mnt/home/<username>/.ssh
By default, a user's SSH keys are stored in the
~/.ssh
directory of this user. -
Open the
authorized_keys
file, for example, using thenano
text editor:nano authorized_keys
If the file is missing, this command will create it.
-
Replace the contents of the file with the public part of the valid SSH key pair.
-
-
Unmount the disk with the fixed SSH key from the VM:
sudo umount /mnt
-
Stop the auxiliary VM and detach the disk with the fixed SSH key from it.
-
Create a new VM. Under Image/boot disk selection, go to the Custom tab and select the disk with the fixed SSH key as the boot disk.
-
Connect to the new VM over SSH.
-
Delete the disk snapshot and delete the auxiliary and old VMs.
An SSH key is lost
Take a snapshot of the VM's disk and create a new VM from the snapshot.
If the problem persists:
- Create a new disk from the VM snapshot.
- Attach it as a secondary disk to a different VM.
- Change the root directory with
chroot
. - Edit the configuration files that make the VM unavailable.
- Detach the disk from the VM.
- Create a new VM. Under Image/boot disk selection, go to the Custom tab and select your disk as the boot disk.
A VM fails to start
If you cannot start a VM, get access to data on the disk as follows:
- Create a snapshot of the disk of the VM that you want to restore access to.
- Create a disk from the snapshot. When creating a disk, choose
Snapshot
in the Contents field and specify the created snapshot. - Attach the disk as secondary to the auxiliary VM.
- Change the configuration files that affect the VM startup or copy important data.
- Detach the disk from the auxiliary VM.
- If you found and fixed the startup issue, create a new VM. When creating a VM, go to the Custom tab under Image/boot disk selection and select the fixed disk as the boot disk.
Unable to connect to a VM via SSH
The problem may occur due to an error in the SSH, security group, or network settings. To restore access, contact Nebius AI support.