download easy rsa somewhere and use full path: ~/bin/EasyRSA-3.1.2/easyrsa
https://github.com/OpenVPN/easy-rsa/blob/master/README.quickstart.md
apt install openvpn
port 1194
proto udp
dev tun
# private key
askpass /etc/openvpn/server/pass.txt
# tls auth (optional)
key-direction 0
server 10.50.8.0 255.255.255.0 # internal tun0 connection IP
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo # Compression - must be turned on at both end
persist-key
persist-tun
#push "dhcp-option DNS 192.168.0.200"
#push "dhcp-option DOMAIN std.local"
#push "route 192.168.0.0 255.255.255.0"
status /var/log/openvpn-status.log
verb 3 # verbose mode
<dh>
-----BEGIN DH PARAMETERS-----
...
-----END DH PARAMETERS-----
</dh>
<cert>
Certificate:
Data:
...
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN ENCRYPTED PRIVATE KEY-----
...
-----END ENCRYPTED PRIVATE KEY-----
</key>
<ca>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</ca>
<tls-auth>
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
</tls-auth>
~/bin/EasyRSA-3.1.2/easyrsa gen-dh
cat pki/dh.pem
inline in server.conf
~/bin/EasyRSA-3.1.2/easyrsa build-server-full server-name-hereServer
cat pki/inline/server-name-hereServer.inline
inline in server.conf
write key password in askpass /etc/openvpn/server/pass.txt
file
sudo touch /etc/openvpn/server/pass.txt
sudo chmod 600 /etc/openvpn/server/pass.txt
sudo nano /etc/openvpn/server/pass.txt
sudo systemctl start openvpn-server@server-name-here.service
for server.conf
inside /etc/openvpn/server/
dir:
sudo systemctl start openvpn-server@server.service
sudo systemctl enable openvpn-server@server.service
sudo systemctl status openvpn-server@server.service
cd /etc/openvpn/client
touch pass.txt
chmod 600 pass.txt
#touch server-name-here.conf
touch server.conf
chmod o-r server.conf
client
remote 'server2.example.com' 1194 udp
remote '192.168.0.1' 1194 udp
remote '192.168.1.1' 1194 udp
# auth-user-pass
cipher AES-128-CBC
data-ciphers AES-256-GCM:AES-128-GCM:AES-128-CBC
dev tun
dev-type tun
proto udp
port 1194
ping 30
ping-restart 90
comp-lzo
nobind
auth-nocache
script-security 2
persist-key
persist-tun
user nobody
group nogroup
# private key / pem password
askpass /etc/openvpn/client/pass.txt
# tls-auth
key-direction 1
# check cert type
remote-cert-tls server
# check server-name
verify-x509-name server-name-hereServer name
<cert>
Certificate:
Data:
Version: 3 (0x2)
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN ENCRYPTED PRIVATE KEY-----
...
-----END ENCRYPTED PRIVATE KEY-----
</key>
<ca>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</ca>
<tls-auth>
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
</tls-auth>
~/bin/EasyRSA-3.1.2/easyrsa build-serverClient-full client-name-hereServerClient
enter password (optional, use )
Certificate created at:
* ....pki/issued/client-name-hereServerClient.crt
...
* ....pki/inline/client-name-hereServerClient.inline
cat pki/inline/client-name-hereServerClient.inline
inline in server.conf
write key password in askpass /etc/openvpn/client/pass.txt
file
sudo touch /etc/openvpn/server/pass.txt
sudo chmod 600 /etc/openvpn/server/pass.txt
sudo nano /etc/openvpn/server/pass.txt
use the same as in server config and keep it secret
sudo systemctl start openvpn-client@server-name-here.service
for server.conf
inside /etc/openvpn/server/
dir:
sudo systemctl start openvpn-server@server.service
sudo systemctl enable openvpn-server@server.service
sudo systemctl status openvpn-server@server.service
https://www.digitalocean.com/community/tutorials/openvpn-ubuntu-16-04-ru