---
title: "How to Change the Root Password on a VPS"
description: "It may become necessary to change the root password on your GNU/Linux operating system. There are two possible scenarios:"
url: https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/change-root-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 Change the Root Password on a VPS

## Objective

It may become necessary to change the root password on your GNU/Linux operating system. There are two possible scenarios:

- You are still able to log in via SSH
- You are unable to log in via SSH because you have lost your password

**This guide will explain how to proceed with changing your admin password depending on the initial situation.**

## Requirements

- An OVHcloud [VPS](https://us.ovhcloud.com/vps/) already set up
- Login credentials received via email after the installation (if still valid)
- Access to the [OVHcloud Control Panel](https://manager.us.ovhcloud.com/) (for using rescue mode)

**Warning:**

OVHcloud is providing you with services for which you are responsible, with regard to their configuration and management. You are therefore responsible for ensuring 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 if you have difficulties or doubts concerning the administration, usage or implementation of services on a server.

## Instructions

### Changing the password if you still have access (sudo user or root)

**Note:**

For more information about connecting to your VPS, please consult the [first steps guide](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/starting-with-a-vps.md).

Log in to your VPS via SSH. Switch to the root user, if necessary:

```
$ sudo su
#
```

Change the password of the current user:

```

# passwd

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

**Note:**

On a GNU/Linux distribution, the password you enter **will not appear**.

If you need to permit logging in as root, follow the steps in [this guide section](#enableroot).

### Changing the password if you have lost it

#### Step 1: Restart the VPS into rescue mode

Log in to your [OVHcloud Control Panel](https://manager.us.ovhcloud.com/) and reboot the VPS in rescue mode. If you need further instructions about activating rescue mode with a VPS, you may consult the [rescue mode guide](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/recover-rescue-mode.md).

#### Step 2: Identify the mount point

On older VPS ranges, your partitions will be automatically mounted in rescue mode. You can use the following commands to verify this and identify where your partition is mounted:

##### **df -h**

```

# df -h

Filesystem      Size  Used Avail Use% Mounted on
udev            5.8G     0  5.8G   0% /dev
tmpfs           1.2G   17M  1.2G   2% /run
/dev/sda1       2.4G  1.5G  788M  66% /
tmpfs           5.8G     0  5.8G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           5.8G     0  5.8G   0% /sys/fs/cgroup
/dev/sdb1        49G  1.2G   48G   3% /mnt/sdb1
/dev/sdb15      105M  3.6M  101M   4% /mnt/sdb15
```

##### **lsblk**

```

# lsblk

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   50G  0 disk
├─sdb1    8:17   0 49.9G  0 part /mnt/sdb1
├─sdb14   8:30   0    4M  0 part
└─sdb15   8:31   0  106M  0 part /mnt/sdb15
```

The example output above shows that the system partition is mounted on **/mnt/sdb1**.

If your VPS is of the current ranges, the `MOUNTPOINT` column should be empty. In that case, mount the partition first:

```

# mkdir -p /mnt/sdb1

# mount /dev/sdb1 /mnt/sdb1

```

#### Step 3: CHROOT permissions

You now need to edit the root directory to apply the changes to your system. You can do this by using the `chroot` command:

```

# chroot /mnt/sdb1/

```

You can check by typing the `ls -l` command, which will list the content stored in the current directory of your system:

```

# ls -l

```

#### Step 4: Change the (root) password

In the last step, change your password with the `passwd` command.

```

# passwd

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

If your VPS is of the current ranges (naming scheme: _vps-XXXXXXX.vps.ovh.net_), you have initially received login credentials for a user with elevated permissions instead of the default “root” account. Additionally, the SSH service is not accepting login requests as root.

It is therefore necessary to enter the username you actually use to log in after `passwd`:

```

# passwd <username>

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

This will ensure that you can log in again with this username after rebooting, in case root login is disabled.

Finally, reboot your VPS in ‘normal’ mode in your [OVHcloud Control Panel](https://manager.us.ovhcloud.com/).

### Enabling root login

If your VPS is of the current ranges (naming scheme: _vps-XXXXXXX.vps.ovh.net_), you have received login credentials for a user with elevated permissions instead of the default “root” account. Additionally, the SSH service is not accepting login requests as root.

**Warning:**

**NOTE:** To make these changes as an admin user, use `sudo` or `su`.\
\
Enabling root logins is usually regarded as a security vulnerability and is therefore not recommended.\
\
We recommend taking measures to secure your VPS first. You can refer to our guide on [Securing a VPS](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/secure-your-vps.md).

#### Step 1: Edit the sshd\_config file

Use a text editor such as vim or nano to edit this configuration file:

```
nano /etc/ssh/sshd_config
```

Add the following line.

```
PermitRootLogin yes
```

Look for this line and make sure it is commented out:

```
#PermitRootLogin prohibit-password
```

Save the file and exit the editor.

#### Step 2: Restart the SSH service

```
systemctl restart sshd
```

This should be sufficient to apply the changes. Alternatively, reboot the VPS (`~$ reboot`).

### Troubleshooting

If you encounter boot issues after you have changed your password and initiated the reboot:

- Check the KVM for important information as to why the VPS is unable to start. Consult the [KVM guide](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/using-kvm-for-vps.md) for help using this feature in the OVHcloud Control Panel.
- If the KVM is showing the VPS booting or unable to find the disk, ensure you have boot logs enabled. Relay the pertinent logs to our support teams by creating a support request in your [OVHcloud Control Panel](https://manager.us.ovhcloud.com/) for further investigations.
