Linux Disable Shell / FTP Access For a User Account

To disable shell and FTP access for a user account in Linux, you can change the user’s shell to a restricted shell, such as /bin/false or /usr/sbin/nologin. This will prevent the user from logging in and running any commands on the system. Additionally, you may need to modify the user’s FTP configuration to prevent them from accessing the system via FTP.

Here are the steps to disable shell and FTP access for a user account in Linux:

  1. Open a terminal or SSH session to the Linux system.
  2. Type the following command to change the user’s shell to /bin/false:
sudo chsh -s /bin/false <username>

Replace <username> with the name of the user account that you want to disable.

Alternatively, you can change the user’s shell to /usr/sbin/nologin with the following command:

sudo chsh -s /usr/sbin/nologin <username>
  1. If the user has FTP access to the system, you will need to modify their FTP configuration to prevent them from accessing the system via FTP. The exact steps for doing this will depend on the FTP server that you are using. In general, you can modify the user’s FTP configuration file to restrict their access.

For example, if you are using vsftpd, you can modify the user’s configuration file with the following command:

sudo vi /etc/vsftpd/user_config/<username>

In the user’s configuration file, you can set the following options to restrict their access:

local_enable=NO
write_enable=NO

This will disable local FTP access and prevent the user from uploading or modifying files on the system.

  1. Save the user’s configuration file and restart the FTP server to apply the changes.

That’s it! You have successfully disabled shell and FTP access for a user account in Linux by changing their shell to a restricted shell and modifying their FTP configuration.

Leave a Comment