How to Enable Root Login on a Linux Server?
Sometimes, when managing a Linux server, you might need direct root access via the SSH console or SFTP file access. By default, this function is disabled for security reasons, but in specific cases, it may be necessary to temporarily enable root login. In this tutorial, you’ll learn how to easily enable or disable root login on a VPS or dedicated Linux server.
Preparation
Before starting the configuration, connect to your Linux server via SSH (e.g., using “PuTTY”). Enter your server's IP address and log in with a regular user account.
Editing the SSH Configuration
Open the SSH configuration file using the following command:
sudo nano /etc/ssh/sshd_config
To edit system files, you need root privileges, which is why we use the sudo prefix. After running the command, enter your user password to authorize file editing.
Enabling the Root User
Using the “nano” text editor, navigate the file using your keyboard's arrow keys.
To enable root login, locate the following line:
#PermitRootLogin prohibit-password
And change it to:
PermitRootLogin yes
Finally, save the configuration changes:
• To save the file, press: “CTRL + X”
• Confirm saving by typing “Y” and pressing “Enter”
Disabling the Root User
To disable root login, edit the same line:
PermitRootLogin yes
And change it to:
PermitRootLogin no
Save the changes the same way as described above.
Restarting the SSH Service
After making the configuration changes, you need to restart the SSH service for them to take effect. Enter the following command:
sudo systemctl restart sshd
Testing changes
You can now try logging in as the root user using “PuTTY” (SSH) or an FTP program:
ssh root@serverio_ip
If you enabled root login, the connection should succeed. If you disabled it, the login attempt should fail.
So, to enable or disable root login on a Linux server, you only need to run a few simple commands. If you run into any issues, feel free to contact our live support or email us at:
[email protected]