# passwd will not change password



## simonpie (Jun 24, 2020)

Hello,

I run 12.1-p6 and I am trying to change my main user password.  I have tried 
	
	



```
sudo passwd myuser
su
passwd myser
```
and just plain
`passwd` from the user's account.
They all complete with success (`echo $?` is zero ).  But the password is not changed.

Permissions look good on the password files :

```
root@charon:~ #    ls -l /etc/*pass*
-rw-------  1 root  wheel  3508 Jun 24 08:30 /etc/master.passwd
-rw-r--r--  1 root  wheel  2862 Jun 24 08:30 /etc/passwd
root@charon:~ #
```

Nothing specific in the logs and I dont remember playing with PAM settings and they look clean.  But nothing works, the password remains the one I used when I created the account on setting up a Freebsd 11 machine a while ago.

Any help would be appreciated.


----------



## SirDice (Jun 24, 2020)

Judging by the timestamps your password was definitely changed. Are  you sure your new password isn't the same as the old one?


----------



## simonpie (Jun 24, 2020)

Yep, pretty sure.  I can try sudo with the new password, and it will not work, but it will work with the old password.


----------



## bjs (Jun 24, 2020)

Try rebooting, just for shits and giggles...


----------



## simonpie (Jun 24, 2020)

Every one loves a good reboot, but to no avail.  It is still the old password that works and not the new one.  I have tried resetting it, did not work again, but the files got touched again.



```
[charon:: 12:32] [~] > ls -l /etc/*pass*
-rw-------  1 root  wheel  3508 Jun 24 12:32 /etc/master.passwd
-rw-r--r--  1 root  wheel  2862 Jun 24 12:32 /etc/passwd
[charon:: 12:33] [~] >
```

Funny thing is, the salt and the hash changed in the master.passwd.  But the old password is being pick up anyway.  Which is even stranger, since I did a `su` to root.  And yes, root and my user have wildly different passwords, which are rather easy to distinguish.  

I'll create a new user and use it to `ssh` into the machine and then `su`, juste to test.


----------



## SirDice (Jun 24, 2020)

Something to try, run `vipw`  (as  root). Then save and quit without making any changes. Something appears to be out of  sync and this may fix it.


----------



## simonpie (Jun 24, 2020)

That did the trick, new password worked after the `vipw`.  Thank you SirDice.

But still, we have a conundrum :

Creating the new user did not work here is the end of the output :

```
......
OK? (yes/no): yes
pw: user 'blabla' disappeared during update
adduser: ERROR: There was an error adding user (blabla).
Add another user? (yes/no): no
Goodbye!
root@charon:
```

And the user is not functionnal.


----------



## SirDice (Jun 24, 2020)

Same trick, `vipw`; save and quit. You will find plenty of  threads with that exact same error. Your databases somehow got out of sync.


----------



## simonpie (Jun 24, 2020)

Ho, and yet, both passwd and master.passwd were modified and my new user was there.  But the home directory was not created.


----------



## simonpie (Jun 24, 2020)

SirDice said:


> Same trick, `vipw`; save and quit. You will find plenty of  threads with that exact same error. Your databases somehow got out of sync.



I did do a search for passwd on the forum before.  I did not find anything usable.  Thank you again.  Are there any solutions to that out of sync thing ?


----------



## SirDice (Jun 24, 2020)

Solved - Error adding new user - pw: user 'anne' disappeared during update
					

Hei,  As root, I'm trying to add a new user with adduser but it returnes a strange error when I confirm. Only the group 'anne' gets created, but nothing more. I checked pw for something helpful as it seems like it's pw creating the error and checked /var/log/messages and /var/log/auth.log but...




					forums.freebsd.org
				











						Solved - pw: user 'postfix' disappeared during update
					

While installing mail/postfix I saw the following output: ===> Creating groups. Using existing group 'mail'. Using existing group 'maildrop'. Using existing group 'postfix'. ===> Creating users Creating user 'postfix' with uid '125'. pw: user 'postfix' disappeared during update install: unknown...




					forums.freebsd.org
				











						Solved - Error adding new user ?
					

# adduser Username: db51 Full name: db51.ofloo.net Uid (Leave empty for default): Login group [db51]: Login group is db51. Invite db51 into other groups? []: Login class [default]: Shell (sh csh tcsh bash rbash nologin) [sh]: Home directory [/home/db51]: Home directory permissions (Leave empty...




					forums.freebsd.org
				











						Solved - PRE-INSTALL script failed
					

Hi, I am using FreeBSD 12.1-RELEASE-p2 I was trying to install Bareos package, and I got this error:   # pkg install bareos-client-18.2.7 Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 3 package(s) will be affected (of 0...




					forums.freebsd.org


----------



## simonpie (Jun 24, 2020)

SirDice said:


> Solved - Error adding new user - pw: user 'anne' disappeared during update
> 
> 
> Hei,  As root, I'm trying to add a new user with adduser but it returnes a strange error when I confirm. Only the group 'anne' gets created, but nothing more. I checked pw for something helpful as it seems like it's pw creating the error and checked /var/log/messages and /var/log/auth.log but...
> ...



Noted, but at my defense,  they all seem related to adding users, which just happened to me after talking on this thread.  My original problem was really with passwd failling silently.

In any case, thank you, I shall go read those with lots of attention.


----------



## outpaddling (Dec 26, 2020)

Same issue on a 12.2-RELEASE system.  vipw + :w did the trick.

Note to posterity: If ever you see weird behavior from the passwd command, make sure you haven't been hacked and are dealing with a Trojan passwd binary.

o sha256 /usr/bin/passwd
o Compare to another system running the same version if possible or find the correct checksum elsewhere
o Run some malware checks such as clamav
o If unsure, back up your data and do a fresh install


----------



## outpaddling (Jun 2, 2021)

Did you try the followig?
`pwd_mkdb /etc/master.passwd`


----------



## vadymrostok (Aug 1, 2022)

In my case I had two `passwd` tools, for whatever reason. One at `/usr/local/bin/passwd` and another at `/usr/bin/passwd`. Using the latter solved the issue.


----------



## outpaddling (Aug 1, 2022)

I'm not seeing anything in the ports tree with bin/passwd in pkg-plist.  If you can't explain how /usr/local/bin/passwd came to be, you'll want to verify that you haven't been hacked.  A fake passwd command in the default PATH is a good candidate for a Trojan.


----------

