Guest User

Untitled

a guest
Mar 23rd, 2018
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ####
  4. # This script automatically creates user accounts with random passwords.
  5. #
  6. # Author: Russ Sanderlin
  7. # Date: 01/21/15
  8. #
  9. ###
  10.  
  11. if [ $# -lt 1 ]; then
  12. echo "Please supply a user name"
  13. echo "Example: " $0 "jsmith"
  14. exit
  15. fi
  16.  
  17. # Declare local variables, generate random password.
  18.  
  19. newuser=$1
  20. randompw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
  21.  
  22. # Create new user and assign random password.
  23.  
  24. useradd $newuser
  25. echo $newuser:$randompw | chpasswd
  26. echo "UserID:" $newuser "has been created with the following password:" $randompw
Add Comment
Please, Sign In to add comment