Bash script change all password cpanel users via ssh
Bash Script to Change All Passwords of cPanel Users via SSH
Changing passwords of cPanel users via SSH can be a handy task for server administrators to ensure the security of accounts. Bash scripting can automate this process effectively. Below is a simple bash script that can be used to change passwords of all cPanel users on a server:
#!/bin/bash
# Get a list of cPanel users
USERS=$(cut -d: -f1 /etc/trueuserowners)
# Loop through each user and change the password
for USER in $USERS
do
NEWPASS=$(openssl rand -base64 12)
/scripts/chpass $USER $NEWPASS
echo "Changed password for user $USER to: $NEWPASS"
done
This script retrieves a list of cPanel users from the server and then loops through each user, generating a random password using OpenSSL and setting it for the user using the '/scripts/chpass' command. Remember to run this script with appropriate permissions and after testing in a controlled environment.
Example Usage:
chmod +x change_passwords.sh ./change_passwords.sh
Disclaimer:
Remember to always have proper backups and permissions in place before making bulk changes like this on a production server. Incorrect usage can lead to account lockouts and potential data loss.
Conclusion
Automating tasks like changing cPanel user passwords via SSH can save time and effort, especially on servers with a large number of accounts. Bash scripting provides a powerful way to achieve this automation while ensuring security and consistency across user passwords.
© 2023 East4Serv | For efficient server management services, visit www.east4serv.com
Managed USA VPS
Managed Saudi VPS
Managed Egypt VPS
Managed UAE VPS