[LCP]how to give passwd in a script?

Greg Black gjb at gbch.net
Thu May 9 15:36:05 UTC 2002


Anandakumar.Thangaraju at EchoMail.com wrote:

| Can anyone pls tell me how to give passwd in a script.

This is a C programming list, which means it's not the place to
ask about shell scripting.

| for((a=1; a<=100; a++))
| do
| useradd "test$a"
| passwd "test$a"

Assuming for a moment that you could do this, which you can't,
there is no point to it -- if the passwords are generated this
way, there's no point in having them at all, because anybody can
guess them.

You'll really need to think hard about what you're doing and why
you're doing it and then do some reading into the way this stuff
is handled by the system.

It's trivial to write a C or Python program that can read an
unencrypted password from its standard input and output an
encrypted password to its standard output.  You can then capture
the encrypted password and use the system's chpass program to
update the password (assuming you're using a system that allows
you to give an encrypted password to chpass).

Greg




More information about the linuxCprogramming mailing list