Skip to content

Commit a1eb26c

Browse files
authored
[update] Install and Configure a StrongSwan Gateway VPN Server (#7187)
* [update] Install and Configure a StrongSwan Gateway VPN Server on Ubuntu 20.04 * Update index.md fixed indentation * Update index.md - added description
1 parent ad997d2 commit a1eb26c

File tree

1 file changed

+23
-6
lines changed
  • docs/guides/networking/vpn/strongswan-vpn-server-install

1 file changed

+23
-6
lines changed

docs/guides/networking/vpn/strongswan-vpn-server-install/index.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,21 @@ The steps in this guide are written for non-root users. Commands that require el
4444

4545
1. Use the IPsec command-line utility to create your IPsec private key. In the case of this tutorial, the private key is used to create the root certificate for StrongSwan. You can also use this key to generate other certificates.
4646

47-
sudo ipsec pki --gen --size 4096 --type rsa --outform pem > /etc/ipsec.d/private/ca.key.pem
47+
sudo ipsec pki --gen --size 4096 --type rsa --outform pem > ca.key.pem
48+
sudo mv ca.key.pem /etc/ipsec.d/private/ca.key.pem
49+
sudo chmod 600 /etc/ipsec.d/private/ca.key.pem
4850

4951
1. Create and sign the root certificate with the configurations included below. Ensure you replace the value of the `CN` configuration with your own desired name for your StrongSwan VPN server.
5052

51-
ipsec pki --self --in /etc/ipsec.d/private/ca.key.pem --type rsa --dn "CN=<Name of this VPN Server>" --ca --lifetime 3650 --outform pem > /etc/ipsec.d/cacerts/ca.cert.pem
53+
sudo ipsec pki --self --in /etc/ipsec.d/private/ca.key.pem --type rsa \
54+
--dn "CN=<Name of this VPN Server>" --ca --lifetime 3650 --outform pem | \
55+
sudo tee /etc/ipsec.d/cacerts/ca.cert.pem > /dev/null
5256

5357
In the example above, the `--lifetime 3650` configuration sets the certificate's lifetime to 3650 days or approximately ten years. The lifetime of the certificate determines when it is to be regenerated and distributed to your StrongSwan server and connected clients. You can adjust this setting to your preferred value.
5458

55-
1. Generate the StrongSwan VPN server's private certificate.
59+
1. Generate the StrongSwan VPN servers private key and save it to `/etc/ipsec.d/private/server.key.pem`. This command ensures root permissions for file creation, and suppresses terminal output.
5660

57-
ipsec pki --gen --size 4096 --type rsa --outform pem > /etc/ipsec.d/private/server.key.pem
61+
sudo ipsec pki --gen --size 4096 --type rsa --outform pem | sudo tee /etc/ipsec.d/private/server.key.pem > /dev/null
5862

5963
1. Generate the host server certificate. There are two ways to generate the certificate, however, they cannot be mixed. The two ways are as follows:
6064

@@ -64,13 +68,26 @@ The steps in this guide are written for non-root users. Commands that require el
6468
**Local Resolver Method**
6569
The example below uses a local resolver. The IPsec utility takes the server key from step 2 and uses it as an input private certificate source, and generates a resolver-based certificate. Ensure you replace the value of `CN` and `san` with your own. The `--dn “CN=<serverhost.ourdomain.tld>` is a DNS or `/etc/hosts` call that should be changed to reflect your organization's own hostname.
6670

67-
ipsec pki --pub --in /etc/ipsec.d/private/server.key.pem --type rsa | ipsec pki --issue --lifetime 3650 --cacert /etc/ipsec.d/cacerts/ca.cert.pem --cakey /etc/ipsec.d/private/ca.key.pem --dn "CN=<serverhost.ourdomain.tld>" --san="<server.ourdomain.tld>" --flag serverAuth --flag ikeIntermediate --outform pem > /etc/ipsec.d/certs/server.cert.pem
71+
sudo ipsec pki --pub --in /etc/ipsec.d/private/server.key.pem --type rsa | \
72+
sudo ipsec pki --issue --lifetime 3650 \
73+
--cacert /etc/ipsec.d/cacerts/ca.cert.pem --cakey /etc/ipsec.d/private/ca.key.pem \
74+
--dn "CN=<serverhost.ourdomain.tld>" --san="<server.ourdomain.tld>" \
75+
--flag serverAuth --flag ikeIntermediate --outform pem | \
76+
sudo tee /etc/ipsec.d/certs/server.cert.pem > /dev/null
77+
6878

6979
**Gateway Server IPv4 Address**
7080

7181
The duplicate `–san=”<server static IP address>` configuration in the command below is correct; do not omit both configurations. Replace their values with your own gateway server's IPv4 address.
7282

73-
ipsec pki --pub --in /etc/ipsec.d/private/server.key.pem --type rsa | ipsec pki --issue --lifetime 3650 --cacert /etc/ipsec.d/cacerts/ca.cert.pem --cakey /etc/ipsec.d/private/ca.key.pem --dn "CN=<server static IP address>" –san=”<server static IP address>” --san="<server static IP address>" --flag serverAuth --flag ikeIntermediate --outform pem > /etc/ipsec.d/certs/server.cert.pem
83+
sudo ipsec pki --pub --in /etc/ipsec.d/private/server.key.pem --type rsa | \
84+
sudo ipsec pki --issue --lifetime 3650 \
85+
--cacert /etc/ipsec.d/cacerts/ca.cert.pem --cakey /etc/ipsec.d/private/ca.key.pem \
86+
--dn "CN=<server static IP address>" \
87+
--san="<server static IP address>" --san="<server static IP address>" \
88+
--flag serverAuth --flag ikeIntermediate --outform pem | \
89+
sudo tee /etc/ipsec.d/certs/server.cert.pem > /dev/null
90+
7491

7592
At the end of this section, you should have generated the following files on your Ubuntu 20.04 server:
7693

0 commit comments

Comments
 (0)