How to disable Root User LoginGOZEN HOST
Step 1: Creating A New User
First of all, you would want to create a new user and make sure you can ssh to your server, before you lock the root user out.
You can add a new user by using the adduser command, you can name this new account anything you want but on our example here, we are going to use the gzsupport name
Once you’ve done that you need to set a password for that user, for that you need to fire the following command.
Make sure you type your password carefully and ….as always try to make the new password something not so easy to guess for everyone.
Before restarting the sshd service (in order for our changes to take effect) don’t forget that you need to add the new user to the Wheel Group
Find the line called “Wheel” and add your new user account to the existing line (be sure to follow the existing format of other lines, and add a comma where necessary), save your changes and close the file.
Step 2: Modifying The sshd_config File
Just to be on the safe side, it’s better to create a backup of the original sshd_confing file
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup
When connected to the server as root using your favorite text editor to open the sshd configuration file (/etc/ssh/sshd_config). For this tutorial, we will use nano.
With the file open, use Ctrl+W to find the line labeled PermitRootLogin. It will most likely be commented out using the # symbol as you can see on your first image.
We will need to remove the # symbol to make the line active and then change “yes” to “no”, then press Ctrl+O and save the file (Ctrl+X to exit the editor).
Now we will need to restart SSH to apply the new settings with the following command
service sshd restart