Shell script

Jason Clinton me at jasonclinton.com
Wed Nov 12 02:48:54 CST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Charles Steinkuehler wrote:
|>> /usr/sbin/useradd -c "$1 Account Whatever Comment Here" $1
|>> echo $2 | /usr/bin/passwd --stdin $1
|>> done
|>>
|>>
|>> You may have to tweak around with this a touch..  But it should do
|>> the job for
|>> you.  The script creates the account with default settings and then
|>> puts the
|>> password in for you using the passwd command.  The --stdin option to
|>> passwd is
|>> generally not documented well, if at all, but it's there in every
|>> distribution
|>> I've used.
|
|
|  From "man passwd" on RHEL-3:
| <quote>
| --stdin
|     This option is used to indicate that passwd should read the  new
|     password from standard input, which can be a pipe.
| </quote>
|

This is not standard at all. This is why Samba has a password changing
communcations section in its config file -- it's different in every
distro. In Gentoo, passwd comes from the 'shadow' package and does not
accept STDIN. This package also contains /usr/sbin/chpasswd which can
only be run by root and accepts a file from STDIN in the form of
"username:password" in which case you would want to do something like this:

# ruby -neW0 'puts "#$1:#$2" if /(.*)t(.*)/' sourcefile | chpasswd -e
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQE/sZF4tSqjk42zvwkRAuERAJwIeKzCVI9hEC2GNczz9rkh7OdAbACgpHTz
2E7zGvq6qWbd18dlXJv/DLo=
=hsax
-----END PGP SIGNATURE-----




More information about the Kclug mailing list