Become the root user and select a password

This guide will show you how to become the root user and create a password for the root account

Last updated 24th March 2022

Objective

To perform certain administrative functions on your server (e.g. installing packages), you'll need to have a high level of user access. On Linux servers, this access is called "root".

This guide explains how to become the root user and create a password for the root account.

Requirements

Instructions

Setting the root password

First, establish an SSH connection to your server with your default user.

At the command line, set a password for the root user (for security reasons, the password will not be shown as you type it):

~$ sudo passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated 
successfully

Update the system (Debian/Ubuntu)

To update the installed software packages on your server, type the following command at the command line:

~$ sudo apt update && sudo apt upgrade -y

Update the system (CentOS/Fedora)

To update your server's operating system, type the following command at the command line:

~$ sudo yum update

Become root

To become the root user, type the following command at the command line:

~$ sudo su -
~#

Next, enter the root password.

Enable root login and password authentication

For connections via the built-in VNC console in the OVHcloud Control Panel

First, set the root password.

Next, access the VNC console on the manager:

Click on the ... button next to the corresponding instance and then click on Instance details.

acces instance

Switch to the tab VNC console. At the command prompt, enter your login as root, then enter your password.

vnc

For connections using Linux terminals

First, set the root password.

Next, enable root login and password authentication in your sshd_config file:

~$ sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config

~$ sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config

Restart the SSH service:

~$ service sshd restart

Once done, you should be able to access your server with the root user and password set.

For connections using Putty

First, set the root password.

Next, enable root login and password authentication in your sshd_config file:

~$ sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config

~$ sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config

Restart the SSH service:

~$ service sshd restart

In the Putty authentication agent (pageant key list), remove your private SSH key.

Remove private key

Once done, you should be able to access your server with the root user and password set.

Go further

Join our community of users on https://community.ovh.com/en/.


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