---
title: "How to recover server access if your user password is lost"
description: "This guide explains how to reset your user account password if you have lost access to your server."
url: https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/replacing-user-password
lang: en
---
> For AI agents: the complete documentation index is available at https://docs.us.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.us.ovhcloud.com/en/llms-full.txt.

# How to recover server access if your user password is lost

**This guide explains how to reset your user account password if you have lost access to your server.**

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.

**Note:**

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](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/replacing-lost-ssh-key-pair.md) instead.

 

## Requirements

- A [dedicated server](https://us.ovhcloud.com/bare-metal/) or a [VPS](https://us.ovhcloud.com/vps/) with a Linux-based OS in your OVHcloud account
- Access to the [OVHcloud Control Panel](https://manager.us.ovhcloud.com/)

**Note:**

This guide does not apply to **Windows** server installations. Please refer to our guides on [How to reset the administrator password on a Windows server](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/reset-administrator-password-windows-server.md) and [How to change the admin password on a Windows VPS](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/reset-windows-password.md).

 

## Instructions

Be sure to consult our "Getting started" guides as well:

- For a [dedicated server](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/getting-started-dedicated-server-windows-linux.md)
- For a [dedicated server of the Eco product line](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/getting-started-with-dedicated-server-eco.md)
- For a [VPS](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/starting-with-a-vps.md)

**Warning:**

**NOTE:** OVHcloud provides services for which you are responsible for their configuration and management. You are therefore responsible for their proper functioning.\
\
This tutorial is designed to help you as much as possible with common tasks. If you are having difficulty performing these actions, please contact a specialized service provider. OVHcloud cannot provide you with technical support in this regard.

 

### Step 1: Restart the server in rescue mode

Use the corresponding rescue mode guide to connect to your server and mount your partitions:

#### Dedicated server

**Tip:** See the full [Dedicated server rescue mode](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/rescue-mode.md#mounting-partitions-to-access-your-files) guide here.

Unless you intend to configure the server's disks in a way that requires them to be detached (unmounted), you need to first **mount the system partition** in order to access your data from rescue mode.
Firstly, list all partitions to retrieve the name of the partition you need to mount:
```bash
lsblk
```
Output examples:
```
NAME      MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda         8:0    0  1.8T  0 disk
├─sda1      8:1    0  511M  0 part
├─sda2      8:2    0  1.8T  0 part
│ └─md127   9:127  0  1.8T  0 raid1
├─sda3      8:3    0  512M  0 part
└─sda4      8:4    0    2M  0 part
sdb         8:16   0  1.8T  0 disk
├─sdb1      8:17   0  511M  0 part
├─sdb2      8:18   0  1.8T  0 part
│ └─md127   9:127  0  1.8T  0 raid1
└─sdb3      8:19   0  512M  0 part
```
```
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
nvme1n1     259:0    0 894.3G  0 disk
├─nvme1n1p1 259:2    0   511M  0 part
├─nvme1n1p2 259:3    0     1G  0 part
│ └─md2       9:2    0  1022M  0 raid1
├─nvme1n1p3 259:4    0 892.3G  0 part
│ └─md3       9:3    0 892.1G  0 raid1
└─nvme1n1p4 259:5    0   512M  0 part
nvme0n1     259:1    0 894.3G  0 disk
├─nvme0n1p1 259:6    0   511M  0 part
├─nvme0n1p2 259:7    0     1G  0 part
│ └─md2       9:2    0  1022M  0 raid1
├─nvme0n1p3 259:8    0 892.3G  0 part
│ └─md3       9:3    0 892.1G  0 raid1
├─nvme0n1p4 259:9    0   512M  0 part
└─nvme0n1p5 259:10   0     2M  0 part
```
Then mount the pertinent partition accordingly:
```bash
mount /dev/PARTITION_NAME /MOUNT_POINT/
```
The partition to mount should be easily identifiable by the **SIZE** indicated in the table (`sda2` in the first example, `nvme1n1p3` in the second). Using the folder name `mnt` as mount point, for the first example the `mount` command would therefore be as follows:
```bash
mount /dev/md127 /mnt/
```
Command to enter for the second example:
```bash
mount /dev/md3 /mnt/
```

**Warning:** **NOTE:** The examples above illustrate the necessary steps based on a typical server configuration. The information in the output table depends on your server's hardware and its partition scheme. When in doubt, consult the documentation of your operating system.
If you require professional assistance with server administration, consider the details in the [Go further](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/rescue-mode.md#go-further) section of this guide.

To see more technical information about the server's disks and partitions, enter:
```bash
fdisk -l
```
Some tasks may require that disks or partitions be detached. To do this, use the unmount command:
```bash
umount /mnt
```

#### VPS

**Tip:** See the full [VPS rescue mode](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/recover-rescue-mode.md#mounting-the-partition-and-changing-the-root-password) guide here.

Once you have successfully accessed your VPS via SSH, the first step will be to mount the partition to the Rescue Mode environment. We can find out which partition we need to mount using the following command:
```

# lsblk

```
Here is a sample output of this command:
```
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  2.5G  0 disk 
└─sda1   8:1    0  2.5G  0 part /
sdb      8:16   0   20G  0 disk 
├─sdb1   8:17   0 19.9G  0 part 
├─sdb14  8:30   0    4M  0 part 
└─sdb15  8:31   0  106M  0 part 
```
This VPS has 20 GB of storage space. That means that the partition we need to mount is `sdb1` since it contains 19.9 GB of storage and thus, contains the Linux filesystem. This partition will be in the `/dev` directory by default.

**Warning:** **NOTE:** The name of your partition may be different, so follow the output of your system. In this article, we will call it `sdb1`.

After identifying the storage device, create a root directory within the `/mnt` directory, and then use the `mount` command to mount the partition to the Rescue Mode environment:
```

# mkdir /mnt/root

```
```

# mount /dev/sdb1 /mnt/root

```
Now, navigate to the newly mounted device and then use the chroot command to give yourself root access to the mounted filesystem:
```

# cd /mnt/root

```
```

# chroot /mnt/root

```
Now, we can change the root password using the following command:
```

# passwd

```
If you wish to change the password for a different user, just append the username to the end of the above command, and it will change the password for that user. If you don't specify a user, as we did above, you are changing the root password by default.

**Warning:** **NOTE:** If you are using a Red Hat based OS (e.g., CentOS, Fedora, AlmaLinux, Rocky Linux, etc.), you will need to perform one additional step here. Run the command `touch /.autorelabel` to make the OS reset SELinux contexts on boot.

Exit Rescue Mode and reboot your server. If you did everything correctly, your new password will grant you access to your live server environment.

**Important:**

**WARNING:** To proceed, your system partition must be **mounted**, and you must have write access to your file system. See the [accordion menus above](#step-1-restart-the-server-into-rescue-mode) for instructions for mounting a partition.

This means that you have entered a version of the following command into the rescue mode shell:

```bash
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:

```bash
chroot /mnt/
```

 

### Step 2: Identify the user account(s) and reset the user 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:

```bash
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:

```bash
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**.

**Note:**

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](https://manager.us.ovhcloud.com/).

Refer to the corresponding [rescue mode guide](#step-1-restart-the-server-into-rescue-mode) if necessary.

The modified user account now has access to the server with the new password.

 

## Go further

[Creating and using SSH keys](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/create-use-authentication-keys-ssh-connections-ovhcloud-server.md)

[Dedicated server rescue mode](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/rescue-mode.md)

[VPS rescue mode](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/recover-rescue-mode.md)

[How to configure user accounts and root access on a server](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/configure-user-accounts-root-access-server.md)

Browse all the [Dedicated Servers guides](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/landing-page-dedicated-servers.md).

Browse the rest of the [OVHcloud US documentation](https://docs.us.ovhcloud.com/en/index.md) for guides on our other products and services.

Learn more about [Dedicated Servers](https://us.ovhcloud.com/bare-metal/) on the OVHcloud US website.
