Skip to content

Instantly share code, notes, and snippets.

@ajithrn
Created May 1, 2024 21:24
Show Gist options
  • Save ajithrn/3f317fb0ad755573f272e83c88565f51 to your computer and use it in GitHub Desktop.
Save ajithrn/3f317fb0ad755573f272e83c88565f51 to your computer and use it in GitHub Desktop.
Script to create bulk user on cyberpanel using CLI and export credentials.
#!/bin/bash
# Create the CSV file with header
echo "url,username,password" > credentials.csv
# Define a string of possible characters for the password
char_pool="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
counter=0
for i in {a..z}; do
for j in {a..z}; do
username="ycuser_${i}${j}"
# Generate a random alphanumeric 8-character password
password=""
for _ in {1..8}; do
# Get a random index to pick a character from char_pool
index=$(( RANDOM % ${#char_pool} ))
password="${password}${char_pool:$index:1}"
done
# Append the values to the CSV file
echo "https://SERVER:IP:8090,${username},${password}" >> credentials.csv
# Command to run the user
command1="cyberpanel createUser --firstName YouthCamp --lastName User${i}${j} --email user${i}${j}@wpkerala.org --userName ${username} --password ${password} --websitesLimit 20 --selectedACL ycuser --securityLevel LOW"
#Command to run the user package
command2="cyberpanel createPackage --owner ${username} --packageName ${username} --diskSpace 1000 --bandwidth 10000 --emailAccounts 3 --dataBases 10 --ftpAccounts 1 --allowedDomains 3"
eval $command1
eval $command2
((counter++))
if [ $counter -eq 75 ]; then
break 2
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment