To disable root login ssh access on Ubuntu 22.04, you need to add “PermitRootLogin no” to the SSH configuration file, you can do this by opening the ssh configuration file using the command sudo nano /etc/ssh/sshd_config on terminal window.
In this tutorial, we will show you how to disable root login ssh access on ubuntu 22.04. And as well as, we will also provide video guide for it.
How to Disable SSH ROOT Login on Ubuntu 22.04
Here are steps for disabling ssh root login on Ubuntu 22.04:
Step 1: Start the Terminal Window and Switch to the Root User
Firstly, press ctrl + alt + t on the keyboard to start the terminal window.
Next, type this command on terminal to switch to root user:
sudo -i
Step 2: Edit the SSH configuration File
Now, Edit the ssh configuration file, you can use this on this command terminal:
sudo nano /etc/ssh/sshd_config
Step 3: Search the PermitRootLogin line
Now to disallow ssh root user login access, you need to search “PermitRootLogin” in the configuration file:
#LoginGraceTime 2m PermitRootLogin yes #StrictModes yes #MaxAuthTries 6
Step 4: Change PermitRootLogin to no
To Disable root login access ssh, you need to change PermitRootLogin yes to no in the configuration file:
#LoginGraceTime 2m PermitRootLogin no #StrictModes yes #MaxAuthTries 6
Save and close this file from terminal.
Step 5: Restart ssh Services
Type these commands on terminal window to restart the ssh service:
# systemctl restart sshd OR # /etc/init.d/sshd restart
Here is the video for Disable Root Login SSH Ubuntu 22.04
Conclusion
That’s it, you’ve now disabled the SSH root user login. You will no longer be able to access root user login. You can also see this by trying it.