0 down vote favorite I've done this (more or less) by the book: http://www.howtoforge.com/virtual-h...uota-and-bandwidth-management-on-ubuntu-12.04 Even have a script that automatically installs the server. But I keep getting the same error (see @ end of post). Please help me out with this: Code: root@ganymede:/etc/pure-ftpd# cat /etc/pure-ftpd/db/mysql.conf MYSQLSocket /var/run/mysqld/mysqld.sock MYSQLUser pureftpd MYSQLPassword XtT0I2EVtUqI5Nxx MYSQLDatabase pureftpd MYSQLCrypt md5 MYSQLGetPW SELECT Password FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MYSQLGetUID SELECT Uid FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MYSQLGetGID SELECT Gid FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MYSQLGetDir SELECT Dir FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") ---- Code: root@ganymede:/etc/pure-ftpd# more conf/* :::::::::::::: conf/AltLog :::::::::::::: clf:/var/log/pure-ftpd/transfer.log :::::::::::::: conf/ChrootEveryone :::::::::::::: yes :::::::::::::: conf/CreateHomeDir :::::::::::::: yes :::::::::::::: conf/DisplayDotFiles :::::::::::::: yes :::::::::::::: conf/DontResolve :::::::::::::: yes :::::::::::::: conf/FSCharset :::::::::::::: UTF-8 :::::::::::::: conf/IPV4Only :::::::::::::: yes :::::::::::::: conf/LimitRecursion :::::::::::::: 5000 500 :::::::::::::: conf/MinUID :::::::::::::: 1000 :::::::::::::: conf/MySQLConfigFile :::::::::::::: /etc/pure-ftpd/db/mysql.conf :::::::::::::: conf/NoAnonymous :::::::::::::: yes :::::::::::::: conf/PAMAuthentication :::::::::::::: no :::::::::::::: conf/PureDB :::::::::::::: /etc/pure-ftpd/pureftpd.pdb :::::::::::::: conf/UnixAuthentication :::::::::::::: no root@ganymede:/etc/pure-ftpd# more auth/* :::::::::::::: auth/30mysql :::::::::::::: /etc/pure-ftpd/db/mysql.conf :::::::::::::: auth/65unix :::::::::::::: no :::::::::::::: auth/70pam :::::::::::::: no ---- Code: root@ganymede:/etc/pure-ftpd# cat /etc/default/pure-ftpd-common # Configuration for pure-ftpd # (this file is sourced by /bin/sh, edit accordingly) # STANDALONE_OR_INETD # valid values are "standalone" and "inetd". # Any change here overrides the setting in debconf. STANDALONE_OR_INETD=standalone # VIRTUALCHROOT: # whether to use binary with virtualchroot support # valid values are "true" or "false" # Any change here overrides the setting in debconf. VIRTUALCHROOT=false # UPLOADSCRIPT: if this is set and the daemon is run in standalone mode, # pure-uploadscript will also be run to spawn the program given below # for handling uploads. see /usr/share/doc/pure-ftpd/README.gz or # pure-uploadscript(8) # example: UPLOADSCRIPT=/usr/local/sbin/uploadhandler.pl UPLOADSCRIPT= # if set, pure-uploadscript will spawn $UPLOADSCRIPT running as the # given uid and gid UPLOADUID= UPLOADGID= ---- Code: root@ganymede:/etc/pure-ftpd# ftp localhost Connected to localhost. 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 1 of 50 allowed. 220-Local time is now 16:36. Server port: 21. 220-This is a private system - No anonymous login 220 You will be disconnected after 15 minutes of inactivity. Name (localhost:dragosc): test 331 User test OK. Password required Password: 530 Login authentication failed Login failed. Remote system type is UNIX. Using binary mode to transfer files. ---- Code: root@ganymede:/etc/pure-ftpd# tail -n 20 /var/log/syslog Mar 19 15:41:24 ganymede pure-ftpd: ([email protected]) [INFO] New connection from 127.0.0.1 Mar 19 15:41:31 ganymede pure-ftpd: ([email protected]) [WARNING] Authentication failed for user [test] Mar 19 15:41:53 ganymede pure-ftpd: ([email protected]) [INFO] Logout. Mar 19 15:57:38 ganymede pure-ftpd: ([email protected]) [INFO] New connection from 127.0.0.1 Mar 19 15:57:47 ganymede pure-ftpd: ([email protected]) [WARNING] Authentication failed for user [test] Mar 19 16:07:49 ganymede dhclient: DHCPREQUEST of 192.168.56.101 on eth1 to 192.168.56.100 port 67 Mar 19 16:07:49 ganymede dhclient: DHCPACK of 192.168.56.101 from 192.168.56.100 Mar 19 16:07:49 ganymede dhclient: bound to 192.168.56.101 -- renewal in 1490 seconds. Mar 19 16:12:47 ganymede pure-ftpd: ([email protected]) [INFO] Timeout - try typing a little faster next time Mar 19 16:17:01 ganymede CRON[3484]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Mar 19 16:32:39 ganymede dhclient: DHCPREQUEST of 192.168.56.101 on eth1 to 192.168.56.100 port 67 Mar 19 16:32:41 ganymede dhclient: DHCPACK of 192.168.56.101 from 192.168.56.100 Mar 19 16:32:41 ganymede dhclient: bound to 192.168.56.101 -- renewal in 1647 seconds. Mar 19 16:36:03 ganymede pure-ftpd: ([email protected]) [INFO] New connection from 127.0.0.1 Mar 19 16:36:13 ganymede pure-ftpd: ([email protected]) [WARNING] Authentication failed for user [test] Mar 19 16:36:56 ganymede pure-ftpd: ([email protected]) [INFO] Logout. With system users it works perfectly. With virtual users, on the other hand... Could you please help with what I'm missing? I know this question is all over the internet & forums, but I still couldn't find the problem. Thanks in advance.
Hi which script you have followed? How did you created the user, inyour case test? I will advice you to use phpmyadmin for creating users. http://yourservername.com/phpmyadmin/ Be cautius for these points:- Whenever you want to create a new user, you have to create an entry in the table ftpd so I will explain the columns of this table here: ftpd Table: User: The name of the virtual PureFTPd user (e.g. exampleuser). status: 0 or 1. 0 means the account is disabled, the user cannot login. Password: The password of the virtual user. Make sure you use MySQL's MD5 function to save the password encrypted as an MD5 string For more details please gothrough the guide tutorial. br// Srijan
@Srijan Hello Srijan, You'll have to follow them in this order: If you see smth that might affect pureftp server, please tell me. This is all written by me. mysql/install.sh Code: #! /bin/bash export MY_PATH="`readlink -f "$0"`" MYSQL_INSTALLER_PATH="`dirname "$MY_PATH"`" source $MYSQL_INSTALLER_PATH/../../lib.sh do_load_config $MYSQL_INSTALLER_PATH do_line if [ ! -f /etc/init.d/mysql ]; then do_line "apt-get install -y mysql-server mysql-client" apt-get install -y mysql-server mysql-client else do_line "MySQL server already installed" fi do_line "+" do_line "MySQL Server: `mysql --version`" do_line do_line 'press ENTER, dude!' 7 read f pureftpd/install.sh Code: #! /bin/bash # http://www.howtoforge.com/virtual-hosting-with-pureftpd-and-mysql-incl-quota-and-bandwidth-management-on-ubuntu-12.04 export MY_PATH="`readlink -f "$0"`" PUREFTP_INSTALLER_PATH="`dirname "$MY_PATH"`" source $PUREFTP_INSTALLER_PATH/../../lib.sh do_load_config $PUREFTP_INSTALLER_PATH source $PUREFTP_INSTALLER_PATH/lib.sh bash $PUREFTP_INSTALLER_PATH/../mysql/install.sh do_line if [ 1 -eq 1 ]; then do_line "apt-get install -y pure-ftpd-mysql" apt-get install -y pure-ftpd-mysql groupadd $PUREFTPD_USER useradd -s /bin/false -d /bin/null -c "pureftpd user" -g $PUREFTPD_USER $PUREFTPD_USER do_mysql_read_password do_line "purftpd mysql user: $PUREFTPD_USER / $PUREFTPD_PASS" cat $PUREFTP_INSTALLER_PATH/install.sql \ | sed -e "s/PUREFTPD_USER/$PUREFTPD_USER/g" \ | sed -e "s/PUREFTPD_PASS/$PUREFTPD_PASS/g" \ | sed -e "s/PUREFTPD_DATA/$PUREFTPD_DATA/g" \ | mysql -uroot -p$MYSQL_ROOT_PASSWORD do_file_backup /etc/pure-ftpd/db/mysql.conf cat $PUREFTP_INSTALLER_PATH/etc/pure-ftpd/db/mysql.conf \ | sed -e "s/PUREFTPD_USER/$PUREFTPD_USER/g" \ | sed -e "s/PUREFTPD_PASS/$PUREFTPD_PASS/g" \ | sed -e "s/PUREFTPD_DATA/$PUREFTPD_DATA/g" \ > /etc/pure-ftpd/db/mysql.conf echo 'yes' > /etc/pure-ftpd/conf/DisplayDotFiles echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone echo "yes" > /etc/pure-ftpd/conf/CreateHomeDir echo "yes" > /etc/pure-ftpd/conf/DontResolve echo "yes" > /etc/pure-ftpd/conf/IPV4Only echo "no" > /etc/pure-ftpd/conf/PAMAuthentication echo '5000 500' > /etc/pure-ftpd/conf/LimitRecursion /etc/init.d/pure-ftpd-mysql restart fi do_line do_line 'press ENTER, dude!' 7 read f pureftpd/install.sql Code: CREATE DATABASE PUREFTPD_DATA; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON PUREFTPD_DATA.* TO 'PUREFTPD_USER'@'localhost' IDENTIFIED BY 'PUREFTPD_PASS'; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON PUREFTPD_DATA.* TO 'PUREFTPD_USER'@'localhost.localdomain' IDENTIFIED BY 'PUREFTPD_PASS'; FLUSH PRIVILEGES; USE PUREFTPD_DATA; CREATE TABLE ftpd ( User varchar(16) NOT NULL default '', status enum('0','1') NOT NULL default '0', Password varchar(64) NOT NULL default '', Uid varchar(11) NOT NULL default '-1', Gid varchar(11) NOT NULL default '-1', Dir varchar(128) NOT NULL default '', ULBandwidth smallint(5) NOT NULL default '0', DLBandwidth smallint(5) NOT NULL default '0', comment tinytext NOT NULL, ipaccess varchar(15) NOT NULL default '*', QuotaSize smallint(5) NOT NULL default '0', QuotaFiles int(11) NOT NULL default 0, PRIMARY KEY (User), UNIQUE KEY User (User) ) ENGINE=MyISAM; pureftpd/lib.sh Code: #! /bin/bash [ "$PUREFTPD_USER" == "" ] && PUREFTPD_USER='pureftpd' [ "$PUREFTPD_PASS" == "" ] && PUREFTPD_PASS=`tr -cd '[:alnum:]' < /dev/urandom | fold -w16 | head -n1` [ "$PUREFTPD_DATA" == "" ] && PUREFTPD_DATA='pureftpd' # # uses mysql/lib.sh # do_pureftp_add_user() { local USER_NAME=$1 local USER_PASS=`tr -cd '[:alnum:]' < /dev/urandom | fold -w16 | head -n1` local USER_HOME=$2 [ "$USER_HOME" == "" ] && USER_HOME="/home/$1" local USER_UID=`id -u $1` local USER_UID=`id -g $1` do_line "adding pureftpd user: $USER_NAME $USER_PASS $USER_HOME $USER_UIG $USER_GID" do_mysql_read_password cat | mysql -uroot -p$MYSQL_ROOT_PASSWORD <<DELIM USE $PUREFTPD_DATA; INSERT INTO ftpd (User, status, Password, Uid, Gid, Dir, ULBandwidth, DLBandwidth, comment, ipaccess, QuotaSize, QuotaFiles) VALUES ('$USER_NAME', '1', MD5('$USER_PASS'), '$USER_UID', '$USER_GID', '$USER_HOME', '0', '0', '', '*', '0', '0'); DELIM } # # uses mysql/lib.sh # do_pureftp_del_user() { local USER_NAME=$1 do_line "deleting pureftpd user: $USER_NAME" do_mysql_read_password cat | mysql -uroot -p$MYSQL_ROOT_PASSWORD <<DELIM USE $PUREFTPD_DATA; DELETE FROM ftpd WHERE User = '$USER_NAME'; DELIM } # # uses mysql/lib.sh # do_pureftp_up_user() { local USER_NAME=$1 local USER_PASS=`tr -cd '[:alnum:]' < /dev/urandom | fold -w16 | head -n1` local USER_HOME=$2 [ "$USER_HOME" == "" ] && USER_HOME="/home/$1" local USER_UID=`id -u $1` local USER_UID=`id -g $1` do_line "updating pureftpd user: $USER_NAME $USER_PASS $USER_HOME $USER_UIG $USER_GID" do_mysql_read_password cat | mysql -uroot -p$MYSQL_ROOT_PASSWORD <<DELIM USE $PUREFTPD_DATA; UPDATE ftpd SET Password = MD5('$USER_PASS'), Uid = '$USER_UID', Gid = '$USER_GID', Dir = '$USER_HOME' WHERE User = '$USER_NAME'; DELIM } pureftpd/user-add.sh Code: #! /bin/bash export MY_PATH="`readlink -f "$0"`" PUREFTP_TOOL_PATH="`dirname "$MY_PATH"`" source $PUREFTP_TOOL_PATH/../../lib.sh do_load_config $PUREFTP_TOOL_PATH/../.. source $PUREFTP_TOOL_PATH/lib.sh source $PUREFTP_TOOL_PATH/../mysql/lib.sh do_line do_pureftp_add_user $1 $2 do_line do_line 'press ENTER, dude!' 7 read f do_line is just an 'echo' function do_mysql_read_password will read a variable used as password for mysql server To add a user I just need to type: Code: bash /path/to/user-add.sh username [/path/to/user/home(this is optional)]
Hi Please follow the Chapter7 of the guide to create the user. I think there is some issue in your script for creating the user. Br// Srijan
Hello Sirjan. Thank you for your support. I'm having trouble with another script just now. Will come back asap with an answer.
Hello guys, still having trouble installing pureftpd. As a note it is not the first time I install it and for my last 3 times it always worked. Anyone have any idea? Code: root@ganymede:/etc/pure-ftpd# ls -la auth/ total 8 drwxr-xr-x 2 root root 4096 Apr 1 15:04 . drwxr-xr-x 5 root root 4096 Apr 1 16:59 .. lrwxrwxrwx 1 root root 23 Dec 14 2011 30mysql -> ../conf/MySQLConfigFile lrwxrwxrwx 1 root root 26 Dec 14 2011 65unix -> ../conf/UnixAuthentication lrwxrwxrwx 1 root root 25 Dec 14 2011 70pam -> ../conf/PAMAuthentication root@ganymede:/etc/pure-ftpd# cd auth/ root@ganymede:/etc/pure-ftpd/auth# more * :::::::::::::: 30mysql :::::::::::::: /etc/pure-ftpd/db/mysql.conf :::::::::::::: 65unix :::::::::::::: no :::::::::::::: 70pam :::::::::::::: no Code: root@ganymede:/etc/pure-ftpd/auth# cd ../conf/ root@ganymede:/etc/pure-ftpd/conf# ls -la total 64 drwxr-xr-x 2 root root 4096 Apr 1 22:03 . drwxr-xr-x 5 root root 4096 Apr 1 16:59 .. -rw-r--r-- 1 root root 36 Dec 14 2011 AltLog -rw-r--r-- 1 root root 4 Apr 1 22:03 ChrootEveryone -rw-r--r-- 1 root root 4 Apr 1 22:03 CreateHomeDir -rw-r--r-- 1 root root 4 Apr 1 22:03 DisplayDotFiles -rw-r--r-- 1 root root 4 Apr 1 22:03 DontResolve -rw-r--r-- 1 root root 6 Dec 14 2011 FSCharset -rw-r--r-- 1 root root 4 Apr 1 22:03 IPV4Only -rw-r--r-- 1 root root 9 Apr 1 22:03 LimitRecursion -rw-r--r-- 1 root root 5 Dec 14 2011 MinUID -rw-r--r-- 1 root root 29 Dec 14 2011 MySQLConfigFile -rw-r--r-- 1 root root 4 Dec 14 2011 NoAnonymous -rw-r--r-- 1 root root 3 Apr 1 22:03 PAMAuthentication -rw-r--r-- 1 root root 28 Dec 14 2011 PureDB -rw-r--r-- 1 root root 3 Dec 14 2011 UnixAuthentication root@ganymede:/etc/pure-ftpd/conf# more * :::::::::::::: AltLog :::::::::::::: clf:/var/log/pure-ftpd/transfer.log :::::::::::::: ChrootEveryone :::::::::::::: yes :::::::::::::: CreateHomeDir :::::::::::::: yes :::::::::::::: DisplayDotFiles :::::::::::::: yes :::::::::::::: DontResolve :::::::::::::: yes :::::::::::::: FSCharset :::::::::::::: UTF-8 :::::::::::::: IPV4Only :::::::::::::: yes :::::::::::::: LimitRecursion :::::::::::::: 5000 500 :::::::::::::: MinUID :::::::::::::: 1000 :::::::::::::: MySQLConfigFile :::::::::::::: /etc/pure-ftpd/db/mysql.conf :::::::::::::: NoAnonymous :::::::::::::: yes :::::::::::::: PAMAuthentication :::::::::::::: no :::::::::::::: PureDB :::::::::::::: /etc/pure-ftpd/pureftpd.pdb :::::::::::::: UnixAuthentication :::::::::::::: no Code: root@ganymede:/etc/pure-ftpd/conf# cd ../db/ root@ganymede:/etc/pure-ftpd/db# cat mysql.conf ############################################## # # # Sample Pure-FTPd Mysql configuration file. # # See README.MySQL for explanations. # # # ############################################## # Optional : MySQL server name or IP. Don't define this for unix sockets. # MYSQLServer 127.0.0.1 # Optional : MySQL port. Don't define this if a local unix socket is used. # MYSQLPort 3306 # Optional : define the location of mysql.sock if the server runs on this host. MYSQLSocket /var/run/mysqld/mysqld.sock # Mandatory : user to bind the server as. MYSQLUser pureftpd # Mandatory : user password. You must have a password. MYSQLPassword FvjcoIeJTZTpA10X # Mandatory : database to open. MYSQLDatabase pureftpd # Mandatory : how passwords are stored # Valid values are : "cleartext", "crypt", "sha1", "md5" and "password" # ("password" = MySQL password() function) # You can also use "any" to try "crypt", "sha1", "md5" *and* "password" MYSQLCrypt cleartext # In the following directives, parts of the strings are replaced at # run-time before performing queries : # # \L is replaced by the login of the user trying to authenticate. # \I is replaced by the IP address the user connected to. # \P is replaced by the port number the user connected to. # \R is replaced by the IP address the user connected from. # \D is replaced by the remote IP address, as a long decimal number. # # Very complex queries can be performed using these substitution strings, # especially for virtual hosting. # Query to execute in order to fetch the password MYSQLGetPW SELECT Password FROM users WHERE User='\L' # Query to execute in order to fetch the system user name or uid MYSQLGetUID SELECT Uid FROM users WHERE User='\L' # Optional : default UID - if set this overrides MYSQLGetUID #MYSQLDefaultUID 1000 # Query to execute in order to fetch the system user group or gid MYSQLGetGID SELECT Gid FROM users WHERE User='\L' # Optional : default GID - if set this overrides MYSQLGetGID #MYSQLDefaultGID 1000 # Query to execute in order to fetch the home directory MYSQLGetDir SELECT Dir FROM users WHERE User='\L' # Optional : query to get the maximal number of files # Pure-FTPd must have been compiled with virtual quotas support. # MySQLGetQTAFS SELECT QuotaFiles FROM users WHERE User='\L' # Optional : query to get the maximal disk usage (virtual quotas) # The number should be in Megabytes. # Pure-FTPd must have been compiled with virtual quotas support. # MySQLGetQTASZ SELECT QuotaSize FROM users WHERE User='\L' # Optional : ratios. The server has to be compiled with ratio support. # MySQLGetRatioUL SELECT ULRatio FROM users WHERE User='\L' # MySQLGetRatioDL SELECT DLRatio FROM users WHERE User='\L' # Optional : bandwidth throttling. # The server has to be compiled with throttling support. # Values are in KB/s . # MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User='\L' # MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User='\L' # Enable ~ expansion. NEVER ENABLE THIS BLINDLY UNLESS : # 1) You know what you are doing. # 2) Real and virtual users match. # MySQLForceTildeExpansion 1 # If you're using a transactionnal storage engine, you can enable SQL # transactions to avoid races. Leave this commented if you are using the # traditionnal MyIsam engine. # MySQLTransactions On Code: mysql> use pureftpd; Database changed mysql> select * from ftpd; +------+--------+----------+------+------+------------+-------------+-------------+---------+----------+-----------+------------+ | User | status | Password | Uid | Gid | Dir | ULBandwidth | DLBandwidth | comment | ipaccess | QuotaSize | QuotaFiles | +------+--------+----------+------+------+------------+-------------+-------------+---------+----------+-----------+------------+ | test | 1 | test | 1000 | 1000 | /home/test | 1000 | 1000 | | * | 32767 | 2147483647 | +------+--------+----------+------+------+------------+-------------+-------------+---------+----------+-----------+------------+ 1 row in set (0.00 sec) Code: root@ganymede:/home# ls -la total 4 drwxr-xr-x 4 root root 31 Apr 1 22:17 . drwxr-xr-x 26 root root 4096 Apr 1 12:12 .. drwxr-xr-x 6 test test 46 Apr 1 16:56 test Code: root@ganymede:/etc/pure-ftpd/db# ftp localhost Connected to localhost. 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 2 of 50 allowed. 220-Local time is now 22:14. Server port: 21. 220-This is a private system - No anonymous login 220 You will be disconnected after 15 minutes of inactivity. Name (localhost:root): test 331 User test OK. Password required Password: 530 Login authentication failed Login failed. Remote system type is UNIX. Using binary mode to transfer files. ftp>