Skip to content

Instantly share code, notes, and snippets.

@mysterious-static
Created February 24, 2017 13:58
Show Gist options
  • Save mysterious-static/f192addd0319127f90156173084d9ab3 to your computer and use it in GitHub Desktop.
Save mysterious-static/f192addd0319127f90156173084d9ab3 to your computer and use it in GitHub Desktop.
Rotate WordPress salts
wget -O new-salts.key https://api.wordpress.org/secret-key/1.1/salt/
sed -i '1s|^|\n*/\n|' new-salts.key
sed -i "/#@+/,/#@-/{ /#@+/{p; r new-salts.key
}; /#@-/p; d }" wp-config.php
rm -f new-salts.key
@mysterious-static
Copy link
Author

The idea here is to preserve the comment structure that I'm using to find the salts in wp-config so that you can rotate them as many times as you want. Seems to work okay for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment