Join our Newsletter — 33% off our NHI Course
Home› FAQ› Cyber Security› What is the difference between an SSH private…
Cyber Security

What is the difference between an SSH private key and the public key stored on a server?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated October 30, 2026 Domain: Cyber Security

An SSH private key stays on the client and must remain secret, while the public key is placed on the server in authorized_keys. The public key identifies who may connect, but only the matching private key can prove possession during login. If the private key is exposed, the account associated with that key can be impersonated.

Why the SSH private key and the server-side public key are not the same thing

The SSH keypair works as a possession test, not a shared secret. The private key stays with the client and is the only part that can create a valid cryptographic proof during login. The public key can be stored on the server because it is meant to be shared, indexed, and matched against the private half without revealing it.

That separation is why the server does not need to know your private key. It only needs the public key entry in SSH Key and Certificate Management Guide style authorized key stores to decide whether a presented login attempt corresponds to an approved keypair.

What each key actually does in authentication

The public key is an identifier in the authentication workflow, but it does not itself grant access. Its job is to let the server recognize which keypair is allowed for a given account. The private key performs the real proof step: the client signs or otherwise proves possession, and the server checks that proof against the stored public key.

That distinction matters operationally because the server-side public key can be copied, audited, and revoked without weakening the account by itself. If the private key is still protected, the public key alone is not enough to impersonate the user. If the private key is exposed, the trust relationship collapses immediately.

What changes when the private key is exposed or the server copy is wrong

An exposed private key is equivalent to handing over the ability to authenticate as that account until the key is removed, rotated, or otherwise invalidated. The risk is not theoretical convenience loss, it is direct impersonation, usually with whatever permissions that account already has.

Because the public key is stored in authorized_keys, mistakes on the server side usually show up as access drift rather than secrecy loss. Old keys, duplicated keys, or keys left behind after role changes create lingering access paths that are easy to forget and hard to spot without inventory and review. The unused SSH key audit guide is useful here because the same lifecycle problem appears across hosts, deployment keys, and team-managed access.

Risk and Threat Considerations

The main security risk is that SSH keys are often treated as durable infrastructure rather than credentials with a lifecycle. A copied private key can be reused from anywhere unless you have compensating controls such as restricted principals, short-lived certificates, host restrictions, or rapid revocation.

Failure mechanism: Attackers or insiders recover a private key from a workstation, repository, image, backup, or automation host, then replay it against any server that still trusts the matching public key.

Impact: The affected account can be impersonated without triggering password resets, and the blast radius depends on what that account can reach, including privileged shells, deployment paths, or automation tooling.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 addresses the attack surface, NIST SP 800-53 Rev 5 sets the technical controls, and ISO/IEC 27001:2022 defines the regulatory obligations.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-2 — Identification and Authentication (Organizational Users)SSH keypairs authenticate users to systems and protect login proof.
IA-5 — Authenticator ManagementThe question hinges on protecting and rotating the private key authenticator.
AC-6 — Least PrivilegeCompromised SSH keys inherit the account's permissions, so privilege scope drives impact.
Recommendation — Enforce strong identification and authentication for interactive SSH access. Manage SSH private keys as authenticators with issuance, storage, rotation and revocation controls. Restrict SSH account permissions to the minimum required for the role.
ISO/IEC 27001:2022A.5.17 — Authentication informationSSH private keys are authentication information that must be protected and lifecycle-managed.
Recommendation — Protect and rotate SSH private keys as sensitive authentication information.
OWASP Non-Human Identity Top 10NHI-02 — Secret LeakageAn exposed SSH private key is leaked secret material that enables impersonation.
Recommendation — Scan for leaked SSH private keys and revoke any exposed key immediately.

Practitioner Guidance

What to verify: Confirm which accounts and systems trust the keypair, not just whether the key exists. A server entry in authorized_keys should map to a named owner, an intended use case, and a review date; otherwise it is unmanaged access.

Decision rule: If the private key may have been exposed, treat it as compromised credentials and rotate or remove trust first, then investigate potential misuse. Do not wait for proof of abuse before revoking a key that can still authenticate.

What good looks like: Keypairs are unique per purpose, old keys are removed promptly, and privileged access is limited to keys with clear ownership and expiry. Where possible, move from long-lived static keys to controls that reduce standing trust and make revocation easier, such as SSH certificates or tightly governed automation credentials.

Practitioner takeaway: The public key is a server-side allowlist entry, but the private key is the credential. Treat exposure of the private half as an account compromise, not a configuration issue.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 30, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org