Re: [Fedora] Re: User creation script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aaron Konstam wrote:
The problem as I see it is to generate passwds automatically. There used
to be a program mkpasswd that did that but I can't find that now.
In my case, I had the password and username, I just needed to pass them. With the help from another list, I ended up with this. Since I was going to pass both the username and password to this script, I just wrote one bash shell script that took both values and processed them accordingly:

      cat useradd.sh

      #!/bin/sh
      #
      # This has been simplified.  Adjust to your own needs.
      username=$1
      password=$2
      USHELL=/bin/bash

      crypt=`/path/to/crypt.pl $password`

/usr/sbin/useradd -d "/home/$username" -p "$crypt" -s $USHELL "$username";


   And the crypt.pl script looks like this:

      cat crypt.pl

      #!/usr/bin/perl
      use Crypt::Passwd;
my $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64];
      print unix_std_crypt($ARGV[0], "\$1\$$salt\$");



And while I could've done the whole thing in one perl script, by splitting them into two pieces, it allows me to re-use the crypt.pl part in other scripts.

--
W | It's not a bug - it's an undocumented feature.
 +--------------------------------------------------------------------
 Ashley M. Kirchner <mailto:ashley@xxxxxxxxxx>   .   303.442.6410 x130
 IT Director / SysAdmin / Websmith             .     800.441.3873 x130
 Photo Craft Imaging                       .     3550 Arapahoe Ave. #6
 http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux