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

Installing and configuring Spamassassin on CentOS

If you run your own mail server you'll want it to run spam filtering software to reduce the...

How to prevent DDoS attack with csf?

First make sure DDOS attack is not from open recursive DNS settings. To check and fix that issue...

25 Most Frequently Used Linux IPTables Rules Examples

In the below examples we are using ETH0 as network interface, however if you are using our...

How to Secure PHP from php.ini

PHP's default configuration file, php.ini (usually found in /etc/php.ini on most Linux systems)...

what is eXploit Scanner (cxs)

eXploit Scanner (cxs) is a new tool from Configserver that performs active scanning of files as...