Remove root user access

Having root user access available is good foundation to have your website(s) or server hijacked. Why well they know username they need to just go through different passwords to try and guess and belive me people do have software and servers doing this so they can gain something out of that theft. Today I just checked my log files and saw some chineese IP's trying to break in. Really what could I do if they do, just cry about it. So first step is remove root user.

So we create new username when logged in as root.

adduser new_user

Add the user to the administer the system (admin) group by entering the following command. Replace new_user with your username:

usermod -a -G sudo new_user

This should add the newuser proper privillegies. Next step is to remove rootuser access, so you go and login as newsuer over your SSH and now write all commands with sudo, so you go.

sudo vi /etc/ssh/sshd_config

To change configuration, if you get here message

User is not in the sudoers file.  This incident will be reported

Then you need to go back to root and do this, you edit

vi /etc/sudoers 

and add

new_user ALL = (ALL) ALL 

Then you go back to the new user ans login over SSH, and then write the line of code we mentioned before

sudo vi /etc/ssh/sshd_config

and change yes to no.

PermitRootLogin no

Then you run

sudo service ssh restart

or if you have some older configuration try

/etc/init.d/ssh restart

.
And this should be it, you have no root access, try it.