how to reset login in freebsd if the password is expired
matthew at FreeBSD.org
matthew at FreeBSD.org
Mon Jul 27 09:58:27 UTC 2020
On 27/07/2020 10:33, Jiang Xu wrote:
> I set the root login to be expired in 90 days, and we forget to
> update the password of the login, and the password is expired, and
> now we can not login in on it? but we can access the disc with attach
> it to another instance, is there any way to reset the expired
> password?
First of all, as you have discovered, setting the root password to
expire is not a good idea. In some ways, the root account is your
account of last resort for regaining access to or control of the system,
so don't implement policies that would ever deny that.
See the passwd(5) manual page. The 7th column in the master.passwd file
is the account expiry time. If you can mount your drive on a second
machine, then edit `master.passwd` and set that field to `0` for the
root account. It should look something like this:
root:$1$XXXXXXXCENSOREDXXXXXXXXXXXXXX:0:0::0:0:Charlie &:/root:/bin/csh
^
this field
Then, assuming you've temporarily mounted the disk at /mnt so the file
you're editing is /mnt/etc/master.passwd, you need to run:
pwd_mkdb -d /mnt/etc -p /mnt/etc/master.passwd
After that, replace the drive in the original machine and reboot.
You can also do this without taking the drive out of the original
machine by booting into single user mode, but in that case you will need
to remount the root partition read-write:
mount -u / -o rw
and obviously in this case the root partition will be mounted in the
usual location, so adjust paths in `pwd_mkdb` appropriately.
Cheers,
Matthew
More information about the freebsd-questions
mailing list