# Pureftpd login problem



## guldhammer (Dec 29, 2007)

Hello.

First a warm thanks from Denmark. I really like the guides from this website.

First with a empty computer, I followed the http://www.howtoforge.com/perfect_setup_debian_etch guide, from chapter 1 to 7, 10 to 13 and 15 to 18.

It works, apache, mysql, phpmyadmin and so on. Works really good.

Then I followed the http://www.howtoforge.com/debian_etc...pd_mysql_quota, from chapter 3 (the system has mysql installed from above guide).

This works also pretty nice, but - when I adds a user via mysql and tries to login with the specified username/password - I get a login failure. It seems that the ftp server aproves my username but not the password.

I did a guide walk through several times, but all information seems to follow the guide. 

Does any one have a solution.

(excuse my bad english)

Info on login try:
Connecting to 86.58.131.183:21
Connected to 86.58.131.183:21 in 0.015625 seconds, Waiting for Server Response
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 13:14. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Host type (1): Automatic Detect
USER webhost
331 User webhost OK. Password required
PASS (hidden)
530 Login authentication failed

Mysql info:
webhost 1 test 2008 2008 /www/webhost4u 100 100 * 50 0


----------



## Deleriux (Dec 28, 2007)

Open this file in vim or another text editor.
vi /etc/my.cnf

Add the following line after 
[mysqld]
log=/var/lib/mysql/general.log

Restart the mysql service.

For consistency restart the pureftpd service.

Attempt a login to your ftp service. If it fails thats OK.

Go to the file /var/lib/mysql/general.log

Here you will see a list of all the queries that were sent to mysql - including the query (if it was sent at all) including the username and the password for the FTP client.

If it is there, manually run the query in SQL to see what happens. If you dont get anything back but the password is correct there is likely a structuring error in the way the database was built I.E a table not available or a column not added.

If you dont get a SQL query logged to that file then that suggests that Pureftpd isnt communicating at all with MySQL, so recheck your configuration files for pureftpd (and its log files) to make sure it connects to MySQL and if not why it does not connect.

Once your done, remove the line you added to /etc/my.cnf and restart MySQL/PureFTPD. You dont want to run that log contstantly both for security reasons (it contains passwords) and performance ones (youll fill you disk up in no time).

Good luck!


----------



## guldhammer (Dec 29, 2007)

SELECT password FROM ftpd WHERE User="webhost" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "**IP**")

I did a manual query with the password line. I got the password back, just in md5 crypted text just like my settings are. I still can't login because the password is still wrong.


----------



## Deleriux (Dec 28, 2007)

The problem is not with your MySQL then. Check access for the user webhost, does it have a home directory it can access?

Check the logs for pureftpd (probably in /var/log) they will indicate the reason why that user cannot login.


----------



## guldhammer (Dec 29, 2007)

Deleriux said:


> The problem is not with your MySQL then. Check access for the user webhost, does it have a home directory it can access?
> 
> Check the logs for pureftpd (probably in /var/log) they will indicate the reason why that user cannot login.


Mmm, the only log for pureftpd there is, are a transfer.log but it's empty.


----------



## Deleriux (Dec 28, 2007)

Check your syslog.

Depending on distro that is /var/log/messages or /var/log/syslog.


----------



## guldhammer (Dec 29, 2007)

Deleriux said:


> Check your syslog.
> 
> Depending on distro that is /var/log/messages or /var/log/syslog.


