Debian Tutorials

Debian Tutorials


Step by step tutorials showing you how to install and configure various applications and services on Debian based Linux distros.

April 2018
M T W T F S S
« Mar    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Categories


Installing vsftpd using text file for virtual users on squeeze/wheezy

Ástþór IPÁstþór IP

vsftpd (Very Secure FTP Daemon) is a secure, fast and stable FTP server. In this tutorial we’ll install the server and make it check in a flat text file for virtual users allowed to login.

1. Install required packages

apt-get install vsftpd libpam-pwdfile

2. Configure vsftpd (pico /etc/vsftpd.conf)

Edit these variables in the config file and leave everything else with the default value.

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
nopriv_user=vsftpd
virtual_use_local_privs=YES
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/$USER
chroot_local_user=YES
hide_ids=YES
guest_username=vsftpd

Set the local_root to the parent directory where the user’s home directories are located

3. Configure PAM to check the passwd file for users (pico /etc/pam.d/vsftpd)

auth required pam_pwdfile.so pwdfile /etc/ftpd.passwd
account required pam_permit.so

Make sure you remove everything else from the file

4. Create the passwd file containing the users

htpasswd -cd /etc/ftpd.passwd user1

You can later add additional users to the file like this:

htpasswd -d /etc/ftpd.passwd user2

5. Create a local user that’s used by the virtual users to authenticate

useradd --home /home/vsftpd --gid nogroup -m --shell /bin/false vsftpd

6. Restart vsftpd

/etc/init.d/vsftpd restart

7. Create user’s home directory since vsftpd doesn’t do it automatically

mkdir /var/www/user1
chown vsftpd:nogroup /var/www/user1
chmod a-w /var/www/user1

Comments 5
  • Hugo
    Posted on

    Hugo Hugo

    Author

    Followed teh tutorial line by line however Vsftpd dont start, I get

    /etc/vsftpd.conf: listen disabled – service will not start


  • Piotrek
    Posted on

    Piotrek Piotrek

    Author

    Trying 127.0.0.1…
    Connected to localhost.
    220 (vsFTPd 2.3.5)
    Name (localhost:root): test
    331 Please specify the password.
    Password:
    530 Login incorrect.
    Login failed.

    Not working under debian 7


  • Michael
    Posted on

    Michael Michael

    Author

    I followed the tutorial step by step too and it worked perfectly. Thanks!


  • Sam
    Posted on

    Sam Sam

    Author

    Everything just fine, except this:
    If you want your user to upload data (chmod 755 /var/www/user1) you’ll face this error message:
    500 OOPS: vsftpd: refusing to run with writable root inside chroot ()
    This is related to the version 2.3.5 that comes with Debian/Wheezy.

    To solve this:
    – remove write permissions from the root folder (/var/www/user1/)
    – add subfolder eg. data (/var/www/user1/data) with write permissions

    The user can upload data in the subfolder now.

    Thanks for the howto, helped a lot!


  • kampungsiber
    Posted on

    kampungsiber kampungsiber

    Author

    Thank’s Writer & Sam, It’s tutorial running well using my tiny machine Raspberry Pi 2 under rasbian wheezy.
    Within nginx webserver, I change folder /var/www/ into /usr/share/nginx/www