Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- FILE=$1
- PASS="a"
- while read line; do
- set $line
- TEMP=$2
- pass=$(date +%s | sha256sum | base64 | head -c 32 ; echo)
- user=${line:0:1}${line:1:1}${TEMP:0:1}${TEMP:1:1}
- usernamesize=${#user}
- [ $usernamesize -eq 0 ] && break
- #number is how many users that matches the string 'user'.
- number=$(cut -d: -f1 /etc/passwd | grep ^"$user"[0-9] | wc -l)
- user=$user$number
- useradd -m $user
- if [ "$?" -eq 0 ]; then
- echo $user:$pass | chpasswd
- echo $user - $pass
- else
- echo "Error."
- fi
- done < "$FILE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement