This SSH key management policy template gives you ready-to-edit policy statements for SSH user keys, host keys and SSH certificates, covering approved key types, lifetimes, control of authorized_keys files, certificate authorities, revocation and monitoring. SSH keys are among the oldest and most numerous non-human identities in most estates. They grant direct, often privileged, access to servers, and they rarely expire on their own. NIST IR 7966 observes that the security of SSH key-based access has been largely ignored to date, and a written policy is the first step to changing that.
This template is deliberately specific to SSH. It sits underneath a general cryptographic key policy such as our Cryptographic Key Management Policy Template, which covers key states, cryptoperiods and custody for every key class. Where the two overlap, this policy adds the SSH detail: which OpenSSH settings enforce each rule, what goes in an authorized_keys file, and how certificates replace long-lived keys. For the wider discovery and governance programme, read the SSH Key Management Guide.
Settings and defaults quoted here come from the OpenBSD manual pages for sshd_config(5), sshd(8) and ssh-keygen(1) as published in November 2026. Defaults vary between OpenSSH releases and Linux distributions, so confirm each value against the version you run.
Key takeaways
- Treat every SSH user key as a credential with an owner, a purpose, an approved location and an end date. Keys with none of these are the main source of SSH risk.
- Prefer short-lived SSH certificates over static public keys for people, and restricted, forced-command keys or certificates for automation.
- Move control of
authorized_keysaway from individual users: use a root-ownedAuthorizedKeysFilelocation orAuthorizedKeysCommandfed from an approved inventory. - Write the restrictions into the key line or certificate (
restrict,from=,command=,expiry-time=) rather than relying on users to behave. - Keep a revocation route that works in minutes: a key revocation list (KRL) distributed through
RevokedKeys. - Bracketed values such as [90 days] are suggested starting points from NHI Mgmt Group, not requirements from any standard. Set them to fit your risk appetite.
How to use this template
Copy sections 1 to 8 into your policy management system and replace every value in square brackets. Delete the guidance notes in italics before you publish. The policy is written for organisations running OpenSSH on Linux and Unix servers, network devices and cloud instances. If you run another SSH implementation, keep the policy statements and change the enforcement settings in the right-hand column of each table.
- Agree the owner. The policy needs one accountable owner, usually the head of infrastructure security or identity, plus named operators for the certificate authority and the key inventory.
- Set your values. Decide lifetimes, approved algorithms and the review interval. Start strict for new keys and allow a migration period for legacy keys rather than weakening the standard.
- Map the enforcement. For each statement, record the setting, configuration management role or scanner that enforces it. A statement with no enforcement is an aspiration, so mark it as such.
- Link the parent policies. Reference your cryptographic key policy, privileged access policy and incident response plan, so readers know which rules win if they conflict.
- Approve and publish. Record approval in section 8 and communicate the change with a clear date after which non-compliant keys will be removed.
Guidance: this is a policy, not a procedure. Keep step-by-step commands in runbooks and link them from section 6. For a playbook covering exposure of a key, see the SSH Key Compromise Response Playbook.
1. Purpose and scope
1.1 Purpose. This policy sets the minimum requirements for creating, approving, deploying, using, rotating, revoking and removing SSH keys and SSH certificates at [Organisation]. Its aim is that every SSH credential that can grant access is known, owned, restricted to its purpose and time-limited.
1.2 In scope.
- SSH user keys used by people for interactive access.
- SSH user keys used by services, scripts, schedulers, CI/CD pipelines, backup and file transfer jobs (automated access).
- SSH host keys on every server, appliance, container image and virtual machine template that runs an SSH daemon.
- SSH certificate authority (CA) keys and the certificates they issue, for both users and hosts.
- Hardware-backed SSH keys (FIDO
ecdsa-skanded25519-sktypes) and keys held in agents or PKCS#11 tokens. - Git hosting deploy keys and SSH keys registered with source code platforms, where they grant access to [Organisation] repositories.
1.3 Out of scope. TLS certificates (see the [Certificate Management Policy]) and API keys or tokens (see the [Secrets Management Policy]). Keys owned by third parties that access [Organisation] systems are in scope for sections 4 to 7.
1.4 Applicability. This policy applies to all employees, contractors, suppliers and automated systems that create or use SSH credentials for [Organisation] systems, in every environment including development and test.
2. Roles and responsibilities
| Role | Responsibilities |
|---|---|
| Policy owner [role] | Maintains this policy, approves exceptions above [risk level], reports compliance to [committee] every [quarter]. |
| SSH CA operators [team] | Run the user and host certificate authorities, protect CA private keys, issue and revoke certificates, publish the KRL. |
| Inventory owner [team] | Runs discovery scans, keeps the SSH key inventory, raises findings for unowned or non-compliant keys. |
| System owners | Ensure servers they own enforce the configuration in section 5 and approve access to their systems. |
| Key owners | Every SSH key and certificate has a named human owner, even when used by a service. The owner confirms continued need at each review and requests removal when the need ends. |
| Users | Protect private keys, never share them, report suspected exposure immediately to [security contact]. |
3. Approved key types and generation
3.1 Approved algorithms. New SSH keys must use one of the approved types below. The ssh-keygen manual lists ecdsa, ecdsa-sk, ed25519, ed25519-sk, mldsa44-ed25519 and rsa as key types, and states that the default is Ed25519.
| Key use | Approved types [edit] | Notes |
|---|---|---|
| Interactive user keys | [ed25519-sk, ecdsa-sk, ed25519] | Hardware-backed types preferred for privileged access. See our Security Keys for SSH guide. |
| Automated access keys | [ed25519, rsa 3072 or larger] | RSA only where a target system cannot accept Ed25519. |
| Host keys | [ed25519, ecdsa, rsa 3072 or larger] | Generated on the host or by the provisioning system, never copied between hosts. |
| CA keys | [ed25519 or rsa 3072 or larger, held in HSM or PKCS#11 token] | ssh-keygen supports signing with a CA key held on a PKCS#11 token (-D) or in ssh-agent (-U). |
| Post-quantum hybrid keys | [mldsa44-ed25519, pilot only] | Approve only after testing interoperability. See the PQC SSH Migration Guide. |
3.2 Minimum sizes. RSA keys must be at least [3072] bits. The ssh-keygen manual gives 1024 bits as the RSA minimum and 3072 bits as the default, so the policy value is stricter than the tool minimum. ECDSA keys must use one of the curve sizes the tool accepts (256, 384 or 521 bits). Ed25519 and the FIDO types have fixed lengths.
3.3 Prohibited. DSA keys, RSA keys below [3072] bits, and CA signatures using the SHA-1 ssh-rsa algorithm, which the ssh-keygen manual marks as not recommended. Servers must not list these in PubkeyAcceptedAlgorithms once the migration date in section 7 has passed.
3.4 Generation. Private keys must be generated on the device or system that will use them, or inside the hardware token. Private keys must never be generated centrally and emailed, posted in chat, or stored in shared folders. Interactive user private keys must be protected with a passphrase or held in a hardware authenticator. Automated keys that cannot carry a passphrase must be stored in [approved secrets manager or file location with mode 0600, owned by the service account].
3.5 Identification. Every public key must carry a comment that identifies the owner and purpose, in the format [owner-email:purpose:ticket]. Inventories record the SHA256 fingerprint, which is the ssh-keygen default fingerprint hash.
4. Lifetimes, rotation and certificates
4.1 Certificates first. Interactive access by people to [production] systems must use SSH user certificates issued by the [Organisation] user CA, not static public keys in authorized_keys. Our SSH Keys vs SSH Certificates page explains the trade-offs.
4.2 Lifetimes.
| Credential | Maximum lifetime [edit] | How it is enforced |
|---|---|---|
| User certificate, interactive | [8 to 16 hours] | Validity set at signing with ssh-keygen -V. |
| User certificate, automation | [24 hours, renewed by the workload] | Validity set at signing, renewal automated by [tool]. |
| Static user key, interactive (legacy) | [90 days], then removed | expiry-time= option on the authorized_keys line. |
| Static key, automation | [365 days] with owner re-approval | expiry-time= option plus inventory review. |
| Host certificate | [1 year] | Validity set at signing, loaded through HostCertificate. |
| Host key | [Life of the host, or on compromise or rebuild] | Regenerated on rebuild. See How to rotate SSH host keys. |
| User CA key | [2 years], with a published rollover plan | CA operators, section 2. |
Guidance: the ssh-keygen manual documents validity intervals written as a single end time, a start and end separated by a colon, or relative offsets such as +52w1d. The authorized_keys option expiry-time stops the server accepting a key after the given date, written as YYYYMMDD or YYYYMMDDHHMM[SS], with an optional Z for UTC.
4.3 Certificate contents. Every user certificate must include:
- A key identity (
-I) that names the requester and the request reference. The ssh-keygen manual notes that this identifier is logged by the server and can be used for revocation. - One or more principals (
-n) that match approved roles or accounts, never a wildcard for user certificates. - A unique serial number, so the certificate can be revoked individually.
- Only the permissions the role needs. Automation certificates start from
clearand add back only what is required, and useforce-command=andsource-address=where the use is fixed.
Guidance: ssh-keygen permits agent forwarding, port forwarding, PTY allocation, user rc files and X11 forwarding by default in user certificates. Removing them is a deliberate choice that this policy makes for automation.
4.4 Rotation triggers. Keys and certificates must be rotated or revoked when: the owner leaves or changes role; the key reaches its maximum lifetime; the key is suspected of exposure; the system or service it serves is decommissioned; or the algorithm becomes prohibited under section 3.
5. authorized_keys control and server configuration
5.1 Location and ownership. On [production and privileged] systems, the list of keys a server will accept must be managed centrally, not by the account holder. System owners must use either:
- an
AuthorizedKeysFilepath outside user home directories, owned by root and written only by [configuration management]; or - an
AuthorizedKeysCommandthat returns approved keys from the [inventory or directory service]. The sshd_config manual requires this program to be owned by root, given by an absolute path and not writable by group or others.
Guidance: the sshd_config manual gives the default AuthorizedKeysFile as .ssh/authorized_keys .ssh/authorized_keys2, both inside the user's home directory. Leaving the default means any user, or any process running as that user, can add a key that grants persistent access. MITRE ATT&CK tracks this as T1098.004 SSH Authorized Keys, a persistence and privilege escalation technique.
5.2 Required key line options. Every static key in an authorized_keys source must carry:
restrict, which the sshd manual describes as enabling all restrictions: port, agent and X11 forwarding, PTY allocation and~/.ssh/rcexecution. Permissions are then added back only where approved.from="pattern-list"naming the approved source hosts or networks for automated keys.command="..."for automated keys with a single purpose, such as a backup or file transfer job.expiry-time="..."matching the lifetime in section 4.2.permitopen="host:port"only where local forwarding is approved for that key.
5.3 Certificate trust. Servers that accept user certificates must use TrustedUserCAKeys pointing to the approved CA public keys, and should use AuthorizedPrincipalsFile or AuthorizedPrincipalsCommand to map certificate principals to local accounts. The sshd_config manual states that certificates without a principals list are not accepted when TrustedUserCAKeys is used. The cert-authority option in an authorized_keys file, with a principals= restriction, is permitted only for [named exceptions].
5.4 Baseline sshd settings.
| Setting | Required value [edit] | Reason |
|---|---|---|
PermitRootLogin | [no] | The documented default is prohibit-password, which still allows root to log in with a key. |
StrictModes | yes | Default yes. The sshd manual says the server will not use an authorized_keys file if it, the ~/.ssh directory or the home directory is writable by other users, unless StrictModes is no. |
PasswordAuthentication | [no] | Key or certificate authentication only. |
PubkeyAcceptedAlgorithms | [approved list from section 3] | Run ssh -Q PubkeyAcceptedAlgorithms to see what a build supports. |
RevokedKeys | [path to KRL] | Keys listed are refused for public key authentication. |
HostCertificate | [path to host certificate] | By default sshd loads no host certificates. |
LogLevel | [VERBOSE] | Default INFO. Choose a level that gives your detection team the authentication detail it needs, and confirm log volume first. |
Guidance: for the full hardening baseline beyond key handling, use the OpenSSH Server Hardening Guide.
5.5 Host key trust on clients. Clients must verify host keys. Where host certificates are deployed, client configuration must trust the [Organisation] host CA through a managed known hosts file distributed by [configuration management]. Users must not disable host key checking in shared configuration or scripts.
6. Inventory, approval and review
6.1 Inventory. The inventory owner must keep a record of every SSH public key and certificate authority that can grant access to [Organisation] systems, including: fingerprint, key type and size, owner, purpose, source host, target accounts and systems, date added, expiry date and the approving ticket.
6.2 Discovery. Discovery scans must run at least [weekly] across all in-scope systems and compare what is deployed with what is approved. Unapproved keys are findings. Our guide on how to find SSH authorized keys across a server fleet covers practical approaches.
6.3 Approval. A new static key, a new automation certificate profile or a new trust relationship between systems requires approval from the target system owner and the key owner's manager, recorded in [ticketing system]. Keys that grant root or equivalent access also need approval from [privileged access owner].
6.4 Periodic review. Key owners must reconfirm every automated key and every legacy static key every [6 months]. Keys that are not reconfirmed within [14 days] of the review request are disabled, then removed after a further [30 days].
6.5 Unused keys. Keys not used for [90 days], as shown by authentication logs, must be reviewed and removed unless the owner justifies them. See our Linux SSH and Authentication Log Detection Guide for the log sources.
6.6 Joiners, movers and leavers. When a person leaves or changes role, their SSH keys, certificates and any automation keys they own must be revoked or reassigned within [1 working day] for privileged access and [5 working days] otherwise.
7. Revocation, compromise and transition
7.1 Revocation list. The CA operators must publish a key revocation list generated with ssh-keygen -k, and every in-scope server must reference it through RevokedKeys. The ssh-keygen manual documents revoking by key, by certificate serial number or by key ID, and merging new entries into an existing list with -u. Distribution of an updated KRL must complete within [1 hour].
7.2 Testing revocation. CA operators must test at least [quarterly] that a revoked key is refused. The ssh-keygen -Q option tests keys against a KRL and exits non-zero if any key is revoked.
7.3 Suspected compromise. Any suspected exposure of a private key, CA key or host key is a security incident and must be reported to [security contact] immediately. CA key compromise triggers the CA rollover plan in section 4.2 and re-issue of all affected certificates.
7.4 Transition of legacy keys. Existing keys that do not meet sections 3 to 5 must be brought into compliance or removed by [date]. System owners may request a time-limited exception under section 8.
8. Exceptions, compliance and approval
8.1 Exceptions. Exceptions must be requested in writing, state the risk, compensating controls and an end date no later than [12 months], and be approved by the policy owner. Exceptions are recorded in the [risk register].
8.2 Compliance. Compliance is measured through the inventory and discovery scans. The policy owner reports at least: number of keys without an owner, keys past expiry, keys without restrictions, servers using home directory authorized_keys files and mean time to revoke.
8.3 Non-compliance. Non-compliant keys may be disabled without notice where they present an immediate risk. Repeated breaches are handled under [disciplinary or supplier management process].
8.4 Review. This policy is reviewed every [12 months] or after a significant incident or change in SSH tooling.
| Version | Date | Author | Approved by | Changes |
|---|---|---|---|---|
| [1.0] | [date] | [name] | [name, role] | [Initial issue] |
Common failure patterns
- Policy without enforcement. A statement that keys expire after 90 days means nothing if no
expiry-timeoption or certificate validity backs it. Map each rule to a setting. - Home directory authorized_keys left in place. Moving to a central source but leaving the default
AuthorizedKeysFilelets users keep adding their own keys alongside the managed ones. - Owner equals service account. A key owned by "backup-svc" has no one to answer the review. Always name a person or a team mailbox with a manager.
- Unrestricted automation keys. Keys used for one job but able to open a shell, forward ports and forward agents turn a narrow integration into general access.
- CA key on a laptop. The certificate authority becomes the single most valuable SSH secret. Keeping it as a plain file defeats the benefit of certificates.
- Revocation never tested. Teams discover during an incident that half the fleet never received the KRL.
- Images with baked-in host keys. Cloning templates that already contain host keys gives many hosts the same identity.
Practitioner checklist
- Named policy owner, CA operators and inventory owner recorded in section 2.
- Approved key types and minimum sizes set, with DSA and SHA-1 RSA signatures prohibited.
- Interactive production access moved to short-lived user certificates.
- Central
AuthorizedKeysFileorAuthorizedKeysCommandin place on privileged systems. - Every static key line carries
restrict,from=andexpiry-time=. TrustedUserCAKeysand principals mapping configured where certificates are used.- KRL published, referenced by
RevokedKeyson every server, and revocation tested. - Discovery scan compares deployed keys with the inventory at least weekly.
- Leaver process removes SSH keys and certificates within the agreed time.
- Exceptions recorded with an end date and compensating controls.
Standards and references
- NIST: IR 7966, Security of Interactive and Automated Access Management Using Secure Shell (SSH), October 2015.
- OpenBSD manual: sshd_config(5), server settings and defaults.
- OpenBSD manual: sshd(8), authorized_keys file format and key options.
- OpenBSD manual: ssh-keygen(1), key types, certificates and key revocation lists.
- NIST: SP 800-57 Part 1 Rev. 5, Recommendation for Key Management.
- MITRE ATT&CK: T1098.004 SSH Authorized Keys.
- NIST SP 800-53 Rev. 5 controls IA-5 Authenticator Management and AC-2 Account Management.
Related NHI Mgmt Group resources: SSH Key Management Guide · Cryptographic Key Management Policy Template · SSH Protocol and Certificate Authority Guide · SSH Key Compromise Response Playbook