Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Author:Surendra Kumar Anne
- #Purpose:To automate user creation
- #Date/Time:06-08-2011.19:10
- mkdir -p /home/admin/useraccounts
- for (( i=0; i<=500; i++ ))
- do
- #Create users whose name starts with baci,
- #so this script will create baci1, baci2, baci3 etc depending on i value.
- useradd baci$i
- #this command is bit tricky, < /dev/urandom
- #will generate all the random characters which are not even present
- #on keyboard.. and tr -dc A-Na-n1-9, will display only characters
- #which are from A to N, a to n and 1 to 9. This is to avoide o(small o),
- #O(capital o), 0(numerical zero) characters in order to remove
- #confusion in the password. #And there is no character limit. so head -c8
- #will limit the random characters to just 8
- < /dev/urandom tr -dc A-Na-n1-9_ | head -c8 > /tmp/passwd.txt
- #As this is an automated shell script, the below command will take
- #password from STDIN(--stdin) ie /tmp/passwd.txt
- cat /tmp/passwd.txt | passwd --stdin user$i
- echo -e "Username:baci$i" > /home/admin/useraccounts/baci$i
- echo -e "password:" >> /home/admin/useraccounts/baci$i
- cat /tmp/passwd.txt >> /home/admin/useraccounts/baci$i
- done
- rm -rf /tmp/passwd.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement