Session key
A session key is a temporary cryptographic key for accessing and protecting a session. Learn how session keys are created and used, how they differ from long-term keys, and why forward secrecy matters.
What is a session key?
A session key is a symmetric encryption key used for one communication session and then discarded. Protocols such as TLS (used by HTTPS), SSH, and many VPNs create a fresh session key for each connection and use it to encrypt and authenticate the data exchanged. Because it is short-lived, a session key limits how much data is exposed if any single key is compromised.
How does a session key work?
- At the start of a session, the two parties run a key exchange, often based on Diffie-Hellman, using long-term keys or certificates to authenticate each other.
- Both sides derive the same session key without ever sending it across the network.
- The session key encrypts and protects the integrity of the traffic with a fast symmetric cipher, such as AES.
- When the session ends, or after a set time or amount of data, the key is discarded or replaced.
When each session uses a new, ephemeral key exchange, the protocol offers forward secrecy: stealing a server's long-term private key later does not let an attacker decrypt past recorded sessions.
Session key vs. long-term key
A long-term key, such as a server's private key or a user's SSH key, identifies its owner and is used for months or years. A session key is generated for one session and used only for encryption during it. Long-term keys establish trust; session keys protect the data.
Why does a session key matter?
Session keys make encrypted communication both fast and resilient. Using a new key for each session reduces the value of any single key to an attacker. The long-term keys used to set up sessions still need strong protection, since compromising them can allow impersonation.
Frequently asked questions
What is a session key?
A session key is a temporary cryptographic key for accessing and protecting a session, used for a single session and then discarded.
Why are session keys symmetric?
Symmetric encryption is much faster than public key encryption, so protocols use public key methods to agree on a symmetric session key for the bulk of the data.
What is forward secrecy?
Forward secrecy means that past sessions stay protected even if a long-term private key is later stolen, because each session used its own ephemeral key.
Protect the long-term secrets behind your sessions
Store, share, and govern credentials in one secure, encrypted place.
Related terms
Session
A session is a temporary connection between two computers or systems wherein they exchange information.
Read now →Public key encryption
Public key encryption uses a pair of cryptographic keys, a public key and a private key: either the key used to encrypt the data is public and the key used to decrypt it is private, or the reverse.
Read now →HTTPS
HTTPS is HTTP encrypted with the SSL/TLS protocol to ensure the secure transfer of data over a network.
Read now →