I'm trying to change programmatically a user's password, and got a few messages I can't explain along the way.
I ran this command to start with:
sudo usermod -p "$(openssl passwd -1 newpassword)" theuser
No error got printed, but next time I logged in, I got this message:
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Mon Jan 30 16:22:41 2017 from 18.104.22.168 Wrong salt length: 0 bytes when 8 <= n <= 16 expected.
I tried another encryption method:
sudo usermod -p "$(openssl passwd -crypt newpassword)" theuser
Still no error, but the message changed:
Wrong salt length: 0 bytes when 8 <= n <= 16 expected.
I finally tried something else, using
mkpasswd to have a stronger encryption (related to this post):
sudo usermod -p "$(mkpasswd --method=sha-512 newpassword)" theuser
This time, the error disappeared, so I believe this was related to the hash algorithm strength. What I don't understand is which algorithm can and should be used to generate a password.
Which algorithms can be safely used with
mkpasswd to avoid the message error? Does that also mean
mkpasswd command is ran at startup?
UPDATE: I forgot to mention I had these messages using a Raspbian Jessie Lite. I also found some strings containing this error message in mkpasswd.c source on rfc1036/whois GitHub repository.