Linux, Operating System

Prevent User SSH Login to Linux

prevent-user-ssh-login

When you want to share your Linux user account to allow other user to access your computer for specific tasks.
For example, login your FTP (Ignore the anonymous login)
You will provide the user account name and password for other user.
However, on that time your system will be in danger if the user wants to access to your computer with other daemon, such as SSH.

Prevent User SSH Login to Linux
Sharing account for public user to access into your FTP Server

Prevent User SSH Login to Linux
Somehow, public user can access to your system by using other daemon, such as SSH.
Public user can destroy your data

So, how to prevent that situation ?
Shutdown your SSHD is one of method, but if you need to remote control to your computer.
This is not a good idea.

Before you launch the daemon or user account.
You should limit the user account permissions.

Prevent User SSH Login to Linux
Type

sudo gedit /etc/passwd

(use any text editor to open /etc/passwd with root permission)

Prevent User SSH Login to Linux
Search your target user accounts to modify the user account which you would like to limit its permissions.

Prevent User SSH Login to Linux
modify /bin/bash to /sbin/nologin

Prevent User SSH Login to Linux
And now try to access the computer with SSH.
However, you should no longer to access the specific accounts.