How to Disable Root SSH Access on CentOS 7



First, create an alternate user instead of using the default "root"

useradd doneill
Second, set a password for this user

passwd doneill 
Third, give sudo permission for this user. For that go this file

visudo
Add permission to your user  like this. Here the user name is doneill




Now check whether you can run the sudo command with username as doneill 

  1.  su doneill
  2.  sudo ls


If things work good, continue

Now prevent SSH login as root user.

vi  /etc/ssh/sshd_config
Search for "Permit" word



to



Now restart your ssh service by below command

service sshd restart

Thats it.

Now please check what you have done is working fine. Don't logout now, first make sure everything is working fine.


type 

ssh doneill@your systemip

and give the password and check if the user login works fine.



Comments

Popular posts from this blog

Postgresql Hacked ? - FATAL: pg_hba.conf rejects connection for host "127.0.0.1", user "postgres", database "", SSL on

AWS RDS