To replace a service password, API key or token safely, first identify every consumer. Prepare the new secret and a rollback plan, update each dependency, test with a genuinely fresh connection, then revoke the old credential. The change is complete only when monitoring remains clean and the old secret no longer works.
A technical password is not a user password
A user password is entered by a person. A technical secret is consumed automatically by software: a database account, NAS credential, API token, deployment key or backup account.
This difference changes the procedure. A user can type a new password at the next login prompt. A service will continue using the old value until its configuration has been updated and reloaded.
Rotation should not become a context-free routine. Lifetime depends on what the secret protects, its exposure and the system's ability to accept a change. The OWASP Secrets Management guidance describes this lifecycle around creation, rotation, revocation and expiration.
1. Map the secret and every dependency
Before changing anything, answer three questions: where is the secret defined, which components consume it and how will you prove that each component still works afterward?
| Secret | Possible consumers | Useful validation |
|---|---|---|
| Database account | Application, migration task, backup | Fresh connection and simple query |
| Network share account | Server mount, copy job, monitoring | New mount plus read/write test |
| API token | Application, integration, automation | Low-impact authenticated request |
| Deployment key | CI/CD, server, repository | Repository read and test deployment |
Search environment variables, configuration files, secrets managers, scheduled jobs, system services, CI/CD settings and external devices. Record owners and restart order, but never copy the secret value into the inventory itself.
2. Prepare the change and the rollback
Choose a quiet maintenance period, notify the people concerned and define the signals that require a rollback: authentication errors, failed backups, blocked queues or missing monitoring signals.
- keep the old secret active during the transition when the service supports it;
- prepare a way to restore the configuration without exposing the secret;
- make sure a second administrative access path exists;
- define the tests before starting;
- identify who decides whether to continue or roll back.
If the system supports two credentials at once, create the new one, migrate consumers and only then remove the old one. This overlap greatly reduces interruption risk. If only one credential can exist, preparation and timing become even more important.
3. Create and store the new secret correctly
Generate a unique value suited to the authentication mechanism and limited to the permissions actually required. Store it directly in the secrets manager or protected configuration location intended for it.
Avoid Git repositories, tickets, messaging systems, plaintext scripts or shell commands that will remain in history. If a secret has been exposed, deleting it from a file is not enough: treat it as compromised and replace it.
4. Update consumers in a controlled order
Update the configuration source first, then reload only the affected component. When possible, work one consumer at a time: application, scheduled job, backup, monitoring, then secondary integrations.
A correct file does not prove that the service has reloaded it. Depending on the application, you may need to reload configuration, recreate a container or restart a process. Validate actual behaviour, not just file contents.
5. Test with a genuinely fresh connection
An existing session may continue to work with cached authentication. It therefore does not prove that the new secret is valid. Close the current session or use a separate client, then authenticate again using the new credential.
The test should resemble real use while remaining low risk: read and write a small file on a share, run a non-destructive query, call an authenticated health endpoint or fetch repository references.
- check the return code and response content;
- review client and server logs;
- wait for the next run of a critical scheduled task;
- confirm that monitoring signals are still arriving.
6. Revoke the old secret
Once every consumer has been validated, disable the old credential. Then explicitly verify that it is rejected. This final check prevents an obsolete access path from remaining active indefinitely.
If exposure or compromise is suspected, the priority changes: reduce access as quickly as possible, investigate abnormal use and handle the rotation as part of incident response. Continuity still matters, but it should not unnecessarily prolong a compromised credential.
7. Monitor and document the change
Watch authentication errors, scheduled tasks and alerts for a period that matches the service's operating rhythm. A daily backup cannot be fully validated by an immediate test alone; its next scheduled run must also succeed.
Record the date, scope, updated components, tests and secret owner. Never include the secret value in the change record. This documentation makes the next rotation easier and helps reveal forgotten dependencies.
Check configuration before changing the secret
Static checks can identify missing variables, accidentally embedded secrets and inconsistencies in Dockerfile, Compose or Kubernetes configuration before a restart.
Explore TechAtelier tools Check a Compose fileValidation checklist
- the secret and all known consumers have been inventoried;
- the new secret is stored outside source code with minimum required permissions;
- each component has reloaded its configuration;
- a fresh connection succeeds with the new value;
- scheduled jobs and monitoring still work;
- the old secret has been revoked and its rejection verified;
- the change is documented without revealing sensitive data.
Common mistakes
- changing the server-side credential without updating consumers;
- forgetting a scheduled task or rarely connected device;
- validating only with an already authenticated session;
- restarting several services at once and losing the ability to isolate a failure;
- revoking the old credential before the new path is validated;
- leaving both credentials active indefinitely after the migration.
Frequently asked questions
Should every password be rotated regularly?
No. Human passwords and technical secrets do not necessarily follow the same policy. Rotation should reflect risk, exposure, service capabilities and events such as a credential leak or access change.
How do you verify that the new secret works?
Open a fresh connection using the new credential and perform a representative operation. An existing session may continue working and hide a configuration error.
When should the old secret be revoked?
After all known consumers have been updated and the new credential has been validated. If compromise is suspected, reduce exposure as quickly as possible according to the incident response plan.
Where should a technical secret be stored?
Use a secrets manager or another protected configuration location. Avoid source repositories, plaintext scripts, tickets, messaging systems and shell histories.
A safe rotation is a migration, not a password edit
The key principle is simple: inventory first, introduce the new credential, validate every consumer, then remove the old one. Treating secret rotation as a small migration rather than a single password change greatly reduces the risk of unexpected downtime.
Published on 12 September 2026.