Advertisement
Guest User

Untitled

a guest
Mar 29th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.21 KB | None | 0 0
  1. #!/bin/bash
  2. #Author:Surendra Kumar Anne
  3. #Purpose:To automate user creation
  4. #Date/Time:06-08-2011.19:10
  5. mkdir -p /home/admin/useraccounts
  6.  
  7. for (( i=0; i<=500; i++ ))
  8.  
  9. do
  10.  
  11. #Create users whose name starts with baci,
  12.  
  13. #so this script will create baci1, baci2, baci3 etc depending on i value.  
  14.  
  15. useradd baci$i
  16.  
  17. #this command is bit tricky, < /dev/urandom  
  18.  
  19. #will generate all the random characters which are not even present
  20.  
  21. #on keyboard.. and tr -dc A-Na-n1-9, will display only characters
  22.  
  23. #which are from A to N, a to n and 1 to 9. This is to avoide o(small o),  
  24.  
  25. #O(capital o), 0(numerical zero) characters in order to remove
  26.  
  27. #confusion in the password.  #And there is no character limit.   so head -c8
  28.  
  29. #will limit the random characters to just 8
  30.  
  31. < /dev/urandom tr -dc A-Na-n1-9_ | head -c8 > /tmp/passwd.txt
  32.  
  33. #As this is an automated shell script, the below command will take
  34.  
  35. #password from STDIN(--stdin) ie /tmp/passwd.txt  
  36.  
  37. cat /tmp/passwd.txt | passwd --stdin user$i  
  38.  
  39. echo -e "Username:baci$i" > /home/admin/useraccounts/baci$i
  40.  
  41.  echo -e "password:" >> /home/admin/useraccounts/baci$i  
  42.  
  43. cat /tmp/passwd.txt >> /home/admin/useraccounts/baci$i  
  44.  
  45. done
  46.  
  47. rm -rf /tmp/passwd.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement