Rotation of passwords for SaaS accounts or REST API endpoints using custom scripts
Keeper supports custom scripting for the purpose of rotation or other actions. To demonstrate this capability, a few examples have been published.
Rotating Okta user accounts using the Okta API
This documentation explains how to rotate Okta accounts using KeeperPAM's rotation option called "Run PAM scripts only". This is a setting in the PAM User rotation settings which tells the Gateway to skip the primary rotation method and directly execute the post-rotation script attached to the PAM User record in the vault.
KSM Application: Ensure that the Keeper Secrets Manager (KSM) application is set up.
Shared Folder: A shared folder should be set up where all the records will be stored.
PAM Configuration: Ensure that the PAM Configuration is set up and that the Gateway is running and attached to this configuration.
Okta API Token: You will need an Okta API Token to interact with the Okta API.
Follow the steps in the official Okta documentation to generate an API token.
Store this API token in a Keeper record. The record can be of any type, but for this example, we will use a "Login" type.
Store the API Token in the "password" field.
Store the Organization URL in the "Website Address" field.
Name this record "Okta API Access Details" as this title will be used to fetch the record in the script later.
Create a new PAM User record to store Okta User details whose password will be rotated.
Set the username to match the Okta user's email address.
Set the password to the current password set for the user.
Add the "Additional Credential" record, which is the "Okta API Access Details" record created in Step 1.
In the example below, we'll use the bash script because the Keeper Gateway is running as a Docker container.
Rotation Type: Set it to "Run PAM scripts only"
PAM Configuration: Select the configuration for your environment
In order for the post-rotation script to execute, the host where the Keeper Gateway is running needs to have the necessary execution environment available.
The Bash script below works on the latest Docker version of the Keeper Gateway or any Linux environment that has jq
installed.
The Python script below is well-commented and follows best practices. It imports necessary modules, initializes variables, and defines functions for various tasks like finding a password by its title, fetching all Okta users, and rotating the password for the particular user.
Rotating Snowflake users within your Keeper Vault
This documentation explains how to rotate Snowflake accounts using KeeperPAM's rotation option called "Run PAM scripts only". This is a setting in the PAM User rotation settings which tells the Gateway to skip the primary rotation method and directly execute the post-rotation script attached to the PAM User record in the vault.
This guide includes prerequisites, step-by-step instructions, and a Python script example.
KSM Application: Ensure that the Keeper Secrets Manager (KSM) application is set up.
Shared Folder: A shared folder should be set up where all the records will be stored.
PAM Configuration: Ensure that the PAM Configuration is set up and that the Gateway is running and attached to this configuration.
snowflake.connector Library: Ensure that the snowflake connector library is installed in your python environment.
The Snowflake Connector for Python provides an interface for developing Python applications that can connect to Snowflake and perform all standard operations. You should have snowflake connector library installed in your python environment to successfully run the post-rotation script. To install snowflake connector, activate a Python virtual environment in your keeper-gateway environment and run the following command:
pip install snowflake-connector-python
NOTE: If you want to use a virtual environment, add a shebang line at the top of the script as documented here Python Environment Setup
Follow these steps to successfully setup rotation on Snowflake User Records:
Create a new PAM User record to store Snowflake User details whose password will be rotated.
Set the username to match the Snowflake user's email address.
Set the password to the current password set for the user.
Attach the below Python script that will perform the password rotation. The script has additional comments inside that describe each line.
Enable No-Operation (NOOP) atomic execution:
In the current PAM User record where user's details are stored, create a new custom text field labeled NOOP
and set its value to True
.
Rotation Type: Set it to "On-Demand" for this example.
Password Complexity: Leave it as default unless you have specific requirements.
Rotation Settings: Point to the PAM Configuration set up earlier.
Administrative Credentials Record: Can should be left empty
PAM script to rotate Snowflake user credentials:
The above script for the Snowflake Post-Rotation Script can be also found here:
After successfully setting up Rotation for your Snowflake User Credentials on the PAM User Record, clicking on "Run Scripts Only" will rotate the credential:
Automatically rotate any cloud-based account using a REST API with Keeper Secrets Manager
This documentation provides generic instructions on how to set up password rotation using KeeperPAM's rotation option called "Run PAM scripts only". This is a setting in the PAM User rotation settings which tells the Gateway to skip the primary rotation method and directly execute the post-rotation script attached to the PAM User record in the vault.
This guide includes pre-requisites, step-by-step instructions, and a Python script example.
KSM Application: Ensure that the Keeper Secrets Manager (KSM) application is set up.
Shared Folder: A shared folder should be set up where all the records will be stored.
PAM Configuration: Ensure that the PAM Configuration is set up and that the Gateway is running and attached to this configuration.
REST API Token: You will need an API Token to interact with the arbitrary API.
Follow the steps in your target application or service to generate an API token.
Store this API token in a Keeper record. The record can be of any type, but for this example, we will use a "Login" type.
Store the API Token in the "password" field.
Store the Organization URL in the "Website Address" field.
Name this record "API Access Details" as this title will be used to fetch the record in the script later.
Create a new PAM User record to store target User details whose password will be rotated.
Set the username to match the user's login ID.
Set the password to the current password set for the user (this really depends on the REST endpoint)
Attach the below Python script that will perform the password rotation. The script has additional comments inside that describe each line.
Add the "Rotation Credential" record, which is the record created in Step 1 containing the API Token and URL.
Enable No-Operation (NOOP) atomic execution:
In the current PAM User record where user's details are stored, create a new custom text field labeled NOOP
and set its value to True
.
Rotation Type: Set it to "On-Demand" for this example.
Password Complexity: Leave it as default unless you have specific requirements.
Rotation Settings: Point to the PAM Configuration set up earlier.
Administrative Credentials Record: Can should be left empty
Below steps are related to the environment where the Keeper Gateway is running.
Ensure that the Python environment has all necessary dependencies installed.
If you want to use a virtual environment, add a shebang line at the top of the script.
Note: Ensure that the shebang line does not contain spaces. If it does, create a symbolic link without spaces. Example to create a symbolic link on Linux:
sudo ln -s "/Users/john/PAM Rotation Example/.venv/bin/python3" /usr/local/bin/pam_rotation_venv_python3
The Python script is well-commented and follows best practices. It imports necessary modules, initializes variables, and defines a rotation function to call an arbitrary REST API that changes user's password.
Rotate your Cisco IOS XE Network Credentials
In this guide, you will learn how to set up password rotation to rotate Cisco IOS XE network credentials.
KSM Application: Ensure that the Keeper Secrets Manager (KSM) application is set up.
Shared Folder: A shared folder should be set up where all the records will be stored.
PAM Configuration: Ensure that the PAM Configuration is set up and that the Gateway is running and attached to this configuration.
Requests Library: Ensure that the requests library is installed in your Python environment. This library is necessary for making HTTP requests to Cisco devices.
Setting up AnyConnect Cisco VPN: In order to connect to cisco devices, ensure that the machine hosting Keeper Gateway has Cisco AnyConnect VPN installed and properly configured
Test Cisco Device Connectivity
The Requests library allows you to send HTTP requests easily. Activate a Python virtual environment in your Keeper Gateway environment and install the library using the following command:
Ensure that the machine hosting Keeper Gateway has Cisco AnyConnect VPN installed and properly configured in order to connect to cisco device. This setup is necessary for establishing secure connections to Cisco devices.
Following these steps will allow you to test the Cisco device and create a new user in the Cisco sandbox environment.
Note: If you want to use a virtual environment, add a shebang line at the top of the script as documented here in the Python Environment Setup.
Go to the Cisco DevNet Sandbox
Log in with your Cisco account credentials.
Select and launch the sandbox.
Navigate to the sandbox catalog.
Select the appropriate sandbox for your Cisco device (e.g., Cisco IOS XE, etc.).
Launch the sandbox.
After launching the sandbox, you will receive an email with the connection details or find them in the DevNet Environment under Quick Access.
Download and install the Cisco AnyConnect Secure Mobility Client.
Get detailed connection instructions here.
Open the Cisco AnyConnect Secure Mobility Client.
Enter the VPN connection details provided in the email or from the DevNet Environment.
Connect using the provided username and password.
At this point, you will see Developer Credentials—a host, username, and password. Store these values in a Keeper Security record of type Login
named as Cisco Authentication Record
. You will need this Keeper Security record name in order to run the post-rotation script.
Add a custom field named host_endpoint
to the Cisco Authentication Record and set its value to the host address (e.g., 10.10.20.48
).
Open your terminal or SSH client.
Connect to the Cisco device using the provided IP address and credentials.
Login with Admin User (developer):
Enable privileged commands:
Enter configuration mode:
Create a new user with a password:
Login with the new user:
Note: Replace
<user>
with the username you created and<device-ip>
with the IP address of the Cisco device.
Once you have your prerequisites ready, make sure you cover the following:
Make sure you satisfy all the prerequisites
Ensure that the post-rotation script references the Keeper Security record containing your Cisco admin credentials.
Attach the post-rotation script to a Keeper Security PAM user record using the Keeper Security documentation. When this record has its secrets rotated, the post-rotation script will execute and update the password for the specified Cisco device user.
Create a new PAM User record to store Cisco User details whose password will be rotated.
Set the username to match the Cisco device admin credentials
Set the password to the current password set for the user.
Add a custom field named host_endpoint
to the Cisco Authentication Record and set its value to the host address (e.g., 10.10.20.48
).
Attach the below Python script that will perform the password rotation. The script has additional comments inside that describe each line.
Enable No-Operation (NOOP) atomic execution:
In the current PAM User record where user's details are stored, create a new custom text field labeled NOOP
and set its value to True
.
Rotation Type: Set it to "On-Demand" for this example.
Password Complexity: Leave it as default unless you have specific requirements.
Rotation Settings: Point to the PAM Configuration set up earlier.
Administrative Credentials Record: Can should be left empty
PAM script to rotate Cisco IOS XE user credentials:
The above script for the Cisco Post-Rotation Script can be also found here:
Note: The user whose password is getting rotated should not be an administrator and must be Authorized for Client VPN [While adding the user via user management portal, the authorized option should be selected as 'Yes'].
After successfully setting up Rotation for your Cisco User Credentials on the PAM User Record, clicking on "Run Scripts Only" will rotate the credential:
Rotate your Cisco Meraki Network Credentials
In this guide, you will learn how to set up password rotation to rotate Cisco Meraki network credentials.
KSM Application: Ensure that the Keeper Secrets Manager (KSM) application is set up.
Shared Folder: A shared folder should be set up where all the records will be stored.
PAM Configuration: Ensure that the PAM Configuration is set up and that the Gateway is running and attached to this configuration.
Requests Library: Ensure that the requests library is installed in your Python environment. This library is necessary for making HTTP requests to Cisco devices.
Setting up AnyConnect Cisco VPN: In order to connect to cisco devices, ensure that the machine hosting Keeper Gateway has Cisco AnyConnect VPN installed and properly configured
Test Cisco Device Connectivity
The Requests library allows you to send HTTP requests easily. Activate a Python virtual environment in your Keeper Gateway environment and install the library using the following command:
Ensure that the machine hosting Keeper Gateway has Cisco AnyConnect VPN installed and properly configured inorder to connect to cisco device. This setup is necessary for establishing secure connections to Cisco devices.
Following these steps will allow you to test the Cisco device and create a new user in the Cisco sandbox environment.
Note: If you want to use a virtual environment, add a shebang line at the top of the script as documented here in the Python Environment Setup.
Go to the Cisco DevNet Sandbox
Log in with your Cisco account credentials.
Select and launch the sandbox.
Navigate to the sandbox catalog.
Select the appropriate sandbox for your Cisco device (e.g., Cisco IOS XE, etc.).
Launch the sandbox.
After launching the sandbox, you will receive an email with the connection details or find them in the DevNet Environment under Quick Access.
Download and install the Cisco AnyConnect Secure Mobility Client.
Get detailed connection instructions here.
Open the Cisco AnyConnect Secure Mobility Client.
Enter the VPN connection details provided in the email or from the DevNet Environment.
Connect using the provided username and password.
At this point, you will see Developer Credentials—a host, username, and password. Store these values in a Keeper Security record of type Login
named as Cisco Authentication Record
. You will need this Keeper Security record name in order to run the post-rotation script.
Add a custom field named network_id
to the Cisco Authentication Record and set its value to the host address (e.g., 13.0.0.1
).
Open your terminal or SSH client.
Connect to the Cisco device using the provided IP address and credentials.
Login with Admin User (developer):
Enable privileged commands:
Enter configuration mode:
Create a new user with a password:
Login with the new user:
Note: Replace
<user>
with the username you created and<device-ip>
with the IP address of the Cisco device.
Once you have your prerequisites ready, make sure you cover the following:
Make sure you satisfy all the prerequisites
Ensure that the post-rotation script references the Keeper Security record containing your Cisco admin credentials.
Attach the post-rotation script to a Keeper Security PAM user record using the Keeper Security documentation. When this record has its secrets rotated, the post-rotation script will execute and update the password for the specified Cisco device user.
Create a new PAM User record to store Cisco User details whose password will be rotated.
Set the username to match the Cisco device admin credentials
Set the password to the current password set for the user.
Add a custom field named network_id
to the Cisco Authentication Record and set its value to the host address (e.g., 13.0.0.1
).
Attach the below Python script that will perform the password rotation. The script has additional comments inside that describe each line.
Enable No-Operation (NOOP) atomic execution:
In the current PAM User record where user's details are stored, create a new custom text field labeled NOOP
and set its value to True
.
Rotation Type: Set it to "On-Demand" for this example.
Password Complexity: Leave it as default unless you have specific requirements.
Rotation Settings: Point to the PAM Configuration set up earlier.
Administrative Credentials Record: Can should be left empty
PAM script to rotate Cisco Meraki user credentials:
The above script for the Cisco Post-Rotation Script can be also found here:
Note: The user whose password is getting rotated should not be an administrator and must be Authorized for Client VPN [While adding the user via user management portal, the authorized option should be selected as 'Yes'].
After successfully setting up Rotation for your Cisco User Credentials on the PAM User Record, clicking on "Run Scripts Only" will rotate the credential: