Replacing your lost SSH key pair

Find out how to regain SSH access to your Public Cloud Instance

Last updated 10th February 2022


If you have lost your SSH key, you might be unable to connect to your Public Cloud Instance if you have not configured any alternative way to do so.

To regain access, we have provided you with a rescue mode, which allows you to log in with a password and then change your files.

This guide explains how to configure the authorized_keys file for the admin user, so that you can add a new SSH key to regain access to your instance.



If you would like to store an SSH key in the OVHcloud Control Panel, we recommend to use RSA or ECDSA encryption. ED25519 is currently not supported.

After mounting your instance's disk in rescue mode, you will be able to access all your files. The file containing your SSH keys is shown below:


If you want to add your new SSH key, you just have to edit this file as follows:

admin@instance:~$ sudo vim /mnt/home/USER_NAME/.ssh/authorized_keys

ssh-rsa 1111111111122222222222333333333333444444444555555555556666666666
777777777778888888888999999900000000000000000000000000== old@sshkey
EEFFFFFFFFFFFFFGGGGGGGGGGGGGhhhhhhhhhhhhhhhhhhhhhhhhhh== new@sshkey

Change the SSH key for the default user

To change your default user's SSH key, you just have to go to the user's personal file.

For example, for the admin user, the file you need is in the following folder:


For an Ubuntu instance, the default user will be "ubuntu" and the file will therefore be in the following folder:


Change the password for the default user

You can also change your default user's password by using rescue mode and the following commands (if the user is admin).

First, change the root directory so that it is placed directly on the instance's disk:

In the example below, we have used vdb1 as the name of the server's disk and mnt as the mount point.

root@instance:/home/admin# mount /dev/vdb1 /mnt/
root@instance:/home/admin# chroot /mnt/

Then change the admin password.

root@instance:/# passwd admin

Once this change has taken place and been backed up, you need to reboot your instance on its disk, so that you can log in with your new SSH key.

Go further

Become root and select a password

Join our community of users on

Did you find this guide useful?

Please feel free to give any suggestions in order to improve this documentation.

Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.

Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.

Thank you. Your feedback has been received.

These guides might also interest you...

OVHcloud Community

Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.

Discuss with the OVHcloud community

In accordance with the 2006/112/CE Directive, modified on 01/01/2015, prices exclude VAT. VAT may vary according to the customer's country of residence.