Deny FTP user access to SFTP and SSH

Last updated on

You may have a case where you’ve added an FTP user to allow file transfer using vsftpd FTP server for example, but don’t want them to have access to SFTP/SSH.

To prevent users from logging into via SSH or SFTP, you can simply add their username to the SSH config file.

Open the SSH config in nano.

sudo nano /etc/ssh/sshd_config

Add the following to the bottom of the file replacing user_name with the user you want to deny SSH and SFTP access. (To paste in nano, press the right mouse button).

Be very careful you don’t enter your root username here, or any username you use to access SSH or you could get locked out of SSH permanently.

/etc/ssh/sshd_config
DenyUsers user_name

To save file and exit, press CTRL + X, press Y and then press ENTER.

Restart the SSH service.

sudo service sshd restart

The user will now be denied access via SSH/SFTP but should still be able to log in to the FTP server to transfer files.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

Leave a reply

Your email address will not be published. Required fields are marked *