how to deny root ssh access in linux server
how to deny root ssh access in linux server
For security point of view we generally restrict root direct ssh access in server.But keep in mind you also must have user who can access the server other than root.
So before doing this practical ,check if you have access to server with other user or else create a new user with password.
So before doing this practical ,check if you have access to server with other user or else create a new user with password.
1
2
3
|
useradd username
passwd username
|
OK, now restrict the root from ssh follow the given below steps
Step 1 : Take the backup of sshd_config file
1
|
cp -p /etc/ssh/sshd_config /etc/ssh/sshd_config.backup
|
Step 2: Edit the sshd_config file and search for keyword PermitRootLogin
Bydefault PermitRootLogin is yes. Change the PermitRootLogin yes to no
Bydefault PermitRootLogin is yes. Change the PermitRootLogin yes to no
1
2
3
|
vi /etc/ssh/sshd_config
PermitRootLogin no
|
Step 3: After this change restart the ssh service.
1
2
3
4
5
6
7
|
In CentOs and Red Hat
/etc/init.d/sshd restart
In Debian and Ubuntu
/etc/init.d/ssh restart
|
Now you can check it, use command
ssh root@server-ip-Or-FQDN
No comments:
Post a Comment