Securing a WordPress website requires more than just installing an endpoint firewall plugin. The true foundation of WordPress security lies directly at the server level within the core configuration file: wp-config.php. Among its most critical components are WordPress Security Keys and Salts—cryptographic variables that protect user passwords, authentication cookies, and session tokens against hijacking.
In this 2026 developer guide, we break down how cryptographic salts work, step-by-step methods to rotate them safely without downtime, and battle-tested wp-config.php rules to harden your production server against automated exploits.
📑 Table of ContentsHide / Show
What Are WordPress Security Keys and Salts?
WordPress security keys and salts are randomized 64-character cryptographic strings stored in your wp-config.php file. They provide multi-layered encryption for credentials stored inside user browser cookies. Whenever an administrator, author, or subscriber logs into your WordPress dashboard, WordPress generates a temporary session cookie containing hashed credentials.
Without security salts, passwords in cookies are hashed using simple MD5 or standard SHA algorithms, making them vulnerable to precomputed rainbow table dictionary attacks and packet-sniffing packet inspection. By injecting unique cryptographic salts, WordPress appends randomized characters to passwords before hashing, transforming credentials into an uncrackable hash string.
WordPress utilizes eight distinct security constants, divided into four keys and four matching salts:
AUTH_KEY&AUTH_SALT– Signs and encrypts authentication cookies for secure user logins.SECURE_AUTH_KEY&SECURE_AUTH_SALT– Dedicated encryption for SSL/HTTPS administrative cookies.LOGGED_IN_KEY&LOGGED_IN_SALT– Validates active user sessions across the frontend and dashboard.NONCE_KEY&NONCE_SALT– Protects WordPress security nonces (numbers used once) to prevent Cross-Site Request Forgery (CSRF) attacks.
When and Why You Must Rotate WordPress Salts in 2026
Rotating your security salts is one of the fastest, most effective incident response measures in WordPress security. You should rotate your salt keys in the following scenarios:
- Suspected Site Compromise or Malware Infection: If an administrator account was breached or unauthorized files were uploaded, rotating salts immediately terminates every active user session, forcing attackers out of the dashboard.
- Staff or Contractor Offboarding: When a developer, agency, or contractor with admin credentials finishes their work, rotating salts ensures no residual session cookies can be reused.
- Scheduled Security Maintenance: Best practices recommend rotating salts every 90 to 180 days as part of regular infrastructure hardening.
Important Note: Rotating security salts will NOT change or reset user passwords, nor will it alter any data in your MySQL database. It simply invalidates existing browser session cookies, requiring all users (including yourself) to log in again with their existing credentials.
How to Rotate WordPress Salts Safely (Step-by-Step)
You can rotate your salt keys using two reliable developer methods:
Method 1: Manual Generation via Official WordPress API
1. Open your browser and navigate to the official WordPress Salt Generator API at https://api.wordpress.org/secret-key/1.1/salt/.
2. Each time you load this URL, the WordPress security team’s server generates a completely fresh, cryptographically secure set of 8 random strings, looking like this:
define('AUTH_KEY', 'r#Z(X+8k_qL9!vW3*mP1$tY7@bC5%eR2^uI4&oN6(sA8)dF0_hJ2+kL4=zX6?');
define('SECURE_AUTH_KEY', 'b@7!tY3$wQ1^mP5&vC9*kL2_rZ4+xN8?uI6(eR0_sA2)dF4=hJ6+kL8-zX0%');
define('LOGGED_IN_KEY', 'm*P9$tY1@bC3%eR5^uI7&oN9(sA1)dF3_hJ5+kL7=zX9?r#Z1(X3k_qL5!vW7');
define('NONCE_KEY', 'k_L2+zX4?r#Z6(X8k_qL0!vW2*mP4$tY6@bC8%eR0^uI2&oN4(sA6)dF8_hJ0');
define('AUTH_SALT', 'u&I4(sA6)dF8_hJ0+kL2=zX4?r#Z6(X8k_qL0!vW2*mP4$tY6@bC8%eR0^uI2');
define('SECURE_AUTH_SALT', 's)A8_hJ0+kL2=zX4?r#Z6(X8k_qL0!vW2*mP4$tY6@bC8%eR0^uI2&oN4(sA6');
define('LOGGED_IN_SALT', 'd_F0+kL2=zX4?r#Z6(X8k_qL0!vW2*mP4$tY6@bC8%eR0^uI2&oN4(sA6)dF8');
define('NONCE_SALT', 'h+J2=zX4?r#Z6(X8k_qL0!vW2*mP4$tY6@bC8%eR0^uI2&oN4(sA6)dF8_hJ0');
3. Access your server via SFTP, SSH, or cPanel File Manager and open wp-config.php in your site’s root directory.
4. Locate the existing AUTH_KEY block and replace it entirely with your newly generated keys.
5. Save the file. You will immediately be redirected to the login screen—log back in with your existing password.
Method 2: 1-Click Instant Rotation via WP-CLI
If you have SSH access to your server, the fastest and zero-error method is using WP-CLI. Run the following command in your WordPress root directory:
wp config shuffle-salts
WP-CLI will automatically contact the API, generate brand new random keys, replace the old values in wp-config.php, and preserve the rest of your configuration perfectly.
Crucial wp-config.php Hardening Directives for 2026
In addition to salt rotation, adding the following security constants to wp-config.php (above the /* That's all, stop editing! */ line) dramatically hardens your server against unauthorized changes:
// 1. Disable Theme and Plugin File Editing from Admin Dashboard
define( 'DISALLOW_FILE_EDIT', true );
// 2. Prevent Unauthorized Plugin & Theme Installation from Dashboard
define( 'DISALLOW_FILE_MODS', true );
// 3. Force Strict TLS/SSL for Admin Logins and Dashboard Access
define( 'FORCE_SSL_ADMIN', true );
// 4. Harden Debugging Logs (Log errors to file, never display on screen)
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
// 5. Limit Post Revisions to Reduce Database Bloat
define( 'WP_POST_REVISIONS', 5 );
// 6. Enforce 3-Minute Autosave Interval to Lower Server CPU Load
define( 'AUTOSAVE_INTERVAL', 180 );
Server-Level Protection for wp-config.php
Because wp-config.php stores your raw MySQL database username, password, host, and database name, protecting it from direct HTTP requests and unauthorized local users is paramount:
1. UNIX File Permissions
Set strict file permissions on wp-config.php using SSH or File Manager. Standard WordPress files use 644, but wp-config.php should be tightened to:
chmod 440 wp-config.php(Read-only by owner and web server group)chmod 400 wp-config.php(Read-only strictly by file owner)
2. Apache & LiteSpeed .htaccess Protection
Add this directive to the top of your root .htaccess file to block direct HTTP requests from any web browser or bot:
<Files wp-config.php>
order allow,deny
deny from all
</Files>
3. Nginx Server Block Directive
For sites running on Nginx, ensure your server configuration blocks direct access to the configuration file:
location = /wp-config.php {
deny all;
return 403;
}
Frequently Asked Questions (FAQ)
Does rotating security salts log out all active users?
Yes. Rotating salt keys instantly invalidates all existing authentication cookies across all devices. Administrators, authors, and logged-in customers will need to log back in with their existing username and password.
Can rotating security salts break my WordPress database?
No. Security salts only encrypt browser cookies and temporary nonces. They do not alter database records, posts, users, or saved passwords in any way.
Why is setting 777 permissions on wp-config.php dangerous?
Permissions of 777 give every user and process on the server full read, write, and execute permissions. Any compromised neighbor account or vulnerable script on shared hosting could read your database credentials in plain text.
⚡ Related WordPress Security & Site Hardening Guides
- How to Stop WordPress Spam Comments & Fake Registrations – Block spambots permanently with Turnstile, honeypots, and Akismet.
- Complete Guide to Two-Factor Authentication (2FA) in WordPress – Add authenticator app verification to bulletproof user credentials.
- Wordfence vs Sucuri vs Solid Security Comparison – Endpoint WAF vs cloud proxy firewalls and server load comparison.
- Comparing WordPress.org and WordPress.com: Key Differences – Understand monetization, cost, plugin freedom, and hosting ownership.

