0

When is executed the sudo adduser <username> --disabled-login command, is created an user being locked because is disabled login. It can be confirmed with the passwd -S <username> command that shows something like:

<username> L ...

To unlock is necessary define a password first, therefore is possible accomplish this goal with either the passwd or usermod command as follows:

sudo passwd -u <username>
passwd: unlocking the password would result in a passwordless account.
You should set a password with usermod -p to unlock the password of this account.

sudo usermod -U <username>
usermod: unlocking the user's password would result in a passwordless account.
You should set a password with usermod -p to unlock this user's password.

Therefore is indicated twice to use the usermod -p command. Now according with the man usermod for the -p option is indicated

-p, --password PASSWORD
The encrypted password, as returned by crypt(3).

Note: This option is not recommended because the password 
(or encrypted password) will be visible by users listing
the processes.

The password will be written in the local /etc/passwd or
/etc/shadow file. This might differ from the password
database configured in your PAM configuration.

You should make sure the password respects the system's
password policy.

My concern is about the note indication. Is it in someway deprecated?. Therefore

Question

  • What is the correct approach to unlock a disabled login user?
3
  • 3
    That warning about the -p option is in "man usermod" not "man passwd" as you say. "man passwd" has no such note (nor a -p option.) I'd recommend setting a password with "passwd <user>", which will prompt for a password, so the password is not passed on the command line which risks revealing it. Then enable the login with usermod.
    – rfm
    Commented Apr 24 at 23:10
  • 1
    ... sudo passwd <user> on its own is sufficient to enable login for <user> Commented Apr 25 at 0:44
  • Thanks rfm for the indication of my typo error - fix it. Because both are suggesting use sudo passwd <username> - it is based according your own experience or is indicated explicitly in some place? I could assume the current man usermod would suggest use the passwd instead. I've seen this approach in other man commands Commented Apr 25 at 13:55

0

You must log in to answer this question.

Browse other questions tagged .