This user is a unpriviledged SFTP access user on our server, it was used during the stay-home order earlier this year due to Covid19, and I'm using it today to prepare some work for use tomorrow.

Since I forgot its previous password, I reset it using the command sudo passwd <user>, and I wasn't able to login, I explicitly unlocked it using pw unlock and checked /etc/master.passwd, and confirmed I successfully changed the recorded password hash. Yet, I wasn't able to login using either sftp command remotely, or with login command during the admin ssh session.

What could possibly be the cause of this?


I copied password hash from another unpriviledged user to it and it still cannot login, that other unpriviledged user can login however.

1 Answer 1


Skimming through man page for passwd(5), I found the pwd_mkdb(8) command. Running:

pwd_mkdb -p /etc/master.passwd

solved the problem.

In essence, the problem is that, /etc/master.passwd file didn't get updated into /etc/pwd.db and /etc/spwd.db. These 2 are "cached" database files in Berkeley database format (present for the presumed purpose of speeding up credential lookup).

pwd_mkdb(8) is the system management command for generating "password database", which is the table of user information. I updated the server to 12.2-RELEASE last month, and forgetting to run the command is probably the cause.

  • 2
    Changing the password for a user using passwd should have updated these databases automatically. It is unclear why this did not happen.
    – Kusalananda
    Dec 10, 2020 at 13:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .