How to recover server access if your user password is lost

Knowledge Base

How to recover server access if your user password is lost


Icons/System/eye-open Created with Sketch. 117 Views 02.10.2025 Cloud / Dedicated Server (bare metal)

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

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:

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:

chroot path/to/partition/mountpoint/

The exact command depends on the mountpoint you used. For example, if you have mounted your partition at /mnt, it would be the following:

chroot /mnt/

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:

cat /etc/passwd

Example output (shortened):

daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
.
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:998:998:systemd Network Management:/:/usr/sbin/nologin
syslog:x:102:102::/nonexistent:/usr/sbin/nologin
sshd:x:105:65534::/run/sshd:/usr/sbin/nologin
.
user1:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash

Find your user name(s) in the list of accounts.
To change the password for a specific account (e.g. user1), enter this command:

passwd user1

Enter the new password twice and confirm:

# New password:
# Retype new password:
# passwd: password updated successfully

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

Creating and using SSH keys

Dedicated server rescue mode

VPS rescue mode

How to configure user accounts and root access on a server

Join our community of users.

Related articles