Skip to main content

Rotate the JWT Signing Keys

OpenMetadata signs the JWT tokens it issues with one RSA key pair, set in jwtTokenConfiguration. These tokens include user sessions, personal access tokens, and bot tokens such as the one the ingestion-bot uses. Rotate the key pair when you replace the default keys shipped for testing, when the private key may have leaked, or when your security policy requires it. Rotation is a hard cut. You stop every server, start them all with the new key pair, and then regenerate the bot tokens with the regenerate-bot-tokens command. Tokens signed by the old key stop working.
Plan for downtime. Every server is stopped during the restart. Between the restart and the bot token regeneration, every bot (ingestion, automation, and integrations) is rejected with 401 Unauthorized. Users must sign in again, and every personal access token stops working.

Before You Start

Check the following before you rotate the keys:
  • You run OpenMetadata 2.1.0 or later.
  • You have picked a time when bot downtime is acceptable.
  • You have shell access to a host, container, or pod that can run ./bootstrap/openmetadata-ops.sh. It needs the same configuration as the servers and network access to the server API. A server container or pod meets both conditions.
  • pipelineServiceClientConfiguration.metadataApiEndpoint (SERVER_HOST_API_URL) is set in that configuration. The command reads the server’s JSON Web Key Set (JWKS) from this endpoint and redeploys pipelines through it.

Step 1: Create a New Key Pair

OpenMetadata reads the private key as DER PKCS#8 and the public key as DER X.509. Use keys of 2048 bits or more:
Generate a new key ID:
The new key ID must differ from the current JWT_KEY_ID, so that services that cache the JWKS fetch the new key. The Enable JWT Tokens page asks you to keep the key ID unchanged across upgrades. A key rotation is the exception. Keep private_key.der secret. Make it readable only by the user that runs the OpenMetadata server.

Step 2: Restart Every Server with the New Keys

Stop every OpenMetadata server before you start any server with the new keys. Do not use a rolling restart. During a rolling restart, a restarted server can fetch the old public key from a server that has not restarted yet. This happens when authenticationConfiguration.publicKeyUrls (AUTHENTICATION_PUBLIC_KEYS) points to an OpenMetadata URL behind a load balancer. The server caches that key for up to 24 hours and keeps accepting old user sessions and personal access tokens. The default localhost JWKS URL avoids this problem. Set the following values in the configuration of every server and of the host that runs openmetadata-ops.sh. All of them must hold the same values. Follow the steps for your deployment:
  1. Stop every OpenMetadata server.
  2. Copy private_key.der and public_key.der to the OpenMetadata conf directory of each server, or to the paths set in RSA_PRIVATE_KEY_FILE_PATH and RSA_PUBLIC_KEY_FILE_PATH.
  3. Set JWT_KEY_ID, or jwtTokenConfiguration.keyId in conf/openmetadata.yaml, to the new key ID.
  4. Start every server.
After the servers start, check that each server lists only the new key ID:
Query each server directly. A request through the load balancer checks only one of them. If a rolling restart already happened with a shared JWKS URL, stop all servers and start them again to clear the cached old key. From this point:
  • Users get 401 Unauthorized on their old sessions and must sign in again.
  • Holders of personal access tokens must create new tokens.
  • Bots stay rejected until you complete step 3.

Step 3: Regenerate the Bot Tokens

Run regenerate-bot-tokens from the OpenMetadata server directory, with the same configuration the servers use:
The command does the following:
  1. Fetches <metadataApiEndpoint>/v1/system/config/jwks and checks that it lists the configured key ID with the same public key. If it doesn’t, the command changes nothing, prints the reason, and exits with code 2. This check reads only the server behind metadataApiEndpoint, so it cannot confirm that every server restarted.
  2. Gives every bot that uses JWT authentication a new token signed by the new key. Each change is recorded in the audit log as an update by admin. A bot whose token was revoked is skipped and stays without a token.
  3. Redeploys every ingestion pipeline that is marked as deployed, so that it uses the new ingestion-bot token. When pipelineServiceClientConfiguration.enabled is false, the command skips this step.
A bot works again as soon as its new token is stored. You don’t need to restart the servers.

Command Options

Without --skip-current, the command replaces every token except revoked ones. Run it without the option to replace a leaked bot token without rotating the keys. Don’t use --skip-current in that case, because the leaked token still verifies under the configured key and would be kept.

Command Results

The command prints one row per bot with one of these outcomes:
  • REGENERATED: The bot has a new token.
  • ALREADY_CURRENT: The token was left unchanged. This outcome appears only with --skip-current.
  • SKIPPED: The bot has no bot user, doesn’t use JWT authentication, or its token was revoked.
  • FAILED: The token wasn’t replaced. The details column gives the reason.
If a bot fails with changed concurrently, re-run, someone edited it while the command ran. Run the command again with --skip-current, so that only the failed bots get new tokens. If every bot fails with Private key does not match the public key, RSA_PRIVATE_KEY_FILE_PATH and RSA_PUBLIC_KEY_FILE_PATH point to keys from different pairs. No token is stored in that case.

Pipelines That Aren’t Redeployed

The command redeploys only pipelines marked as deployed. To deploy every pipeline registered in OpenMetadata, including pipelines that were never deployed, run:
For pipelines managed outside OpenMetadata, replace the bot token in their configuration and redeploy them through their own scheduler.

Step 4: Check the Result

Confirm the following:
  • /api/v1/system/config/jwks on each server lists only the new key ID.
  • The command report shows every bot as REGENERATED, or ALREADY_CURRENT on a --skip-current run. Bots whose tokens you revoked show as SKIPPED.
  • Ingestion pipelines run again, on schedule or when you trigger them manually.

Update Tokens Stored Outside OpenMetadata

The new keys invalidate copies of old tokens that other systems hold. Update the following:
  • Personal access tokens: The command doesn’t re-sign or delete personal access tokens. The old tokens can still appear as unexpired in the UI, but requests that use them return 401 Unauthorized. Ask their owners to revoke the old tokens, create new ones, and update their clients.
  • Copied bot tokens: Copy the new token from Settings > Bots to every system that holds the old one, such as CI jobs and external pipelines.
  • Airflow lineage backend: Replace jwt_token in the [lineage] section of airflow.cfg, or metadata_config.securityConfig.jwtToken in the JSON file set in OPENMETADATA_LINEAGE_CONFIG. Pipeline redeployment doesn’t update these values.
  • Airflow OpenMetadataHook: Replace the password of the Airflow connection that the hook uses, openmetadata_default by default. Pipeline redeployment doesn’t update this connection.
  • Services that verify OpenMetadata tokens through the JWKS: Make sure they reload the JWKS and accept the new key ID. Remove any cached or pinned copy of the old public key, so that they reject tokens signed by it.