Then we are getting the user and group that is currently set on the root folder for that particular site, and storing them in respective variables. The next few lines within the for-loop are obtaining the full path of the root folder utilizing sed to trim off the trailing part of the path.
You should be able to easily modify this to other folder structures. The above snippet is assuming that all your wordpress sites are in the /home folder. In the above snippet, we are creating a main for loop that we will use to iterate across all wordpress sites. Root_folder=`echo $obj0 | sed 's/\/wp-config.php//g'` First and foremost we want the bash shell script to iterate across all the WordPress sites on your server : for obj0 in $(find /home/*/public_html/wp-config.php) The purpose of this is to ensure that user and group permissions are sanitized and correct according to what is set on the root folder.
Sanitize user and group permissions for multiple WordPress sites At the bottom of this article I will share the entirety of the shell script. I will touch on each of the above items including the shell script snippets that are required to implement each. The above actions can be implemented as part of a broader security policy when dealing with shared hosting environments where you are hosting multiple WordPress sites. Iterate through all WordPress user accounts and reset the passwords Sanitize WordPress core admin and include files
In this article, I will be going over how to create an automated shell script that completes the following actions across multiple WordPress sites on your linux server : There are several key best practices insofar as how to deal with security intrusions, including but not limited to restoring from backups on a clean server.