{"id":20941,"date":"2016-12-09T07:39:55","date_gmt":"2016-12-09T13:39:55","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=20941"},"modified":"2022-06-03T03:42:28","modified_gmt":"2022-06-03T08:42:28","slug":"easy-ftp-vsftpd-server-with-virtual-users-on-debian-8-jessie","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/easy-ftp-vsftpd-server-with-virtual-users-on-debian-8-jessie\/","title":{"rendered":"Easy vsFTPD – FTP server with virtual users on Debian 8 Jessie"},"content":{"rendered":"
<\/p>\n
In this tutorial, we will show you how to easily create an FTP server with virtual users using the vsFTP daemon on Debian 8.<\/p>\n
First things first. Update your Debian VPS<\/a>:<\/p>\n If you don’t have Apache2 webserver or if you are using NGINX, you will have to install Install the vsftpd service:<\/p>\n Edit the vsftpd configuration file and uncomment the bellow lines. Use Next, we should modify our First, create a backup of the file and then edit the existing one:<\/p>\n Remove everything from the file and add these lines instead:<\/p>\n Create the main user that will be used by the virtual users to authenticate:<\/p>\n Once that is done we can create our users\/passwords file. Add another user and append it to the ftpd.passwd file. The Next, add the directories for the users since vsftpd will not create them automatically.<\/p>\n Finally, start the vsftp daemon and set it to automatically start on system boot.<\/p>\n Check the status to make sure the service is started:<\/p>\n# apt-get update && apt-get upgrade<\/pre>\n
apache2-utils<\/code> which is needed to generate passwords for the users.<\/p>\n
# apt-get install apache2-utils<\/pre>\n
# apt-get install vsftpd libpam-pwdfile<\/pre>\n
vim<\/code> or
nano<\/code>. The lines that are not present in the conf file, put them at the bottom.<\/p>\n
# vim \/etc\/vsftpd.conf\r\n\r\nlisten=YES\r\nlisten_ipv6=NO\r\nanonymous_enable=NO\r\nlocal_enable=YES\r\nwrite_enable=YES\r\nlocal_umask=022\r\nnopriv_user=vsftpd\r\nchroot_local_user=YES\r\nallow_writeable_chroot=yes\r\nguest_username=vsftpd\r\nvirtual_use_local_privs=YES\r\nguest_enable=YES\r\nuser_sub_token=$USER\r\nlocal_root=\/var\/www\/$USER\r\nhide_ids=YES\r\n\r\n# Exclude this if you are doing this guide on your own private server\r\nseccomp_sandbox=NO \r\n<\/pre>\n
\/etc\/pam.d\/vsftpd<\/code> file to check the users\/passwords file that we are about to create.<\/p>\n
# cp \/etc\/pam.d\/vsftpd{,.bak}\r\n\r\n# vim \/etc\/pam.d\/vsftpd<\/pre>\n
auth required pam_pwdfile.so pwdfile \/etc\/ftpd.passwd\r\naccount required pam_permit.so\r\n<\/pre>\n
# useradd --home \/home\/vsftpd --gid nogroup -m --shell \/bin\/false vsftpd<\/pre>\n
\nNote: The passwords used by this method can be up to 8 characters long. If you wish vsftpd to read stronger passwords you might want to search for a different pam module.<\/p>\n# htpasswd -cd \/etc\/ftpd.passwd rosetest1<\/pre>\n
-c<\/code> flag is omitted here.<\/p>\n
# htpasswd -d \/etc\/ftpd.passwd rosetest2<\/pre>\n
## For rosetest1\r\n# mkdir \/var\/www\/rosetest1\r\n# chown vsftpd:nogroup \/var\/www\/rosetest1\r\n# chmod +w \/var\/www\/rosetest1\r\n\r\n## For rosetest2\r\n# mkdir \/var\/www\/rosetest2\r\n# chown vsftpd:nogroup \/var\/www\/rosetest2\r\n# chmod +w \/var\/www\/rosetest2\r\n<\/pre>\n
# systemctl start vsftpd && systemctl enable vsftpd<\/pre>\n
# systemctl status vsftpd\r\n\u25cf vsftpd.service - vsftpd FTP server\r\nLoaded: loaded (\/lib\/systemd\/system\/vsftpd.service; enabled)\r\nActive: active (running) since Sat 2016-12-03 11:07:30 CST; 23min ago\r\nMain PID: 5316 (vsftpd)\r\nCGroup: \/system.slice\/vsftpd.service\r\n\u251c\u25005316 \/usr\/sbin\/vsftpd \/etc\/vsftpd.conf\r\n\u251c\u25005455 \/usr\/sbin\/vsftpd \/etc\/vsftpd.conf\r\n\u2514\u25005457 \/usr\/sbin\/vsftpd \/etc\/vsftpd.conf\r\n<\/pre>\n
Test your setup<\/h2>\n