Advertisement
Guest User

Untitled

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