On Thu, Jun 22, 2000 at 08:26:58AM +0100, Brian Cullen wrote:
>> I have scripted the setting up of the users by using passwd files from some
> of my IRIX boxes for this project. This has been fine with regard to the
> creating of the accounts, profiles etc, what my query is, does anyone know
> how to set passwords on these accounts without going through the pain of
> "passwd bc2" etc, etc. and inputting a password and making a note etc?
>> There is about 700 accounts to apply passwords to and my typing skills are
> poor! Any quick ways to do this folks?
The following little Perl program will return an encrypted password from a
plaintext command line argument
#!/usr/bin/perl
@saltchars = ('a'..'z','A'..'Z','0'..'9','.','/');
print password($ARGV[0]) . "\n";
exit;
sub password {
my $plaintext = shift;
my $salt = $saltchars[rand(@saltchars)] . $saltchars[rand(@saltchars)];
return crypt($plaintext, $salt);
}
You could use this as is in conjunction with your scripts and modify
/etc/passwd (or /etc/shadow) as appropriate. Alternatively, you could read
the man pages for useradd and then use this program to generate the
arguments to the -p switch of useradd.
Don't anybody bother bitching about the program - I know it could be a
one-liner, but I'd rather Brian could read it if he's not a Perl person.
Also, I know that the salt thing is a little tautological, and I could have
just used the same salt for them all, but that just feels wrong, somehow.
Regards,
Niall
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!