I know this is possible to log in vsftpd using htpasswd (libpam-pwdfile) but in every tutorials I read, they use virtual user.

My users are not virtual, they are local user I added using "adduser" command, I would like to allow them to log into the FTP server, but using password stored in htpasswd.

How can I do that ? Does this feature only works with virtual users ?


The Linux system normally uses the sudo passwd userid tool for setting the password. A connvenient way to have the same password for both htpassword/htaccess and the Ubuntu System's login accounts is to set the passwords as the same.

A Linux account can't have two different passwords for logging in. However, the same password can be set for two different accounts. To achieve what you have described you would have to set the same password for the two different account... the Linux account and the htpasswd account (which is the web server account).

Performing the latter is often done for convenience.

  • This is wrong, "The only way a normal user can login to Ubuntu is to use the password that is specified in the /etc/shadow file" Authentication occurs via PAM. There is a PAM module called pam_unix which implements that kind of authentication. But there are other modules that implement other things like LDAP. – rovr138 Mar 9 '17 at 18:53
  • Thanks... I updated my answer taking your comment into account. – L. D. James Mar 9 '17 at 18:59
  • The reason I want to make vsftpd use the passwords from a htpasswd file is that I'm managing the users password using PHP. So my users will be able to change their FTP password at anytime using a PHP script which will update the htpasswd file (without the need of sudo). – Artyum Mar 9 '17 at 19:50
  • What I have done in those type of occasions (including having a web page access for users to change their passwords) is to create a C++ wrapper with the suid bit set that would change/update the Linux password after making the htpassword change. – L. D. James Mar 9 '17 at 20:00


To disable anonymous login and to enable local users login and give them write permissions:

# No anonymous login 
# Let local users login 
# If you connect from the internet with local users, you should enable TLS/SSL/FTPS 
# Write permissions 

To allow them to login via the password set in httpasswd, you need a workflow that will automatically update that password.

Create a script, export PATH to these users with the location of this script and automate the workflow. That's all you can do easily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.