LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] How to automate password creation

[ILUG] How to automate password creation

Niall O Broin niall at magicgoeshere.com
Thu Jun 22 12:09:39 IST 2000


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




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell