By default, Ubuntu disables direct root login via SSH for security reasons. To enable root login via SSH on Ubuntu 22.04, you can follow these steps:
Step 1 : Enable the Root Account
If the root account is not already enabled, set a password for the root user:
Enter a new password for the root account when prompted.
Step 2 : Permit Root Login in SSH Configuration
Edit the SSH server configuration file:
Look for the line that says PermitRootLogin
and change its value to yes
. If the line is commented out (has a #
at the beginning), remove the #
:
Save the changes and exit the text editor.
Step 3 : Restart the SSH Service
Restart the SSH service to apply the changes:
Step 4 : Connect as Root via SSH
You can now connect to your Ubuntu machine using the root account:
Replace your_ubuntu_ip
with the actual IP address of your Ubuntu machine.
Congratulations! You have successfully enabled direct login with the root account via SSH on Ubuntu 22.04.