Bunch of keys

WordPress Security Keys – What, Why & How

| 11 Comments

What are they?

The WordPress security keys are eight random strings of characters, used to beef up the security of your cookies and passwords. More accurately, there’s four security keys and four corresponding salts – salts are extra strings that make it harder to crack passwords by adding extra pieces to them.

Why use them?

All too often, people use incredibly simple passwords that are easy to crack by using brute force attacks. WordPress security keys help to encrypt information in users’ cookies more securely, making your installation much more secure. They are not a substitute for creating a good password however and you should still employ sound password-creating practices such as including combinations of upper-case and lower-case letters, symbols, punctuation and numbers.

In short, security keys are like an extra bolt on the door – just one more thing to break in order to gain access.

How to use them

Adding security keys to your WordPress installation is actually a fairly simple task, so long as you are confident editing a PHP file.

All you need to do is find your wp-config.php in the root of your installation and open it for editing. Look around for the following piece of code:

* Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

The next step is to create the unique phrases for each key and salt. You are welcome to try and create them yourself, however, the more random they are, the better and a computer is far better at being random than a human. It’s also easier for a computer to create 8 60-character strings than for you, so just save yourself the trouble and use the simple key and salt generator, a free tool provided by WordPress.

Once you arrive at that page, all you have to do is copy the entire page contents and replace the eight lines of code in wp-config.php with those created for you by the generator. An example of the code that you will be presented with is:

define('AUTH_KEY',         '8NhUy4z!=Xscgm7ZT%~dO(UDsOmT<Up)iq-{=Ot}B+;|?kzPS5(S:7!-@FBo|u]N');
define('SECURE_AUTH_KEY',  'k:P5|=7)GnQ9i%:-hC9ekn5e-c~!+=;d@2{]KN|ohMJYUH6|GV|K^[u95I/&!IXE');
define('LOGGED_IN_KEY',    '~Dx0|g~`D@N``7B}xFP?a{$oSM_B,,~,gIjhS?|4gWU5%5lnlZdogP13X%P`]~5!');
define('NONCE_KEY',        'r2=LE]XfhsXqG+NL:v50`.`?/!Y8vPBhG)=P[B6,^78|PUW_$|+@0~riALu@6MQ:');
define('AUTH_SALT',        '-(RdXQIon(`@N}y|!`%%eMpN`$58Vq=-4!;iP8C_~-Ce{NG,_2yfbwrrt)>Vs>n_');
define('SECURE_AUTH_SALT', 'YvM?R%cuBRy}=a#W@DH+z$u^#vCVdpu^+5s-`,s;N4/NN<[ RSsDBGx[v+;$*DQ#');
define('LOGGED_IN_SALT',   ';.azo JkjmYUZPgv-0<#Zrc@i;<V[<;8m:TU`J$)~kD=F(|-VEl!pH=f8I]43n:9');
define('NONCE_SALT',       'i48y6,}zW3:Ex(|l[mjG&O;}Ts> |00oAKAMS-. 0s+j[9e_D[Or DFGT|_b0f5+');

Now save your wp-config.php and you're set to go.

You can change these periodically if you so choose and should definitely do so if you experience a security breach. The only drawback is that any logged in users will have to log back in as their cookies will become invalid.

What other security practices do you employ on your installation?

Categories: Security, The Basics | Permalink

What next?

Hire me

If you couldn't quite manage this yourself, find it too intimidating, or just don't have the time to do it, you can always hire Dave to do it. Please get in touch so that we can discuss your needs.

Leave a comment

If you have a question, update, or comment about the tutorial, please leave a comment. I try and respond to every comment, though it may take a few days, so please check back soon.

Keep your site backed up, updated & secure

I provide a service called The WP Butler, which helps you stay on top of the maintenance of your WordPress site. Instead of worrying about whether your site is secure, updated and backed up, The WP Butler handles all that for you on a regular basis, so that you can focus on doing what you do best. If you use coupon DIWW, you'll save 15% on our already-low-prices for all maintenance plans.

Author: Dave Clements

Dave Clements has been building websites for close to a decade and in 2010, he formalised that by starting his own company, The UK Edge. He now works on a variety of web projects, from simple tasks like installing a new WordPress site, to consulting on problems, or redesigning his clients' sites. He also runs Do It With WordPress, a site dedicated to providing free tutorials on WordPress. When he's not building your new website, you can find Dave eating Wheat Thins, spending time with friends and family, watching Indie films, fostering kittens from the local Humane Society, listening to some dubstep, dance and electronic rock, and exploring the world.

11 Comments

  1. Thanks for the post as it gives good guidelines as to how to give security to the wordpress cookies

  2. Your every post is great to read. And now i subscribed your feed to be updated with you. Good work !!!!

  3. Thanks, I’ll give this a try. Security online is as important, or more so, than offline. More people should realize that by now.

    • I’d say they’re equally important, but while you’re not going to lose your credit card details by having your WordPress installation hacked, you can lose an awful lot of work and cause yourself a lot of hassle trying to get it all fixed.

  4. I think all blog owners should consider using security keys. Don’t wait till you get hacked before you start thinking about security. Now is the time.

    • Absolutely. Typically, people will unfortunately wait until the worst happens before they take action. Security should be a paramount consideration for any blog owner.

  5. Dave,

    I am sure there are still lots of people who don’t know about this.

    Although there are tons of other things to secure our wordpress blogs, this is very essential and a must-do and check

    Thanks for bring it up!

    • Indeed. I think I’m going to write an article with general security measures that need to be included as standard, such as using the security keys.

  6. Can you add the security keys after you have installed wordpress? Or can it be difficult like changing the database prefix when you have already installed wordpress?

Leave a Reply