networking:openvpn
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| networking:openvpn [2024/08/12 17:55] – oscar | networking:openvpn [2024/08/14 17:45] (current) – [7. Deploy Certificates & Keys] oscar | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== OpenVPN | + | ====== OpenVPN |
| - | ===== Install Easy-RSA ===== | + | |
| + | ---- | ||
| + | |||
| + | ===== 1. Install Easy-RSA ===== | ||
| The first step in building an OpenVPN configuration is to establish a PKI (public key infrastructure). The PKI consists of: | The first step in building an OpenVPN configuration is to establish a PKI (public key infrastructure). The PKI consists of: | ||
| Line 28: | Line 31: | ||
| | | ||
| Generate the required certificates and keys: | Generate the required certificates and keys: | ||
| - | $ ./easyrsa init-pki | + | $ easyrsa init-pki |
| | | ||
| - | ===== Create own CA certificate ===== | + | ===== 2. Create own CA certificate ===== |
| - | $ ./easyrsa build-ca | + | $ easyrsa build-ca |
| | | ||
| - | ===== Create Server Certificate, Key, and Encryption Files ===== | + | ===== 3. Create Server Certificate |
| - | Throughout this tutorial, the OpenVPN server’s common name will simply | + | Throughout this tutorial, the OpenVPN server’s common name will be “MyServerName”. Be sure to include the nopass option as well. Failing to do so will password-protect the request file, which could lead to permissions issues later on. |
| - | $ ./easyrsa gen-req | + | $ easyrsa gen-req |
| This will create a private key for the server and a certificate request file called server.req. Then sign the request by running easyrsa with the sign-req option, followed by the request type and the common name. The request type can either be client or server, so for the OpenVPN server’s certificate request, be sure to use the server request type. | This will create a private key for the server and a certificate request file called server.req. Then sign the request by running easyrsa with the sign-req option, followed by the request type and the common name. The request type can either be client or server, so for the OpenVPN server’s certificate request, be sure to use the server request type. | ||
| - | $ ./easyrsa sign-req server | + | $ easyrsa sign-req server |
| In the output, you’ll be asked to verify that the request comes from a trusted source. Type yes and press ENTER to confirm this. | In the output, you’ll be asked to verify that the request comes from a trusted source. Type yes and press ENTER to confirm this. | ||
| - | From there, create a strong | + | ===== 4. Generating |
| + | The Diffie–Hellman (DH) Algorithm is a key-exchange protocol that enables two parties communicating over public channel to establish a mutual secret without it being transmitted over the Internet. DH enables the two to use a public | ||
| + | After initializing a PKI, any entity can create DH params that needs them. | ||
| + | DH key params can be generated with: | ||
| $ ./easyrsa gen-dh | $ ./easyrsa gen-dh | ||
| - | This may take a few minutes to complete. | + | This may take a few minutes to complete. |
| + | |||
| + | ===== 5. TLS-AUTH ===== | ||
| + | The tls-auth directive adds an additional HMAC signature to all SSL/TLS handshake packets for integrity verification. Any UDP packet not bearing the correct HMAC signature can be dropped without further processing. The tls-auth HMAC signature provides an additional level of security above and beyond that provided by SSL/TLS. It can protect against:DoS attacks, port flooding, Port scanning, Buffer overflow vulnerabilities, | ||
| + | |||
| + | Using tls-auth requires that you generate | ||
| | | ||
| - | $ openvpn --genkey | + | $ openvpn --genkey secret pki/ta.key |
| - | When the command | + | This command |
| - | sudo cp ~/easy-rsa/ta.key | + | In the server configuration, |
| - | sudo cp ~/ | + | tls-auth ta.key |
| - | With that, all the certificate and key files needed by your server have been generated. You’re ready to create | + | In the client configuration, |
| + | tls-auth ta.key 1 | ||
| + | |||
| + | ===== 6. Create Client Certificate and Key Pair ===== | ||
| + | |||
| + | n this step, you will first generate the client key and certificate pair. If you have more than one client, you can repeat this process for each one. Please note, though, that you will need to pass a unique name value to the script for every client. Throughout this tutorial, the first certificate/ | ||
| + | |||
| + | $ easyrsa gen-req MyClientName nopass | ||
| + | |||
| + | This will create a private key for the client and a certificate request file called MyClientName.req. Then sign the request by running easyrsa with the sign-req option, followed by the request type and the common name. The request type can either be client or server, so for the OpenVPN server’s certificate request, be sure to use the server request type. | ||
| + | |||
| + | $ easyrsa sign-req server MyClientName | ||
| + | |||
| + | In the output, you’ll be asked to verify that the request comes from a trusted source. Type yes and press ENTER to confirm this. | ||
| + | |||
| + | |||
| + | ===== 7. Deploy Certificates & Keys ===== | ||
| + | With that, all the certificate and key files needed by your server have been generated. You’re ready to deploy | ||
| - | ===== Key Files ===== | ||
| Now we will find our newly-generated keys and certificates in the keys subdirectory. Here is an explanation of the relevant files: | Now we will find our newly-generated keys and certificates in the keys subdirectory. Here is an explanation of the relevant files: | ||
| - | ^Filename ^Needed By ^Purpose ^Secret | + | ^Filename ^Needed By ^Purpose ^Secret^ |
| - | |ca.crt |server + all clients |Root CA certificate |NO | + | |ca.crt |server + all clients |Root CA certificate |NO| |
| - | |ca.key |key signing machine only |Root CA key |YES | + | |ca.key |key signing machine only |Root CA key |YES| |
| - | |dh{n}.pem |server only |Diffie Hellman parameters |NO | + | |dh2048.pem |server only |Diffie Hellman parameters |NO| |
| - | |server.crt |server only |Server Certificate |NO | + | |MyServerName.crt |server only |Server Certificate |NO| |
| - | |server.key |server only |Server Key |YES | + | |MyServerName.key |server only |Server Key |YES| |
| - | |client1.crt |client1 only |Client1 Certificate |NO | + | |MyClientName.crt |client1 only |Client1 Certificate |NO| |
| - | |client1.key |client1 only |Client1 Key |YES | + | |MyClientName.key |client1 only |Client1 Key |YES| |
| + | |||
| + | === Server Deployment === | ||
| + | Insert the following options in the openvpn configuration file: | ||
| + | vi / | ||
| + | ---------------------- | ||
| + | option ca '/ | ||
| + | option key '/ | ||
| + | option cert '/ | ||
| + | option dh '/ | ||
| + | |||
| + | |||
| + | === Client Deployment === | ||
| + | Insert the various certificates and keys in the following sections of the client.ovpn configuration file: | ||
| + | |||
| + | - **ca.cert** --> insert contents --> between the < | ||
| + | - **MyClientName.key** --> insert contents --> between the < | ||
| + | - **MyClientName.crt** --> insert contents --> between the < | ||
| + | - **ta.key** --> insert contents --> between the < | ||
| ===== Links ===== | ===== Links ===== | ||
networking/openvpn.1723485303.txt.gz · Last modified: by oscar
