The word "key" covers at least six different things in security, and treating one kind like another is how secrets end up in source code, tickets and chat threads. A cryptographic key, an API key, a cloud access key, an SSH key, a hardware security key and a licence key differ in what they prove, whether they are secret, how long they should live and where they belong. This guide separates them in plain terms, shows which ones are non-human identity (NHI) credentials, and points to the deeper guide for each. It is written for developers, new security staff and anyone in IT who handles keys without being a cryptography specialist.
Key takeaways
- "Key" is a family name, not a type. Before you store, share or rotate anything called a key, ask what it proves and whether anyone who sees it can use it.
- Most keys are bearer secrets. API keys, cloud secret access keys, symmetric encryption keys and SSH private keys give their power to whoever holds them, so they belong in a secrets manager or key management system, never in code or chat.
- Public halves are not secret. An SSH public key, a certificate's public key or a passkey's public key can be shared freely; leaking it is not an incident, but swapping it for an attacker's is.
- Several keys are NHI credentials. API keys, cloud access keys, SSH keys used by automation and service encryption keys authenticate software, not people, and need owners, inventories and rotation like any other NHI.
- Short lifetimes beat careful handling. Where a platform offers temporary credentials, certificates or device-bound passkeys, prefer them over long-lived static keys.
Why "key" is ambiguous
In cryptography a key has a precise meaning. NIST's glossary collects more than twenty definitions of "cryptographic key" across its publications, and they agree on the core idea: a parameter that controls how a cryptographic algorithm works, so that someone who knows the key can perform or reverse an operation (encrypt, decrypt, sign, compute a MAC) and someone who does not know it cannot. Software and product teams then borrowed the word for anything that unlocks access: a string that lets an app call an API, a credential pair that signs cloud requests, a code that activates software, and a physical token on a keyring.
The result is everyday confusion. Common examples:
- "It's only the public key": said about an AWS access key ID (which is an identifier, not the secret) and sometimes, wrongly, about the secret access key that comes with it.
- "Rotate the keys": to a cloud team this means issuing new access keys; to a PKI team it may mean a new certificate key pair; to a database team it may mean re-encrypting data under a new data encryption key. These are very different jobs.
- "Use a security key": means a FIDO hardware authenticator, not an API key and not an encryption key, even though it contains private keys internally.
- "The key is in the README": harmless if it is a published volume licence setup key, an incident if it is an API key.
The NHI Mgmt Group NHI and IAM Glossary defines the wider vocabulary; this page focuses only on keys.
Cryptographic keys
NIST SP 800-57 Part 1 Rev. 5, the main US recommendation on key management, defines a cryptographic key as a parameter used with an algorithm to perform operations such as encryption, decryption, digital signature generation and verification, MAC computation and key derivation. It groups keys by type and sets the protection each type needs.
- Symmetric keys: one secret key encrypts and decrypts (for example an AES data encryption key) or creates and checks a MAC. Anyone holding it can read or forge the protected data, so it is always secret.
- Asymmetric key pairs: a private key that must stay secret and a public key that can be published. Private keys sign or decrypt; public keys verify or encrypt. TLS certificates, code signing and SSH all use pairs.
- Key-encrypting and master keys: keys that protect other keys. Envelope encryption in cloud key management services wraps data keys under a master key that never leaves the service or a hardware security module (HSM).
How to manage them: generate keys inside a key management system or HSM, set a cryptoperiod (the time a key is authorised for use) for each key type, restrict which identities may use each key for which operation, log every use, and plan destruction. Keep encryption keys away from the data they protect; the OWASP Secrets Management Cheat Sheet warns against storing keys beside the secrets they encrypt unless the keys are themselves encrypted. See the Cryptographic Key Management Guide and the HSM and Key Management Buyer's Guide.
API keys
An API key is a string an application sends with a request so the API provider can recognise the calling project or account, apply quotas and bill usage. It is not a cryptographic key in the NIST sense: it is usually a random token compared on the server, and anyone who copies it can replay it.
What an API key proves varies by provider, which is a second source of confusion. Google Cloud's documentation is explicit: a standard API key associates a request with a project for billing and quota but does not authenticate a principal, so IAM cannot check whether the caller is authorised. Google also offers authorization keys that are bound to a service account and act like a long-lived access token, and it recommends against using them in production for APIs that create or manage resources. Many SaaS and AI model providers issue API keys that carry the full rights of an account or organisation.
- Treat every API key as a secret: even "identification only" keys run up bills and expose data if misused.
- Restrict it: limit each key to the APIs it needs and to the calling application, IP range or referrer where the provider supports it. Google states that unrestricted API keys are insecure and recommends setting both API and application restrictions.
- Prefer stronger options for sensitive operations: OAuth access tokens or workload identity federation give scoped, expiring credentials. See API Keys vs OAuth Tokens Guide.
See the API Key Management Guide and, if one has leaked, the API Key Leak Response Playbook.
Cloud access keys
A cloud access key is a credential pair that signs programmatic requests to a cloud provider's API. In AWS, an access key consists of an access key ID (for example one beginning with AKIA) and a secret access key; both are needed to sign requests. AWS describes access keys as long-term credentials for an IAM user or the root user, shows the secret only once at creation, and allows at most two access keys per IAM user so one can be rotated while the other is active. Temporary credentials issued by AWS STS use the ASIA prefix and also require a session token.
- The ID is not the secret, but it is not harmless: the access key ID identifies the key in logs and in CloudTrail. The secret access key is what must never leak.
- Prefer roles and temporary credentials: AWS's own guidance is to use IAM roles and temporary security credentials instead of long-term access keys, and never to create access keys for the root user.
- Know where they sit: AWS notes that keys in the shared credentials file are stored in plaintext, so developer laptops and build agents are common places to find them.
Azure and Google Cloud have equivalents (client secrets for app registrations, service account keys) with the same risk profile. See the AWS Access Keys Security Guide and the Cloud Access Key Leak Playbook.
SSH keys
SSH keys are asymmetric key pairs used to authenticate users and hosts to servers. NIST IR 7966 on SSH access management notes that SSH often provides high-privilege automated access for tasks such as file transfer and patching, and that SSH user key access has been largely overlooked in access management.
- User (identity) keys: the private key stays with the user or the automation account; its public key is listed in the server account's
authorized_keysfile. Whoever holds the private key logs in as that account. - Host keys: each server's key pair, used by clients to check they are talking to the right server. The OpenSSH
ssh-keygenmanual states host keys must have an empty passphrase, so their protection relies on file permissions. - SSH certificates: a CA signs a public key with a validity interval and named principals (
ssh-keygen -swith-Vand-n), which replaces scatteredauthorized_keysentries with short-lived, centrally issued credentials. - Hardware-backed keys: the
ecdsa-skanded25519-sktypes keep the private key on a FIDO authenticator, with options such astouch-requiredandverify-required.
Current OpenSSH creates an Ed25519 key by default. An SSH private key used by a script, CI job or backup system is an NHI credential and needs an owner and rotation. See the SSH Key Management Guide, SSH Keys vs SSH Certificates and How to Find ssh authorized keys across a server fleet.
Hardware security keys and passkeys
A hardware security key is a physical FIDO authenticator (USB, NFC or Bluetooth) that a person uses to sign in. A passkey is the credential itself. The FIDO Alliance describes a passkey as a FIDO cryptographic credential tied to a user's account on a site or app: a key pair where the private key stays with the user's device or passkey provider and the service stores only the public key. Sign-in is a challenge-response, so there is no shared secret for a phishing site to capture or for a server breach to expose.
- Synced passkeys: stored in a passkey provider and synchronised, end-to-end encrypted, across a user's devices.
- Device-bound passkeys: never leave the device that created them, including passkeys held on hardware security keys. FIDO describes these as offering the strongest assurance.
These are human authentication credentials, not NHI credentials, and the person never sees or handles the private key. The confusion to avoid is calling a security key an "API key" or storing a recovery code for one alongside service secrets. Security keys can also protect SSH (see Security Keys for SSH). For choosing between options see Passkeys vs Hardware Security Keys and the Hardware Security Keys Guide.
Licence and product keys
A licence or product key is a code that unlocks or activates software under a licence. It proves entitlement, not identity, and it does not authenticate anyone to a system. Some are deliberately public: Microsoft publishes its KMS client setup keys (Generic Volume License Keys) in its documentation because they only tell a volume-licensed machine to activate against an organisation's own KMS host; they will not activate retail editions. Others, such as a KMS host key or a paid retail key, are commercially valuable and should be stored with restricted access, but a leak is a licensing problem rather than a breach of systems.
Keep licence keys in an asset or licence management system, not in a secrets vault alongside production credentials, and do not let their low sensitivity set the habit for how other "keys" are treated.
Comparison table
| Type | What it proves | Secret? | NHI credential? | Typical lifetime | Where it should be stored |
|---|---|---|---|---|---|
| Symmetric encryption key | Holder may encrypt, decrypt or MAC data | Yes | Yes, when used by services | Defined cryptoperiod per key type | KMS or HSM; never with the data it protects |
| Private key (TLS, signing) | Holder controls the identity in the certificate or signature | Yes | Yes, for servers and workloads | Tied to certificate validity | HSM, KMS or protected key store |
| Public key | Lets others verify or encrypt to the holder | No | Part of one | Same as its private key | Anywhere; protect its integrity |
| API key | Calling project or account (sometimes full account rights) | Yes | Yes | Often indefinite unless rotated or expired | Secrets manager; injected at runtime |
| Cloud access key (ID + secret) | Holder may sign API requests as an IAM identity | Secret part: yes. ID: no, but sensitive | Yes | Long-term until rotated; STS credentials expire | Avoid creating; if required, secrets manager |
| SSH user private key | Holder may log in as the matching account | Yes | Yes, when used by automation | Indefinite unless managed; certificates set validity | Agent, hardware authenticator or secrets manager |
| SSH host key | Server identity to clients | Private part: yes | Yes (machine identity) | Life of the server, rotated on rebuild or compromise | Server file system with strict permissions |
| Passkey or security key | A person controls the account | Private key never exposed | No (human) | Until revoked or device lost | Device, passkey provider or hardware key |
| Licence or product key | Entitlement to use software | Varies; some are published | No | Licence term | Licence or asset management system |
Threats and controls by key type
| Concern | Reference | Applies to |
|---|---|---|
| Credentials left in files and repositories | MITRE ATT&CK T1552.001 Credentials In Files | API keys, cloud access keys, encryption keys in config |
| Theft of private keys | MITRE ATT&CK T1552.004 Private Keys | SSH, TLS and signing private keys |
| Theft of application tokens | MITRE ATT&CK T1528 Steal Application Access Token | API keys and tokens acting for applications |
| Key establishment and management | NIST SP 800-53 Rev. 5 SC-12 | All cryptographic keys |
| Authenticator management | NIST SP 800-53 Rev. 5 IA-5 | API keys, access keys, SSH keys, passkeys |
| Identities and credentials managed | NIST CSF 2.0 PR.AA-01 | Every credential, human and non-human |
How to tell which key you are holding
- Ask what happens if a stranger copies it. If they can call an API, sign requests, log in or decrypt data, it is a secret and goes in a vault.
- Look at the format. PEM blocks labelled PRIVATE KEY, OpenSSH private key files, strings with known provider prefixes (such as AWS
AKIAorASIA) and long random tokens are secrets or credential identifiers. A five-block product key format is usually a licence key. - Ask who uses it. If software uses it without a person present, it is an NHI credential and needs an owner, an inventory entry and a rotation plan. See Human vs Non-Human Identity.
- Check for a shorter-lived option. Roles, workload identity federation, SSH certificates and OAuth tokens remove most long-lived keys.
- When unsure, treat it as secret and ask the platform owner before sharing it.
Practitioner checklist
- Teach the difference between public keys, private keys, API keys and licence keys in developer onboarding, using the comparison table above.
- Keep an inventory of every API key, cloud access key, service encryption key and automation SSH key, each with a named owner.
- Store secret keys only in a secrets manager, KMS or HSM; ban keys in source code, tickets, wikis and chat.
- Run secret scanning on repositories and CI logs, covering provider prefixes and private key headers (see the Generic API Key Detection Guide).
- Replace long-term cloud access keys with roles or federated temporary credentials, and remove any root user access keys.
- Restrict every API key by API and by calling application or network where the provider supports it.
- Set cryptoperiods for encryption and signing keys and automate rotation.
- Move automation SSH access towards short-lived SSH certificates or hardware-backed keys.
- Keep licence keys in licence management, separate from production secrets.
Standards and references
- NIST: SP 800-57 Part 1 Rev. 5, Recommendation for Key Management
- NIST CSRC Glossary: cryptographic key
- NIST: IR 7966, Security of Interactive and Automated Access Management Using SSH
- AWS: Manage access keys for IAM users
- Google Cloud: Manage API keys
- FIDO Alliance: Passkeys
- OpenBSD: ssh-keygen manual page
- OWASP: Secrets Management Cheat Sheet
Related NHI Mgmt Group resources: Secrets Management Guide · Cryptographic Key Management Guide · API Key Management Guide · SSH Key Management Guide · NHI and IAM Glossary