Type the following command to disable shell access for tom:
# chsh -s /sbin/nologin {username}
# chsh -s /sbin/nologin tom
Sample Outputs:
Changing shell for tom
Shell changed.
Where,
If you have VSFTPD ftp server or other FTP server add user to /etc/ftpusers or /etc/vsftpd/ftpusers (VSFTPD) file.
# echo tom >> /etc/ftpuser
OR
# echo tom >> /etc/vsftpd/ftpusers
Any user name added to /etc/ftpusers or /etc/vsftpd/ftpusers will
prevent them from logging into FTP. However, this will still allow user
to login via email (webmail or pop3 / IMAP) and download emails without
shell access.
Apart from above two method Linux supports pam and access.conf login tables.
Pam modules can be used to enable or disable access to certain
services such as vsftpd, ssh, and so on. /etc/security/access.conf act
as login access control table, which is useful to deny or login access
based upon ip address, network location or tty name. When someone logs
in, the file is scanned for the first entry that matches the (user,
host) combination, or, in case of non-networked logins, the first entry
that matches the (user, tty) combination. The permissions field of that
table entry determines whether the login will be accepted or refused.
See how to use pam modules to enable or disable login access. For e.g. deny access to tom, enter the following in /etc/security/access.conf
- : tom : ALL
Where,