Learn how to become the root user and create a password for the root account.
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".
Requirements
- a Public Cloud instance in your OVHcloud account
- access to the OVHcloud Control Panel
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
New password:
Retype new 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 -
~#
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, from the OVHcloud Control Panel:
- Select
Public Cloud
. - Click
Instances
. - Click the more options
...
button next to the corresponding instance. - Select
Instance details
.
Switch to the tab VNC console
.
Open in a new window
.At the command prompt, enter your login as root, then enter your password.
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.
Once done, you should be able to access your server with the root user and password set.
Go further
For more information and tutorials, please see our other Public Cloud support guides or explore the guides for other OVHcloud products and services.