How to recover server access if your user password is lost
Objective
Without a different mode of authentication or another user account, losing your password means you can no longer log in to your server in a regular way.
In this case you can connect to your server via the OVHcloud rescue mode, which allows you to log in with a provisional password and modify your files.
This guide explains how to reset your user account password if you have lost access to your server.
To recover access to a server that you log in to with an SSH key, refer to our guide on How to replace an SSH key pair instead.
Requirements
- A dedicated server or a VPS with a Linux-based OS in your OVHcloud account
- Access to the OVHcloud Control Panel
This guide is not applicable for Windows server installations. Please refer to our guides on How to change the admin password on a Windows dedicated server and How to change the admin password on a Windows VPS.
Instructions
Be sure to consult our "Getting started" guides as well:
- For a dedicated server
- For a dedicated server of the Eco product line
- For a VPS
OVHcloud is providing you with services for which you are responsible, with regard to their configuration and management. It is therefore your responsibility to ensure that they function correctly.
This guide is designed to assist you in common tasks as much as possible. Nevertheless, we recommend that you contact a specialist service provider or reach out to our community if you face difficulties or doubts concerning the administration, usage or implementation of services on a server.
Step 1 - Restart the server into rescue mode
Use the corresponding rescue mode guide to connect to your server and mount your partitions:
In order to proceed, your system partition must be mounted and you must have write access to your file system.
This means that you have entered a version of the following command into the rescue mode shell:
The exact command depends on the mountpoint you used. For example, if you have mounted your partition at /mnt, it would be the following:
Step 2 - Identify the user account(s) and reset the password
After mounting the partition and running chroot /mnt (or the equivalent), you have root privileges on the mounted system.
If needed, before changing a password, identify existing accounts using the following command:
Example output (shortened):
Find your user name(s) in the list of accounts.
To change the password for a specific account (e.g. user1), enter this command:
Enter the new password twice and confirm:
On a GNU/Linux distribution, a password prompt does not display your keyboard input.
Avoid running the passwd command without arguments: This command modifies the password of the current account (which is root after executing chroot).
Always specify passwd <user>.
Remember to use the regular boot mode of your server when restarting it in your OVHcloud Control Panel.
Refer to the corresponding rescue mode guide if necessary.
The modified user account has now access to the server with the new password.
Go further
How to configure user accounts and root access on a server
Join our community of users.