sudo apt-get install libpam-mysql
CREATE DATABASE ftp; GRANT ALL PRIVILEGES ON ftp.* TO 'ftp-admin'@'localhost' IDENTIFIED BY 'f7p@dm1n'; FLUSH PRIVILEGES;
listen=YES anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES nopriv_user=ftp chroot_local_user=YES secure_chroot_dir=/var/run/vsftpd pam_service_name=vsftpd rsa_cert_file=/etc/ssl/certs/vsftpd.pem guest_enable=YES guest_username=ftp local_root=/srv/ftp/$USER user_sub_token=$USER virtual_use_local_privs=YES user_config_dir=/etc/vsftpd_user_conf
sudo vi /etc/pam.d/vsftpd
The contents of the file should be
auth required pam_mysql.so user=ftp passwd=f7p@dm1n host=localhost db=ftp table=accounts usercolumn=username passwdcolumn=password crypt=2 account required pam_mysql.so user=ftp passwd=f7p@dm1n host=localhost db=ftp table=accounts usercolumn=username passwdcolumn=password crypt=2
insert into accounts(username, password) values('hari', PASSWORD('haripriya'));
sudo mkdir /srv/ftp/hari sudo chown ftp:ftp /srv/ftp/hari
sudo systemctl restart vsftpd