Last active
September 24, 2022 14:57
-
-
Save meyt/8622bec7aecbbe23a7fbb4f4550061b3 to your computer and use it in GitHub Desktop.
Batch useradd linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# bash ./mass-useradd.sh 20 | |
cnt="$1" | |
prefix="user" | |
for n in `seq $cnt`;do | |
user="$prefix$n"; | |
pass=$(openssl rand -base64 12); | |
#pass=$(shuf -i 1000000000-9999999999 -n 1); | |
useradd "$user" && echo "$user:$pass" | chpasswd && echo "$user = $pass"; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment