Pre-Shared Key (PSK) authentication uses a secret known to both peers before the IKE negotiation begins. While simpler to deploy than certificates, PSK is best suited for small, fixed deployments where managing a PKI is impractical.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/strongswan/strongswan/llms.txt
Use this file to discover all available pages before exploring further.
When to Use PSK
Good fit
- Lab environments and quick testing
- Fixed site-to-site tunnels between trusted devices
- Embedded devices where certificate management is impractical
- Interoperability with older peers that lack certificate support
Not recommended
- Road-warrior / remote access scenarios with many clients
- Any deployment using IKEv1 Aggressive Mode
- Environments requiring per-user authentication accountability
- High-security deployments where compromise of one secret affects all peers
Basic Configuration
- Site-to-Site
- Road Warrior (Server)
The secrets Section
PSK secrets are defined under thesecrets section using an ike prefix:
Secret Selection by Identity
strongSwan matches secrets to connections using theid entries:
- If an
idin the secret matches the local or remote IKE identity, that secret is used. - If no specific match exists, a secret with no
identries (or%any) is used as a fallback. - If multiple secrets match, strongSwan tries them in order.
When
remote { id = %any } is set on the connection, any peer identity is accepted. The secret is still selected by identity matching — if no id-specific secret matches the peer’s presented identity, the fallback secret is used.IKEv1 and Aggressive Mode
Main Mode (the IKEv1 default) provides identity protection by encrypting the identity payloads, but the PSK still must be looked up before the identity is authenticated. This requires the remote identity to be known in advance (e.g., by IP address) to select the correct secret.Choosing Strong Secrets
Generate a cryptographically random PSK rather than using a passphrase:swanctl.conf with the appropriate prefix: