How to Set Up a WordPress Auto Password Rotation Script Updated on December 22, 2023 by Christopher Maiorana 1 Minutes, 25 Seconds to Read Part of regular WordPress maintenance is password rotation. Once in a while, it is best advised to update your WordPress password. In this article, we’ll show you how you can create a script to automate WordPress password rotation process and send you an email with the new password. WordPress Auto Password Rotation Script In order to complete this tutorial, you will need access to your cPanel. Follow along with the steps below: Log into cPanel. Under Files choose File Manager Navigate to the directory that contains your WordPress site files Create a new file called wpass.sh Edit the wpass.sh file Paste the following into the file: #!/bin/bash EMAIL=[email protected] RANDPW="$(tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1)" wp user update 1 --user_pass=$RANDPW && mail -s "New Password for WordPress" $EMAIL <<< $RANDPW Substitute [email protected] with your desired email address (this will be used to receive the new WordPress password) Likewise, be sure to check the number following wp user update to make sure it corresponds with the correct WordPress user ID If you are unsure which number has been assigned to your WordPress user, run this command via SSH: wp user list (Use the number that corresponds with the user account you are trying to update) Change file permissions on wpass.sh to 755, or, if you are in SSH, you can run the following command to make this script executable: chmod +x wpass.sh Now, all you need to do is set up a cron job to run this script at your decided interval. Then, you can also check to see if the cron job is running correctly. Share this Article CM Christopher Maiorana Content Writer II Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog. More Articles by Christopher Related Articles WooCommerce Setup Guide How to Create an Admin Account in WordPress via MySQL How to Add Google Analytics to WordPress Using the Jetpack Newsletter Subscription Form Benefits of Joining the WordPress Community Online How to Add Social Media Icons and Social Media Buttons to WordPress Create a Footer for WordPress How to Google Analytics to WordPress Without a Plugin Choose the Style of Your WordPress Homepage From Newbie to WordCamp Organizer