There is something here
i can see a failure here:
[WARNING] Wrong SQL parameters : [SELECT Dir FROM ftpd WHERE User="webhost" AND status="1" AND (ipaccess = "*" AND (ipaccess = "*" OR ipaccess LIKE "87.49.60.102")]

Dec 30 00:46:42 guldsrv pure-ftpd: ([email protected]) [INFO] New connection from 0x57313c66.hrnxx13.adsl-dhcp.tele.dk
Dec 30 00:46:42 guldsrv pure-ftpd: ([email protected]) [WARNING] Wrong SQL parameters : [SELECT Dir FROM ftpd WHERE User="webhost" AND status="1" AND (ipaccess = "*" AND (ipaccess = "*" OR ipaccess LIKE "87.49.60.102")]
Dec 30 00:46:42 guldsrv pure-ftpd: ([email protected]) [INFO] PAM_RHOST enabled. Getting the peer address
Dec 30 00:46:44 guldsrv pure-ftpd: ([email protected]) [WARNING] Authentication failed for user [webhost]
Dec 30 00:46:49 guldsrv pure-ftpd: ([email protected]) [WARNING] Wrong SQL parameters : [SELECT Dir FROM ftpd WHERE User="webhost" AND status="1" AND (ipaccess = "*" AND (ipaccess = "*" OR ipaccess LIKE "87.49.60.102")]
Dec 30 00:46:49 guldsrv pure-ftpd: ([email protected]) [INFO] PAM_RHOST enabled. Getting the peer address
Dec 30 00:46:51 guldsrv pure-ftpd: ([email protected]) [WARNING] Authentication failed for user [webhost]
Dec 30 00:47:01 guldsrv pure-ftpd: ([email protected]) [INFO] Logout.

Dec 30 00:53:30 guldsrv pure-ftpd: ([email protected]) [INFO] New connection from 0x57313c66.hrnxx13.adsl-dhcp.tele.dk
Dec 30 00:53:30 guldsrv pure-ftpd: ([email protected]) [WARNING] Wrong SQL parameters : [SELECT Dir FROM ftpd WHERE User="webhost" AND status="1" AND (ipaccess = "*" AND (ipaccess = "*" OR ipaccess LIKE "87.49.60.102")]
Dec 30 00:53:30 guldsrv pure-ftpd: ([email protected]) [INFO] PAM_RHOST enabled. Getting the peer address
Dec 30 00:53:32 guldsrv pure-ftpd: ([email protected]) [WARNING] Authentication failed for user [webhost]
Dec 30 00:53:36 guldsrv pure-ftpd: ([email protected]) [WARNING] Wrong SQL parameters : [SELECT Dir FROM ftpd WHERE User="webhost" AND status="1" AND (ipaccess = "*" AND (ipaccess = "*" OR ipaccess LIKE "87.49.60.102")]
Dec 30 00:53:36 guldsrv pure-ftpd: ([email protected]) [INFO] PAM_RHOST enabled. Getting the peer address
Dec 30 00:53:37 guldsrv pure-ftpd: ([email protected]) [WARNING] Authentication failed for user [webhost]
Dec 30 00:53:45 guldsrv pure-ftpd: ([email protected]) [INFO] Logout.


----------



## Deleriux (Dec 28, 2007)

Run the query manually then. I suspect thats meant to return something.


----------



## guldhammer (Dec 29, 2007)

Deleriux said:


> Run the query manually then. I suspect thats meant to return something.


Mmm, can you give me the right sql code, because i get a fail in this
SELECT Dir FROM ftpd WHERE User="webhost" AND status="1" AND (ipaccess = "*" AND (ipaccess = "*" OR ipaccess LIKE "87.49.60.102")


----------



## Deleriux (Dec 28, 2007)

What does it say it fails doing?


----------



## guldhammer (Dec 29, 2007)

Deleriux said:


> What does it say it fails doing?


With this in phpmyadmin:
Code:
SELECT Dir FROM ftpd WHERE User="webhost" AND status="1" AND (ipaccess = "*" AND (ipaccess = "*" OR ipaccess LIKE "87.49.60.102")


Fail:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 30' at line 2 

i think the string is not correct ended, but i just cant figure it.


----------



## Deleriux (Dec 28, 2007)

Dont use phpmyadmin, it plays with your statements to get it to work the way it wants. Use the mysql command line client.


----------



## guldhammer (Dec 29, 2007)

Deleriux said:


> Dont use phpmyadmin, it plays with your statements to get it to work the way it wants. Use the mysql command line client.


Well now i tried from my shell (the same thing as CMD in Winblows), and it says:
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
krazymail:~# SELECT Dir FROM ftpd WHERE User="webhost" AND status="1" AND (ipaccess = "*" AND (ipaccess = "*" OR ipaccess LIKE "87.49.60.102")
-bash: syntax error near unexpected token `('


----------



## Deleriux (Dec 28, 2007)

you need to use the mysql command line client.

SQL doesnt work in bash .


----------



## guldhammer (Dec 29, 2007)

Deleriux said:


> you need to use the mysql command line client.
> 
> SQL doesnt work in bash .


Where do i find this??


----------



## Deleriux (Dec 28, 2007)

type mysql into bash .

You might need a username and password too. For that you can of course type

man mysql 
to find all the switches.


----------



## guldhammer (Dec 29, 2007)

Hi there.

I found the fail, it was a missing ) in the end, the correct code is 
->
mysql> SELECT Dir FROM ftpd WHERE User="goldie" AND status="1" AND (ipaccess = "*" AND (ipaccess = "*" OR ipaccess LIKE "*"));
<-


----------



## guldhammer (Dec 29, 2007)

guldhammer said:


> Hi there.
> 
> I found the fail, it was a missing ) in the end, the correct code is
> ->
> ...


But in which file should i change this?


----------

