How to Allow Root Login in Ubuntu 18.04
In Ubuntu 18.04, the root account is typically disabled for security reasons. However, there might be situations where you need to enable root login temporarily. Please note that enabling root login should be done with caution, and it’s recommended to only do so when absolutely necessary. Here’s a step-by-step guide on how to allow root login in Ubuntu 18.04:
Step 1: Set the Root Password Before enabling root login, you need to set a password for the root account. Open a terminal and run the following command:
|
|
You’ll be prompted to enter a new password for the root account. After entering and confirming the password, the root account will have a password associated with it.
Step 2: Edit the SSH Configuration File Now, you need to edit the SSH configuration file to allow root login. You can use a text editor like nano or vim for this purpose. Here, we’ll use nano:
|
|
Look for the line that says PermitRootLogin prohibit-password
within the sshd_config
file. It might be commented out with a ‘#’ at the beginning of the line. Change it to:
|
|
Save your changes and exit the text editor.
Step 3: Restart the SSH Service To apply the changes, you’ll need to restart the SSH service:
|
|
That’s it! You’ve allowed root login in Ubuntu 18.04. However, remember that enabling root login can pose security risks, so it’s essential to use it judiciously and disable it once you’ve finished the task that required it.
Important Security Note:
After you’ve completed your tasks that required root access, it’s highly recommended that you disable root login again for security reasons. You can do this by reversing the changes you made in sshd_config
, setting PermitRootLogin
back to prohibit-password
, and then restarting the SSH service. Additionally, it’s a good practice to use the sudo command with your regular user account for administrative tasks rather than relying on the root account.