I have this situation: I have read-only file system based linux. I have a problem that i want to change users passwords. I have moved shadow and passwd files to other partition so I thought i would do the trick. Yes now I can edit shadow file by hands. But passwd command isnt working "passwd: An error occurred updating the password file.". What i need to move to other partition that command would start working?
Also Im thinking about generating password by my self and appending shadow file. BUT how can I generate MD5+salt? I dont have openssl or mkpasswd I just have md5sum.
Any ideas how to fix passwd command or how to generate password?
The system expects the password and shadow file at
/etc/passwd
and/etc/shadow
. If you move them to another location the system is broken and authentication won't work.The
passwd
command updates the file at /etc/shadow, changing the password there. As you are on a read-only filesystem this process has to fail.Generating passwords and hashes by yourself is error prone, you shouldn't do this on your own. For securitys sake you should stick to existing tools. If you do really want to manually generate passwd / shadow entries, you should take a look at the crypt manpage. This function is responsible for encrypting and hashing passwords and is also used by
passwd
.As far as i know there is no way to use simply
md5sum
to create crypt-passwords. Furthermore I would never, never, never use md5 for hashing my passwords as this hash is broken since ages.