-----BEGIN … PRIVATE KEY-----

Exposed Private Key (RSA / SSH / EC)? Here's how to detect and rotate it

A -----BEGIN PRIVATE KEY----- block lets an attacker log into servers, decrypt HTTPS traffic, or forge signatures as you. Scan free with Trust, then rotate the key.

A private key is the secret half of a keypair — the block that starts with -----BEGIN … PRIVATE KEY-----. It might be an SSH key that logs into your servers, a TLS key that terminates HTTPS for your domain, or a signing key that proves a token or artifact really came from you. The public half is meant to be shared; the private half must never leave your control. If it leaks, anyone holding it can act as you.

What an attacker can do with a leaked Private Key (RSA / SSH / EC)

How Private Key (RSA / SSH / EC)s get exposed

Scan your repo and live site for exposed Private Key (RSA / SSH / EC)s — free

Trust checks your code, git history, and shipped JavaScript. No signup, results in about a minute.

Run a free scan →

How to rotate a leaked Private Key (RSA / SSH / EC)

  1. Generate a brand-new keypair — for SSH run ssh-keygen -t ed25519 -C "you@example.com" to a new filename; for TLS generate a fresh key and CSR; for a signing key mint a new one in your tool.
  2. Add the NEW public key everywhere the old one was trusted — append it to ~/.ssh/authorized_keys on each server, add it as a new GitHub/GitLab deploy key, or install the reissued cert — and keep the old one in place for now so you don't lock yourself out.
  3. Test that the new key works (ssh in with it, or verify the new cert serves) before you touch the old one.
  4. Now remove every trace of the old key — delete its line from authorized_keys, delete the old deploy key in your Git host's settings, and delete the leaked key file locally.
  5. For a TLS key, reissue the certificate from your CA and REVOKE the old cert so the leaked key can't be used even if someone kept it.
  6. Audit auth and access logs — SSH logins, Git clone events, cert usage — for any sessions from unfamiliar IPs while the key was exposed.

Other secret types to check

Keep your app safe