# FTP login fail



## hdc (May 19, 2017)

I am using FTPD from FreeBSD, the user name and password were created by `adduser`.

The user name is not in /etc/ftpusers, and it is in /etc/ftpchroot.

The user login was working fine. But after changing password by `passwd`, it was not working and FTP client said login failed.

I can see nothing from /var/log/xferlog.

Any idea how to do?


----------



## SirDice (May 19, 2017)

The most obvious reason is not typing the correct password. But other than that the chroot(8) environment needs a pwd.db and I'm guessing it contains the old password (there shouldn't be a password stored there).


----------



## hdc (May 19, 2017)

Password typing should be correct, I have tried more than 20 times. 

May I know how to update pwd.db?


----------



## SirDice (May 19, 2017)

You'll have to copy them and adjust where needed.

```
~ftp/etc  Make this directory owned by ``root'' and unwritable by
                     anyone (mode 555).  The files pwd.db (see passwd(5)) and
                     group(5) must be present for the ls(1) command to be able
                     to produce owner names rather than numbers.  The password
                     field in passwd(5) is not used, and should not contain
                     real passwords.  The file ftpmotd, if present, will be
                     printed after a successful login.  These files should be
                     mode 444.
```
From ftpd(8)


----------



## hdc (May 22, 2017)

thanks but it is not working.

I have made /home/ftp folder, then create pwd.db and group files in /home/ftp/etc as instruction. But still login failed.


----------



## SirDice (May 22, 2017)

Are there any errors in /var/log/messages and/or /var/log/auth.log?


----------



## hdc (May 22, 2017)

nothing. and no any errors in /var/log/xferlog either.


----------



## SirDice (May 22, 2017)

If I recall correctly the only things showing up in the xferlog are the actual transfers. But you're not even getting that far. Try stopping the daemon itself and running ftpd(8) on the command-line with one or more -d switches. Hopefully that will show us exactly what's going wrong.


----------



## hdc (May 22, 2017)

I can't. To run `/usr/libexec/ftpd` or with -d switch has nothing.

I gave up then try to make a new account by `adduser`. After all filled in, I get this error:

pw: user 'foo' disappeared during update

I am supposing that is the mistake also blocked the FTP account. any idea?


----------



## hdc (May 22, 2017)

I did following steps to fix it although I don't know why:

1. `vipw`to update the password database.
2. try old account 'foo' which still not working.
3. to add new account 'bar' by `adduser`, which is success.
4. then old account 'foo' is working fine too.

totally confused although it is working.


----------



## SirDice (May 22, 2017)

Ah, I've had that happen every now and then. For some reason the passwd and pwd.db are out of sync (you get that "user disappeared during update" message). Forcing the sync to happen (vipw(8) for example) fixes it. Still unsure _why_ this happens though, it doesn't happen often enough for me to dig deeper.


----------

