All Pages > howto > IPsec > strongSwan 4.0 and earlier
IPsec with public key authentication on strongSwan < 5.0.0
Setup
Generate an RSA keypair
Exchange public keys with your peer
- Display the public key. Send the key data to your peer.
ZAASv7cT9DG+xfQmjrJC9SUCAwEAAQ==
- Convert your peer's public key to the Base64 RFC 3110 format using the pubkey-converter script, if necessary.
Configuration
Configure the phase 1 IKE parameters
In this example, we'll use the following settings:
Key | Value |
---|---|
Encryption | AES-128 |
Hash | HMAC-SHA1 |
DH Group | 5 (modp1536) |
Lifetime | 28800 seconds |
Peer address | 192.0.2.2 |
Local address | 192.0.2.1 |
Note: strongSwan < 5.0.0 will read PEM-formatted private keys, but requires public keys to be added to the configuration in Base64 RFC 3110 format. Convert your host's public key from PEM to Base64 RFC 3110 for inclusion in ipsec.conf as described below.
- Configure a connection policy in ipsec.conf for your peer. The
leftrsasigkey
attribute is your host's public key in Base64 RFC 3110 format enclosed in double quotes, andrightrsasigkey
is your peer's key.
- All done! Configure the phase 2 parameters as you otherwise would.
Full GRE/IPsec example
# ipsec.conf - strongSwan IPsec configuration file
keyexchange=ikev1
dpdaction=restart
# peer IPs
left=192.0.2.1
right=192.0.2.2
# phase 1 parameters
ike=aes128-sha1-modp1536!
ikelifetime=28800s
# authentication
authby=pubkey
leftrsasigkey="0sAwEAAdvxViCblVLX7C6L2rzafpz0rE9pkKDSt2VFMLhCnwY0+5oYo3V0R4dUgLSGlNmnp+fneauntu7zAgmDkC2oJ/QpCmrQaueMxjbw0s0BKc9JiLGgcfcY74bIKgJigk6S7SrjM+nGWx/MvKPf2WfCr/iYbeu0/AQyl3M4DoOSCGl/OFKQq5UoJp0rymCrtz157fdW2euh2g2SYz3/WojDXH77lKlXxVp7FdsyOhxbxv7sJKi2pbJz2gMFXiFpdjr8tic3Y9BkS0mMfO3p3kgaPu7Y5VEUE7nQI9fud0hTpAXAj0p8z2KSAt4QX2fGcPK/9uZqFt8X/E5SyyaoAIedGLVcr8lUr9TCmAXY2XBbBF1HHguSyPSWa8gf0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port
leftprotoport=gre
rightprotoport=gre
# startup
auto=route
keyingtries=