Leave a comment

Disable SSH root Login |Disable Direct Root Login Linux

To Allow Root Login remotely is a big risk for your server and it can be hacked.

For security reason it is recommenced to disable root login. you can follow below steps to disable root login.

You can create a user different with root access and disable root login for externally.

$ adduser mynewuser
$ passwd mynewuser (generate strong password)

To Assign Root priviliages to your user:

$ visudo
$ mynewuser ALL=(ALL) ALL

Login into your server with root login and manually edit /etc/ssh/sshd_config and change PermitRootLogin to “no

$ /etc/ssh/sshd_config

See uncommitted line below:

#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

Then restart SSH in by typing

$ service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]

Now verify it again

$ ssh myipaddress or mydomain.com -l root

IT should give you output like:

Permission denied, please try again… 

 

Leave a Reply

Your email address will not be published. Required fields are marked *