Difference between revisions of "OpenVPN Checklist Guide"

From ArchWiki
Jump to: navigation, search
m (fixing detals)
m (It's "easyrsa", not "easy-rsa".)
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
[[Category:Virtual Private Network]]
 
[[Category:Virtual Private Network]]
 
 
This article summarizes the install process required for OpenVPN. See [[OpenVPN]] instead for a walkthrough.
 
This article summarizes the install process required for OpenVPN. See [[OpenVPN]] instead for a walkthrough.
  
 
==Install==
 
==Install==
  
[[pacman|Install]] the package {{Pkg|openvpn}} from the [[Official Repositories|official repositories]].
+
[[Install]] the packages {{Pkg|openvpn}} and {{Pkg|easy-rsa}} from the [[official repositories]].
  
 
==Prepare data==
 
==Prepare data==
  
* Copy {{ic|/usr/share/openvpn/easy-rsa}} to {{ic|/etc/openvpn/easy-rsa}} and cd there
+
* Copy {{ic|/etc/easy-rsa}} to {{ic|/etc/openvpn/easy-rsa}} and cd there
* Edit the {{ic|vars}} file with the information you want, then source it. Read [[Create a Public Key Infrastructure Using the easy-rsa Scripts]] for details.
+
* Edit the {{ic|vars}} file with the information you want. Read [[Create a Public Key Infrastructure Using the easy-rsa Scripts]] for details.
{{bc|# source ./vars}}
+
 
* Clean up any previous keys:
 
* Clean up any previous keys:
{{bc|# ./clean-all}}
+
{{bc|# easyrsa clean-all}}
  
 
==Generate the certificates==
 
==Generate the certificates==
 
* Create the "certificate authority" key  
 
* Create the "certificate authority" key  
{{bc|# ./build-ca}}
+
{{bc|# easyrsa build-ca}}
 
* Create certificate and private key for the server
 
* Create certificate and private key for the server
{{bc|# ./build-key-server ''<server-name>''}}
+
{{bc|# easyrsa build-server-full ''<server-name>''}}
* Create the Diffie-Hellman pem file for the server. Don't enter a challenge password or company name when you set these up.
+
* Create the Diffie-Hellman pem file for the server. Do not enter a challenge password or company name when you set these up.
{{bc|# ./build-dh}}
+
{{bc|# easyrsa gen-dh}}
 
* Create a certificate for each client.  
 
* Create a certificate for each client.  
{{bc|# ./build-key ''<client-name>''}}
+
{{bc|# easyrsa build-client-full ''<client-name>''}}
All certificates are stored in {{ic|keys}} directory. If you mess up, you can start all over by doing a {{ic|./clean-all}}
+
All certificates are stored in {{ic|keys}} directory. If you mess up, you can start all over by doing a {{ic|easyrsa clean-all}}
  
 
Copy to each client the {{ic|ca.crt}}, and their respective crt and key files.
 
Copy to each client the {{ic|ca.crt}}, and their respective crt and key files.
  
==Setting up the Server==
+
==Setting up the server==
 
* Create {{ic|/etc/openvpn/myvpnserver.conf}} with a content like this:
 
* Create {{ic|/etc/openvpn/myvpnserver.conf}} with a content like this:
 
{{hc|/etc/openvpn/myvpnserver.conf|
 
{{hc|/etc/openvpn/myvpnserver.conf|
Line 58: Line 56:
 
Read [[Daemon]] for more information.
 
Read [[Daemon]] for more information.
  
==Setting up the Clients==
+
==Setting up the clients==
 
* Create a .conf file for each client like this:
 
* Create a .conf file for each client like this:
 
{{hc|a-client-conf-file.conf|
 
{{hc|a-client-conf-file.conf|

Latest revision as of 10:54, 16 October 2016

This article summarizes the install process required for OpenVPN. See OpenVPN instead for a walkthrough.

Install

Install the packages openvpn and easy-rsa from the official repositories.

Prepare data

# easyrsa clean-all

Generate the certificates

  • Create the "certificate authority" key
# easyrsa build-ca
  • Create certificate and private key for the server
# easyrsa build-server-full <server-name>
  • Create the Diffie-Hellman pem file for the server. Do not enter a challenge password or company name when you set these up.
# easyrsa gen-dh
  • Create a certificate for each client.
# easyrsa build-client-full <client-name>

All certificates are stored in keys directory. If you mess up, you can start all over by doing a easyrsa clean-all

Copy to each client the ca.crt, and their respective crt and key files.

Setting up the server

  • Create /etc/openvpn/myvpnserver.conf with a content like this:
/etc/openvpn/myvpnserver.conf
port <port>
proto tcp
dev tun0

ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/<server-name>.crt
key /etc/openvpn/easy-rsa/keys/<server-name>.key
dh /etc/openvpn/easy-rsa/keys/<your pem file>

server <desired base ip> 255.255.255.0
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo
user nobody
group nobody
persist-key
persist-tun
status /var/log/openvpn-status.log
verb 3

log-append /var/log/openvpn
status /tmp/vpn.status 10
  • Start and, optionally, enable for autostart on boot, the daemon. (In this example, is openvpn@myvpnserver.service)

Read Daemon for more information.

Setting up the clients

  • Create a .conf file for each client like this:
a-client-conf-file.conf
client
remote <server> <port>
dev tun0
proto tcp
resolv-retry infinite
nobind
persist-key
persist-tun
verb 2
ca ca.crt
cert <client crt file with full path>
key <client key file with full path>
comp-lzo
  • Start the connection with
# openvpn a-client-conf-file.conf &

Optionally, enable for autostart on boot the daemon. (In this example, is openvpn@a-client-conf-file.service)

Read Daemon for more information.