Open wp-config.php on any WordPress site and you find eight lines of random-looking text: AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY and four matching SALT lines. Most site owners never touch them. They are one of the most useful tools you have after a security problem.
What the keys do
When you log in, WordPress gives your browser a cookie that says who you are. To stop anyone from simply writing their own cookie, WordPress signs it using these secret keys. On every request, it checks the signature. A cookie signed with the right keys is accepted; anything else is not.
The keys are also used for nonces, the short tokens that protect forms and admin actions against being triggered from another site.
Why changing them logs everyone out
If you replace the keys, every existing login cookie was signed with the old ones, so none of them are valid any more. Everyone, including you, has to log in again. That sounds like a nuisance; it is exactly the point.
Changing a password does not end existing sessions everywhere. Changing the keys does, for every account at once.
When to change them
- After a break-in, or when you suspect one. Attackers often keep a stolen login cookie even after the password changes.
- When someone with administrator access leaves: a developer, an agency, a former employee.
- When a laptop or phone that was logged in is lost or stolen.
- If the keys were never set, or still contain the placeholder text from the sample config file.
- If
wp-config.phpwas ever exposed, for example through a backup file left in a public folder.
There is no need to change them on a schedule. Change them when there is a reason.
How to change them
By hand
- Generate a fresh set. Our free security keys generator makes them in your browser, without sending them anywhere.
- Open
wp-config.phpwith your host’s file manager or SFTP. - Replace the eight existing lines with the new ones. Keep the rest of the file as it is.
- Save. You will be logged out; log in again.
In one click with Keel
In Keel › Hardening › Security tools, press Change the salts. Keel makes a database backup first, writes new keys to wp-config.php, and everyone logs in again. This is in the free version. The file must be writable; the screen tells you if it is not.
Things to know
- Two-factor backup codes need to be made again afterwards in Keel.
- Some hosts and plugins store keys outside
wp-config.php(for example as environment variables). If the lines are missing from the file, check with your host before adding them. - Never share the keys, paste them into a support chat, or commit them to a public repository.
Keys after a hack: the full list
Changing the keys is one step of a clean-up, not the whole thing. After a break-in, also change every password (WordPress, hosting, database, SFTP), remove the malware, update everything, and look for administrators you did not create. See Is my WordPress site hacked?.
Common questions
Will changing the keys break my site?
No. The only effect is that everyone is logged out and has to log in again.
Do I need to change the keys on every site?
Each site should have its own keys. Never copy the same set to several sites.
Do the keys protect passwords?
No. Passwords are stored as hashes in the database; the keys sign cookies and form tokens.