> For the complete documentation index, see [llms.txt](https://wiki.datadike.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.datadike.com/pam/administration/accounts/rotation.md).

# Rotate credentials

Rotate passwords and SSH keys automatically or on demand, and what to watch for when the credential is a domain account.

## What this is and when to use it

A rotation task changes the secret of one or more accounts on one or more assets, stores the new value in the vault, and — for SSH keys — redistributes the new public key to the targets.

Rotation runs on a schedule, on demand, or both. Use it to satisfy a rotation policy, and immediately after any event that may have exposed a credential.

{% hint style="info" %}
When a password changes, the solution also applies it to the **dependencies** registered for that credential — services, scheduled tasks, and applications that use the same account — so that rotation does not break integrations. Dependencies are declared in the account or task configuration and are updated in the same run.
{% endhint %}

## Before you start

* The asset registered under **Environment › Assets**.
* The credential registered — discovered by an automation or added by hand, it makes no difference.
* The credential linked to the host, either directly or through a template.
* A management protocol reachable on the target:
  * **Windows** — WinRM or OpenSSH
  * **Linux** — SSH
* Firewall open, both the network firewall and the host firewall.
* For WinRM, the solution's IP added as a trusted host on the target.

The solution must be able to reach **each** target to confirm the change. Hosts it cannot reach keep their old password.

## Steps

1. Open **Accounts › Automations › Change secret**.
2. Click **Create**.
3. Fill the fields — see the field reference below. The two that decide the blast radius are **Accounts** and **Assets or Nodes**.
4. Under **Password policy**, set the length and complexity of the generated secret. Match it to the strictest policy among the targets, not the loosest.
5. Under **Periodic**, set the schedule, or leave it off and run the task by hand.
6. Set **Recipient** if someone should be emailed the result.
7. Save, then run the task once manually before trusting the schedule.

## What you should see

![The Change secret screen, listing the rotation tasks](https://1085357737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7xzJyi9JVzRwnV6JzUho%2Fuploads%2Fgit-blob-ef02a06c9d7871c068989567649927d011d8893c%2Frotation.png?alt=media)

**1** How many rotation tasks exist. **2** One task, with the accounts and folders it covers.

The task appears in the list with an execution counter. After a run, the execution log shows one line per asset, with success or failure per host.

## How to verify it worked

Saving and even running the task is not proof. Verify the secret actually changed:

1. Open the account under **Accounts › Accounts**.
2. Open its **password history**. A new version must appear, dated at the run.
3. Open a session to the asset using that account. If the login succeeds, the vault and the target agree.

Step three matters most. A run can report success and still leave a host behind — check the execution log host by host, not just the task status.

## Rotating a domain account

Domain credentials behave differently from local ones, and this is where most mistakes happen.

* The domain account must be registered as a **template**, and the template must be associated with the hosts that authenticate against it. That association is required for the credential to be usable at all, not only for rotation.
* When you rotate, you specify both the **host where the change is executed** and the **hosts that must receive the new credential**.
* The new password is visible under the account, but **the template keeps the original password**. The template is never updated by rotation; changing it is a manual action.
* If you later associate the template with a **new host**, that host must be added to the rotation task. Otherwise it keeps the password stored in the template — which, for a domain account already rotated, no longer works.

That last point is the usual cause of "it worked everywhere except on the new server".

## Rotating SSH keys

The same task rotates SSH keys, scheduled or on demand. On each run the solution generates a new key pair, updates the key in the vault, and redistributes the public key to the associated target assets, so access continues without manual intervention.

## Common errors

| Symptom                                                       | Cause                                                                                          | Fix                                                                                     |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `The password does not meet the password policy requirements` | The generated secret does not satisfy the target's own policy — length, complexity, or history | Raise the complexity in the task's **Password policy** to match the strictest target    |
| Some hosts succeeded, others failed                           | The solution could not reach those hosts                                                       | Check connectivity and the management protocol. Unreachable hosts keep the old password |
| A new server still has the old domain password                | It was added to the template but not to the rotation task                                      | Add the host to the task and run it again                                               |
| The template shows an old password                            | Expected. Rotation never updates the template                                                  | Change the template by hand if you need it to match                                     |
| WinRM connection refused                                      | Port 5985 blocked, or the solution's IP is not a trusted host                                  | Open the port and add the IP to the WinRM trusted hosts                                 |

## Field reference

| Field                    | What it does                                                                                                                                    |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                     | Identifies the task. Required                                                                                                                   |
| Accounts                 | The logins whose password will change. Case-sensitive. Several accounts may be listed, but all receive the same generated secret in a given run |
| Assets or Nodes          | The target hosts, individually or by folder                                                                                                     |
| Password policy          | The generation strategy and complexity of the new secret                                                                                        |
| Automations › Parameters | Additional behavior, such as the groups the account belongs to. Use it so that no account is altered without your knowledge                     |
| Periodic                 | The schedule. Manual execution remains available regardless                                                                                     |
| Active                   | Enables or disables the task without deleting it                                                                                                |
| Recipient                | Email address notified with the run result                                                                                                      |

## Related pages

* [Managed accounts](https://wiki.datadike.com/pam/administration/accounts/managed-accounts.md)
* [Account templates](https://wiki.datadike.com/pam/administration/accounts/account-templates.md) — why the template keeps its original secret
* [Password generation policy](https://wiki.datadike.com/pam/administration/accounts/password-policy.md)
* [Collect accounts from an asset](https://wiki.datadike.com/pam/administration/accounts/discovery-of-accounts.md)
* [Detection and mitigation policy](https://wiki.datadike.com/pam/administration/ueba/policy.md) — rotation triggered by a risk score
