To make an FTP user with limited access to a specific website directory, you can follow these steps:
Create new user for FTP access:
sudo adduser ftpuser
Set a password for the new user.
Create a new group for FTP access:
sudo groupadd ftpaccess
Add the FTP user to the new group:
sudo usermod -aG ftpaccess ftpuser
Change the ownership of the website directory to the new grouup:
sudo chown -R serverpilot:ftpaccess /srv/users/serverpilot/apps/cronegame2/public
Change the permissions of the website directory to allow the new group to read, write, and execute:
sudo chmod -R g+rwx /srv/users/serverpilot/apps/cronegame2/public
Configure vsftpd to allow access only to the specific directory and restrict access to the root directory:
Edit the /etc/vsftpd.conf
file and add the following lines at the end:
# Allow access only to the specific directory
chroot_local_user=YES
local_root=/srv/users/serverpilot/apps/cronegame2/public
# Restrict access to the root directory
userlist_enable=YES
userlist_deny=NO
userlist_file=/etc/vsftpd.allowed_users
Finally create the /etc/vsftpd.allowed_users file and add the FTP user to it:
sudo sh -c "echo 'ftpuser' >> /etc/vsftpd.allowed_users