Disable shell access for unknown users

Suspect there are other users in your system that have shell access to your system? Please follow the below steps to find them and disable the access.

Run the below command to list all users that have shell access to your system.

grep bin/bash$ /etc/passwd

root:x:0:0:root:/root:/bin/bash
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
test2:x:10002:10002::/home/test2:/bin/bash
hduser:x:10003:10003::/home/hduser:/bin/bash
admin:x:10004:10004::/home/admin:/bin/bash
boot:x:0:0:root:/root:/bin/bash
sshusr:x:10006:10006::/home/sshusr:/bin/bash
u1:x:10007:10007::/home/u1:/bin/bash

If you find any unknown users in this list, change the shell of that user to /sbin/nologin by running the below command.

Here I’m going to change the shell of “u1″ user to /sbin/nologin”.

chsh u1

Changing shell for u1.
New shell [/bin/bash]: /sbin/nologin
Shell changed.

This way you can change the shell of a user.

Was this answer helpful?

 Print this Article

Also Read

WHM/cPanel Server Hardening And Security Basics

1. Introduction A step by step paper how to secure linux server with cPanel/WHM andApache...

How to hide your PHP version information?

Like Apache, it is not good to expose your PHP information to the public. Please follow the below...

Is my server hacked? Lets check it with rootkit hunter

RookHit Hunter is a command-line utility that will search your machine for...

Installing Rkhunter (Rootkit Hunter) in RHEL, CentOS and Fedora

Rkhunter (Rootkit Hunter) is an open source Unix/Linux based scanner tool for Linux systems...

Prevent DDoS by using mod_evasive

“mod_evasive” is an evasive maneuvers module for Apache to provide evasive action in...