This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
setting-up-vsftpd [2018/12/21 09:45] 171.78.140.145 created |
setting-up-vsftpd [2018/12/21 10:29] (current) 171.78.140.145 |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Setting up VSFTPD with MySQL ====== | ====== Setting up VSFTPD with MySQL ====== | ||
| + | |||
| + | ===== Install PAM MySQL module ===== | ||
| + | |||
| + | <code> | ||
| + | sudo apt-get install libpam-mysql | ||
| + | </code> | ||
| + | |||
| + | ===== Create a database to store usernames and passwords ===== | ||
| + | |||
| + | <code> | ||
| + | CREATE DATABASE ftp; | ||
| + | GRANT ALL PRIVILEGES ON ftp.* TO 'ftp-admin'@'localhost' IDENTIFIED BY 'f7p@dm1n'; | ||
| + | FLUSH PRIVILEGES; | ||
| + | </code> | ||
| + | |||
| + | ===== Edit /etc/vsftpd.conf ===== | ||
| + | |||
| + | <code> | ||
| + | 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 | ||
| + | </code> | ||
| + | |||
| + | ===== Configure the PAM module ===== | ||
| + | |||
| + | <code> | ||
| + | sudo vi /etc/pam.d/vsftpd | ||
| + | </code> | ||
| + | |||
| + | The contents of the file should be | ||
| + | <code> | ||
| + | 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 | ||
| + | </code> | ||
| + | |||
| + | ===== Create users ===== | ||
| + | |||
| + | <code> | ||
| + | insert into accounts(username, password) values('hari', PASSWORD('haripriya')); | ||
| + | </code> | ||
| + | |||
| + | ===== Create user-specific directories ===== | ||
| + | |||
| + | <code> | ||
| + | sudo mkdir /srv/ftp/hari | ||
| + | sudo chown ftp:ftp /srv/ftp/hari | ||
| + | </code> | ||
| + | |||
| + | ===== Restart VSFPTD ===== | ||
| + | <code> | ||
| + | sudo systemctl restart vsftpd | ||
| + | </code> | ||