mysql virtual users with unix users
Now in case we need to store the password of the user in the mysql database then we need to add the following steps
step 1: we copy the pureftpd-mysql.conf from /usr/local/src/pureftpd-msql.conf ====> to /usr/local/pureftpd/etc/.
the pureftpd-mysql.conf has the following details:
#MYSQLServer localhost
#MYSQLPort 3306
MYSQLSocket /tmp/mysql.sock
MYSQLUser root
MYSQLPassword agnello
MYSQLDatabase pureftpd
MYSQLCrypt MD5
MYSQLGetPW SELECT Password FROM ftpd WHERE User="\L"
MYSQLGetUID SELECT Uid FROM ftpd WHERE User="\L"
MYSQLGetGID SELECT Gid FROM ftpd WHERE User="\L"
MYSQLGetDir SELECT Dir FROM ftpd WHERE User="\L"
step 2 : we create a data base in mysql ( pureftpd )
mysql -u root -password
create database pureftpd;
use pureftpd;
CREATE TABLE ftpd (
User VARCHAR(16) BINARY NOT NULL,
Password VARCHAR(64) BINARY NOT NULL,
Uid VARCHAR(11) NOT NULL default '-1',
Gid VARCHAR(11) NOT NULL default '-1',
Dir VARCHAR(128) BINARY NOT NULL,
PRIMARY KEY (User)
);
quit;
step 3: we create a directory where all our domains will be stored say /etc/website
the permission i wll be as follows ( these are just the basic )
[root@linux-test pure-ftpd-1.0.21]# ll /home/
drwxr-xr-x 5 root root 4096 May 20 17:30 website
step 4 : now suppose we have to creat a user for a domain called silly .com
1. lets create a unix user
useradd -d /home/website/silly.com -s /sbin/nologin silly
2. then we add the virtual user ( with password ) in the the mysql database ( usning phpmyadmin )
user: silly
password ( MD5 ): silly123
uid : silly
gid : sil ly
dir: /home/website/silly.com
step 5: now we start the ftpd daemon
/usr/local/pureftpd/sbin/pure-ftpd -lmysql:/usr/local/pureftpd/etc/pureftpd-mysql.conf -l unix -j /home/websites &
can view the log with tail -f /var/log/messages
now try to log in ftp://192.168.0.244 with username and password
--
No comments:
Post a Comment