User Agents

Web browsers and everyday web tech, explained

How to Clear SSSD Cache in Linux: A Complete Guide

· 4 min read · Cookies and Cache

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Clearing the System Security Services Daemon (SSSD) cache forces the system to discard stored identity, authentication, and group information and fetch fresh data from the backend provider (such as Active Directory, LDAP, or FreeIPA). This process is essential when user permissions have changed on the server but are not reflecting on the local machine, or when account lockouts and password changes are not being recognized immediately.

What You'll Need

  • A Linux system with SSSD installed and running.
  • Root or sudo privileges to execute administrative commands.
  • Terminal access (SSH or local console).

Step-by-Step

  1. Identify the scope of the cache clear. Decide if you need to clear the entire cache for all users or just the cache for a specific user. Clearing the entire cache is more thorough but can cause a brief spike in network traffic as the system re-queries the backend for every active session.
  2. Clear the entire SSSD cache. To wipe all cached data, run the following command in your terminal:
    sudo sss_cache -E
    The -E flag stands for "everything," which clears the cache for users, groups, and other identity information.
  3. Clear a specific user's cache (Optional). If you only need to update one person's account to avoid affecting other users, use the -u flag:
    sudo sss_cache -u username
    Replace username with the actual login name of the user.
  4. Clear a specific group's cache (Optional). To update membership for a specific group, use the -g flag:
    sudo sss_cache -g groupname
    Replace groupname with the name of the group.
  5. Restart the SSSD service. While sss_cache handles the data, restarting the daemon ensures that all internal states are reset and the service is operating cleanly:
    sudo systemctl restart sssd
  6. Verify the changes. Use the id command to check if the user information is now correct:
    id username
    If the group memberships or UID/GID have updated, the cache clear was successful.

Common Mistakes

  • Forgetting sudo: Running sss_cache without root privileges will result in a permission denied error, as the cache files are owned by the system.
  • Assuming sss_cache deletes files: The sss_cache tool tells the daemon to invalidate entries. It does not physically delete the cache.sdb file from the disk. If the database is corrupted, a different approach is needed.
  • Restarting the service before clearing the cache: Restarting sssd does not automatically clear the persistent cache stored on disk. You must run the sss_cache command first or manually delete the database files.
  • Ignoring network connectivity: If the machine cannot reach the LDAP or AD server, clearing the cache will remove the local copies of user data, and users may be unable to log in because the system cannot fetch new data.

Tips

  • Use the -E flag during migrations: When moving users between OUs (Organizational Units) in Active Directory, using sss_cache -E is the fastest way to ensure all group policy and membership changes propagate.
  • Check logs for errors: If the cache doesn't seem to update, check the SSSD logs located in /var/log/sssd/. These logs provide detailed information on why a backend request might be failing.
  • Combine commands: You can chain the cache clear and the restart into a single line for efficiency: sudo sss_cache -E && sudo systemctl restart sssd.

Troubleshooting

If sss_cache -E does not resolve the issue, the cache database itself may be corrupted or stuck. In these cases, you must perform a manual hard reset of the cache files.

Manual Cache Deletion:

  1. Stop the SSSD service: sudo systemctl stop sssd
  2. Navigate to the SSSD database directory: cd /var/lib/sss/db/
  3. Remove the cache files: sudo rm -rf cache.sdb* (Note: Be extremely careful with rm -rf).
  4. Start the SSSD service: sudo systemctl start sssd

If users still cannot authenticate, verify that the sssd.conf file has the correct permissions (it must be 600) and that the backend server is reachable via ping or telnet on the required ports (e.g., 389 for LDAP or 88 for Kerberos).

Frequently Asked Questions

Does clearing the SSSD cache log out current users?

No, clearing the cache does not terminate existing SSH or local sessions. However, it may affect the permissions of new processes started by those users.

How often should I clear the SSSD cache?

You should not clear it on a schedule. Only clear it when you have made changes to the identity provider (like AD or LDAP) that need to be reflected immediately on the client.

What is the difference between sss_cache and restarting the service?

Restarting the service stops and starts the process, but SSSD stores its cache in a persistent database file on disk. sss_cache specifically tells the system to invalidate the entries in that database.

Can I clear the cache for just one group?

Yes, using the sss_cache -g [groupname] command allows you to target a specific group without affecting the rest of the system's cached identities.

Will clearing the cache slow down my server?

On systems with thousands of users, a full cache clear (-E) can cause a temporary increase in CPU and network load as the system re-populates the cache from the server.