Skip to content

Instantly share code, notes, and snippets.

@meyt
Last active September 24, 2022 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meyt/8622bec7aecbbe23a7fbb4f4550061b3 to your computer and use it in GitHub Desktop.
Save meyt/8622bec7aecbbe23a7fbb4f4550061b3 to your computer and use it in GitHub Desktop.
Batch useradd linux
#!/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