Rotating Stored Passwords
PrivX can automatically rotate target account passwords over SSH or Windows Remote Management (WinRM). To configure a target account to use a stored password for authentication, see Stored Passwords.
We recommend using SSH certificate authentication instead of password rotation whenever possible. For setup instructions, see SSH Certificate Authentication.
When rotation is enabled, PrivX periodically changes the password on the target account according to the password-rotation policy and stores the new password in PrivX.
Prerequisites
Before enabling password rotation, check the requirements for the target host:
-
Unix: Configure at least one SSH service on the host entry in PrivX. For the service used for rotation, specify the target host's SSH host keys. Password rotation requires these keys even if Trust on first use is enabled for interactive connections.
-
Windows: Configure WinRM on the target host. For a test configuration, see Enabling Remote Commands on Windows with WinRM.
If a separate server changes passwords on behalf of the target, see Dedicated Rotation Server.
Configuring Password Rotation
To set up password rotation:
- Create a password policy to define when PrivX rotates passwords and how it generates them.
- Select or create a rotation script that can change passwords on the target.
- Configure rotation on the target host and enable it for the required accounts.
Accounts Used for Password Rotation
When PrivX rotates a password, it generates a new password for a target account, changes the password on the target, and stores the new password in PrivX.
Before you proceed, decide which target accounts need their passwords rotated and which account will run the script. PrivX supports two ways to change a target account's password:
| Method | Example | Access requirements |
|---|---|---|
| Use an administrator account | PrivX runs the script as admin to change the password for appuser. | The administrator account must have permission to change other accounts' passwords. With this method, you do not need to enter each target account's current password in PrivX. Configure non-interactive access to this account: a) SSH: Use certificate or stored-password authentication. If you use a certificate, the administrator account must be able to change passwords without a sudo password prompt. b) WinRM: Store the administrator account's current password in PrivX. |
| Use individual accounts | PrivX runs the script as appuser to change its own password. | Store each target account's current password in PrivX. Each account must be able to change its own password using its default shell. |
We strongly recommend leaving password rotation disabled for the administrator account's own password, whichever method you use. You can still use the administrator account to rotate other accounts' passwords.
If the administrator password stored in PrivX gets out of sync with the password on the target, you may lose access through that account. If it provides your only administrative access, you may lose administrative access to the environment.
In both examples, PrivX stores the new password for appuser.
Creating Password Policies
A password policy defines how often PrivX rotates passwords, the strength of the passwords it generates, and how it handles failed rotation attempts.
To create a new password policy:
-
In the PrivX Web UI, go to Deployment → Password Rotation and select Add Password Rotation Policy.
-
Enter a unique name for the policy and set the rotation interval.
-
Configure the password requirements, maximum number of password revisions, maximum number of retries, and retry interval.
Choose reasonable retry settings that allow for temporary host downtime. When PrivX reaches the retry limit, it stops attempting automatic rotation for the affected account. To resume rotation, see Force Password Rotation.
-
-
Save your changes.
Creating Password-Rotation Scripts
PrivX uses password-rotation scripts to rotate passwords on target accounts. These scripts are composed of variables and shell commands. Variables are used for synchronizing username and password data between PrivX and the target host. You can use a default script or adapt one to your environment.
Choose a script that meets the following requirements:
- Operating system and shell. The script must support the operating system and the default shell of the account that runs it, such as Bash on Linux or PowerShell on Windows.
- Rotation account. If PrivX runs the script as an administrator, the script must be able to change other accounts' passwords. If PrivX runs the script as an individual target account, the script must be able to change that account's own password.
- Non-interactive execution. The script must complete the password change without user interaction.
To choose or create a script:
- Go to Deployment → Password Rotation. In the Script Templates section, review the default scripts.
- If you need a custom script, select Add Script Template. Use a default script as a starting point, adapt the commands to your environment, and select Save.
You will need this script later when you enable password rotation on the target host.
Passing Input over SSH on Linux
PrivX can pass passwords to a rotation command over SSH through standard input (stdin). This keeps the passwords out of the remote command's arguments and shell history.
| Setting | Values | Description |
|---|---|---|
@pipe_over_ssh | true or false | Set to true to pass input to the remote command over SSH through standard input. |
@use_sudo_pass | true or false | Set to true if sudo requires a password. For administrator-account rotation, PrivX uses the administrator account's password. For individual-account rotation, PrivX uses the target account's current password. |
@stdin | Text or template variables | Specifies the input to send to the command. Use \n to separate lines. |
To change other accounts' passwords with an administrator account, use @stdin to supply the administrator's sudo password on the first line, followed by one username:new_password pair per target account.
$sudo_password\n$user_password_list
In the shell equivalent below, sudopass authenticates the administrator, user1:pass1 sets the password for user1 to pass1, and user2:pass2 sets the password for user2 to pass2.
(echo sudopass; echo user1:pass1; echo user2:pass2) | ssh target.ip.com sudo -k -S chpasswd
To change an account's own password, use @stdin to supply the current password, the new password, and the new password again for confirmation.
@stdin=$old_password\n$password\n$password
In the shell equivalent below, the account changes its password from pass1 to pass2.
(echo pass1; echo pass2; echo pass2) | ssh target.ip.com passwd
Script Variables and Settings for Windows and Linux
Use the following variables to pass target account details to the rotation command:
| Variable | Description |
|---|---|
$username | Username of the target account whose password PrivX is changing. |
$old_password | Current password of the target account. |
$password | New password for that target account. |
If the command accepts a list of usernames and passwords, use the following settings to format the list:
| Setting | Description |
|---|---|
@list_format | Defines the format of each entry. For example, $username:$password separates the username and new password with a colon. |
@list_item_prefix | Specifies a prefix if the rotation command requires one. |
@list_separator | Specifies the separator between entries. For example, "\n" places each entry on a separate line. |
To run the password-rotation script on a separate (dedicated) server, specify the server and the account that runs the password-change command:
@rotation_server="<uuid>:<username>@<address>:<port>"
- Use the rotation server's Identifier in PrivX for
<uuid>. - Enter the account that runs the command for
<username>, the rotation server's address for<address>, and the port of its SSH or RDP service for<port>.
For setup instructions, see Dedicated Rotation Server.
Enabling Password Rotation on Target Hosts and Accounts
To enable password rotation on a host and select which accounts PrivX rotates:
-
Go to Administration → Hosts and select Edit for the target host.
-
In the Options section, enable Rotate account passwords. The Password Rotation section appears below Accounts.
- In the Password Rotation section, select the required protocol to use for rotation.
- Configure how passwords are rotated on all enabled accounts with Rotation Policy, Operating System, and Rotation Script. Choose a script that supports the operating system and the account that will run it.
- Under Rotation Account Type, select Rotate passwords with admin account or Rotate passwords with individual account to match the method you chose in Accounts Used for Password Rotation.
-
In the Accounts section, under Password Rotation enable Rotate this account for each target account whose password you want PrivX to change.
cautionWe recommend leaving Rotate this account disabled for administrator accounts. If an administrator account's password changes on the target and the password stored in PrivX gets out of sync, the password may be unrecoverable. You can leave this setting disabled for the administrator account and still use that account to rotate other accounts' passwords.
-
Save the changes.
Verifying Password Rotation
- Go to Administration → Hosts and open the target host's details.
- In the Accounts section, verify that Password rotation is Enabled for each account you configured.
- After a rotation, verify that Rotation status is OK. To test rotation immediately, see Force Password Rotation.
Force Password Rotation
You can rotate a target account's password immediately. Use Rotate Now to test the configuration, change a password before its next scheduled rotation, or resume automatic rotation after PrivX reaches the retry limit.
To force password rotation on a target account:
- Go to Administration → Hosts and open the target host's details.
- In the Accounts section, open the actions menu for the target account and select Rotate Now.
PrivX attempts to rotate the password and notifies you when the operation finishes.
Use Rotate Now to test the configuration, change a password before its next scheduled rotation, or resume automatic rotation after PrivX reaches the retry limit
Dedicated Rotation Server
Configure PrivX to run password-rotation scripts on a dedicated password-rotation server (rotation server). A rotation server is a separate machine from target hosts, but with the ability to change target-account passwords.
The setup involves the following steps:
- Set up PrivX access to the rotation server.
- Create a password-rotation script that targets the rotation server.
- Enable password rotation using this rotation script.
To configure password rotation using a dedicated server
-
Go to Administration → Hosts and select Add Host to add the rotation server.
- In the Services section, add an SSH service for rotation over SSH or an RDP service for rotation over WinRM.
- In the Accounts section, add the account that runs the password-rotation commands on the rotation server. Grant the
privx-adminrole access to this account.
-
Select Save. Open the rotation server's details and copy its Identifier. This is the host's UUID in PrivX. You will need this UUID to configure the password-rotation script.
-
Create a password-rotation script and include the following entry:
@rotation_server="<uuid>:<username>@<address>:<port>"Value Description <uuid>Identifier of the rotation server in PrivX. <username>Account that runs the rotation commands on the rotation server. <address>Address of the rotation server. <port>Port of the SSH or RDP service configured for the rotation server. The following example shows a basic password-rotation script that targets a rotation server:
@pipe_over_ssh=true@stdin="$username\n$password"@rotation_server="123e4567-e89b-42d3-a456-426614174000:rotator@192.0.2.10:22"#!/bin/bashread usernameread passwordexport usernameexport password/example/password-rotation-command -
In the target host's Password Rotation settings, select the script you created. Then enable Rotate this account for the required target accounts and save the host. For the full procedure, see Enabling Password Rotation on Target Hosts and Accounts.
For a detailed example of setting up a rotation server, see Web Target Password Rotation with Rotation Server.
Examples
Enabling Remote Commands on Windows with WinRM
To enable password rotation on Windows hosts, configure remote-command support using Windows Remote Management (WinRM).
To enable WinRM on a Windows host:
The instructions in this example are verified against Windows Server 2019. Adapt these instructions as needed for other platforms. The commands are only for testing purposes and are not suitable for production environments.
-
Gain Administrator access to the target host.
-
Create a certificate for HTTPS connections:
$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "test-windows" -
Enable remote PowerShell:
Enable-PSRemoting -SkipNetworkProfileCheck -Force -
Create an HTTPS listener using the certificate created earlier:
New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint -Force -
Open port 5986 for WinRM access:
New-NetFirewallRule -DisplayName "Windows Remote Management (HTTPS-In)" -Name "Windows Remote Management (HTTPS-In)" -Profile Any -LocalPort 5986 -Protocol TCP -
Finally, configure WinRM with:
winrm quickconfig
The Windows host now accepts remote commands over WinRM. You can now enable password rotation on the host.
Web Target Password Rotation with Rotation Server
In this example, PrivX connects to a Linux rotation server over SSH. The rotation server runs a command that changes a web target account's password. The example uses the following configuration:
-
Web target: An existing host in PrivX named
Example Web Targetathttps://web-target.example.com. Allows password authentication for thealiceaccount, which is available to all PrivX users.
-
Rotation server: A Linux server at
192.0.2.10that accepts SSH connections on port22. Itsrotatoraccount can run/example/change-password-commandto change the web target account's password. -
Password policy: A policy named
Example Password Policydefined in PrivX with the settings of your choice. To test rotation by checking out and releasing the password, enable Rotate on Release in the policy.
This example describes how to enable password rotation for an existing web target using a dedicated rotation server. The setup involves the following steps:
- Adding the rotation server to PrivX.
- Creating a password-rotation script that targets the rotation server.
- Enabling password rotation on web targets.
Setting Up Password Rotation with Rotation Server
First, add the example rotation server to PrivX:
-
In the PrivX Web UI Administration → Hosts, click Add Host.
-
Add the example rotation server's SSH service with its address and port. Also add the
rotatoraccount with Roles set toprivx-admin.
-
Save the host, then return to Administration → Hosts, find its entry, and select View. Note the rotation server's Identifier UUID. Use this UUID to configure the password-rotation script.
Next, create a password-rotation script that runs on the rotation server:
-
In the PrivX Web UI Deployment → Password Rotation under Script Templates, click Add Script Template.
-
To target the rotation server, the script must include a
@rotation_serverentry. Using the example rotation server's details, the entry is:@rotation_server="123e4567-e89b-42d3-a456-426614174000:rotator@192.0.2.10:22"The following full script example runs on the rotation server and invokes the password-rotation command, while passing the required credentials from PrivX:
@pipe_over_ssh=true@stdin="$username\n$password"@rotation_server="123e4567-e89b-42d3-a456-426614174000:rotator@192.0.2.10:22"#!/bin/bashread usernameread passwordexport usernameexport password/example/change-password-commandSave the script. In this example, name the script
Example Rotation Script.
Finally, enable password rotation on Example Web Target:
- In the PrivX Web UI Administration → Hosts, select Edit for
Example Web Target. Then under the host's Options, enable Rotate account passwords. - Under the host's Password Rotation section, set up password rotation using the previously created rotation script and the example rotation server:
- Protocol: SSH
- Rotation Policy: Example Password Policy
- Operating System: Linux
- Rotation Script: Example Rotation Script
- Rotation Account Type: Rotate passwords with individual account (since this example does not use root).
- Under the host's Accounts, expand
alice's Password Rotation section and enable Rotate this account. To run the checkout test below, also enable Allow explicit password checkout. - Save your changes.
You have now configured the following:
- Allow PrivX to connect to the rotation server, and to run commands there to change the web-target accounts' passwords.
- Enabled password rotation for the web target's accounts. With Allow explicit password checkout also enabled, PrivX users connecting to the web target in the PrivX Web UI can also manually check out the password during their session.
Testing Password Rotation
If you enabled Rotate on Release in Example Password Policy, you can test rotation during a web session:
- Log into PrivX and under Connections → Hosts and connect to
Example Web Targetusing the target account configured for rotation. - On the connection view's Secrets tab, click Checkout Secret, then copy the secret to verify the account's current password.
- Select Release Secret to trigger rotation.
- After rotation finishes, select Checkout Secret again and verify that the password has changed.
If Rotate on Release is disabled, PrivX rotates the password according to the interval in the policy. To test rotation before the next scheduled attempt, see Force Password Rotation.