Linux – Jail Linux user to directory for FTP login

ftpgroupslinuxusers

I'm planning on using vsftpd to act as a secure ftp server, but I am having
difficulty controlling the linux users that will be used as ftp logins.

The users are required to be "jailed" into a specific directory (and
subdirectories) and have full read/write access.

Requirements:
– User account "admin_ftp" should be jailed to /var/www directory.
– Other accounts will be added as needed, for each site… e.g:
– User account "picturegallery_ftp" should be jailed to /var/www/picturegallery.com directory.

I have tried the following, but to no avail:

# Group to store all ftp accounts in.
groupadd ftp_accounts
# Group for single user, with the same name as the username.
groupadd admin_ftp

useradd -g admin_ftp -G ftp_accounts admin_ftp
chgrp -R ftp_accounts /var/www
chmod -R g+w /var/www

When I log into FTP using account admin_ftp, I am given the error message:

500 OOPS: cannot change directory:/home/admin_ftp

But didn't I specify the home directory?

Extra internets for a guide how to do this specifically for vsftpd 🙂

Best Answer

My first response is simple:

Don't use FTP unless you absolutely have to. It's not secure, and there's no reason in this day in age to use it.

Instead, use SSH and/or SCP and/or SFTP (all similar and related protocols).

As far as how to do it, there are a fair number of them. I'll link to a few google search results (Not vouching for any of these):

There are tons more, just search around...