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

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...

How to disable all Apache header information?

Follow the below steps to disable Apache header information. Edit your mail Apache configuration...

How to secure /tmp and /var/tmp

Secure /tmp Edit /etc/fstab by typing the command nano -w /etc/fstab Paste the following...

How to change default SSH port?

Everyone knows 22 is the default SSH port. So it’s always good to change this default port...

How to Password Protect a Directory

This tutorial will teach how to password protect a directory. Password protecting a directory...