Score:0

vsftpd - restrict users to custom directory not working in Ubuntu 18.04

cn flag

I have an Ubuntu 18.04 server and I installed vsftpd.

I created a new FTP user following this tutorial: https://devanswers.co/installing-ftp-server-vsftpd-ubuntu-18-04/

I want to lock the user to the folder: /var/www/html/mydomain.com/ but I am unable, no matter what I set in the /etc/vsftpd.conf file.

I tried for example these suggestions:

write_enable=YES
local_umask=022
chroot_local_user=YES
allow_writeable_chroot=YES

I also tried adding:

local_root=/

or

local_root=/var/www/html/mydomain.com/

The user can login successfully but I am unable to lock it to any folder. Any advice will be great. Thanks.

cn flag
I updated the title, it's Ubuntu 18.04
Score:0
cn flag

After hours of searching, I found the answer by myself:

run in terminal:

sudo nano /etc/ssh/sshd_config

At the end of the file add:

Match User yourusername
ForceCommand internal-sftp
PasswordAuthentication yes
ChrootDirectory /var/www/html/yourdomain.com/
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no

Replace yourusername with the name of the ftp user that you created and also replace the ChrootDirectory path.

run in terminal:

sudo systemctl restart sshd

More details here: https://www.digitalocean.com/community/tutorials/how-to-enable-sftp-without-shell-access-on-ubuntu-18-04

riahc3 avatar
vn flag
Your answer is for SSH, not for FTP
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.