Xianqing,

I created a simple shell script to do this. It prompts for userid, first name, 
last name, and email address. Then it inserts the entry into the USER table and 
the LOCALAUTH table. The value for 'salt' is just a random 8-char string. The 
value for 'passhash' is derived from combining the desired password with the 
salt and piping it to sha1sum. 
(E.g.  echo -n 'mypassword ekYR8k2a' | sha1sum)

The script could be improved by prompting for desired password and generating 
the passhash within the script, but this was just a quick and dirty script I 
wrote to use the same password each time.

===================================================
#!/bin/bash

while true
do
        echo -n "Input userid =>"
        read myusername
        echo -n "Input first name =>"
        read myfirstname
        echo -n "Input last name =>"
        read mylastname
        echo -n "Input email address =>"
        read myemailaddr
        echo
        echo "userid: $myusername"
        echo "first: $myfirstname"
        echo "last: $mylastname"
        echo "email: $myemailaddr"
        echo -n "correct? (y/n) "
        read answer
        if [ "$answer" = "y" ]
        then
                break
        fi
done

# add entry to user table
echo "INSERT INTO user (unityid, firstname, lastname, email, lastupdated) 
VALUES 
('$myusername', '$myfirstname', '$mylastname', '$myemailaddr', NOW());" |mysql 
vcl

# find out the id generated for that user
ID=`echo "SELECT id, unityid FROM user WHERE unityid = '$myusername';"|mysql -s 
vcl|awk '{print $1}'`

# add entry to the localauth table
echo "insert into localauth (userid,salt,passhash,lastupdated) values 
('$ID','ekYR8k2a','c142df97acda160fa2c5366b2fb8bd1686dd43c9', NOW());"|mysql vcl
==================================================================================

Mike Waldron
Systems Specialist
ITS Research Computing
University of North Carolina at Chapel Hill
CB 3420, ITS Manning, Rm 2509
919-962-9778


-----Original Message-----
From: Xianqing Yu [mailto:yu267155...@hotmail.com] 
Sent: Thursday, January 20, 2011 11:54 PM
To: VCL Develop Mail List Mail List
Subject: The way to create local user quickly

Hi All:

I try to create several local accounts in VCL system. Is there any ways to 
create local accounts easily and quickly?

Thanks,

Xianqing

Graduate Student
NCSU

Reply via email to