Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.57 KB | None | 0 0
  1. #!/bin/bash
  2. FILE=$1
  3. PASS="a"
  4. while read line; do
  5.     set $line
  6.     TEMP=$2
  7.     pass=$(date +%s | sha256sum | base64 | head -c 32 ; echo)
  8.     user=${line:0:1}${line:1:1}${TEMP:0:1}${TEMP:1:1}
  9.     usernamesize=${#user}
  10.     [ $usernamesize -eq 0 ] && break
  11.     #number is how many users that matches the string 'user'.
  12.     number=$(cut -d: -f1 /etc/passwd | grep ^"$user"[0-9] | wc -l)
  13.     user=$user$number
  14.     useradd -m $user
  15.     if [ "$?" -eq 0 ]; then
  16.      echo $user:$pass | chpasswd
  17.      echo $user - $pass
  18.     else
  19.      echo "Error."
  20.     fi
  21. done < "$FILE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement