In this chapter, we will setup an OpenVPN server so that we can securely connect to our remote servers. A Virtual Private Network (VPN) is a type of network which establishes a secure and encrypted connection over the internet by creating a encrypted tunnel between our device and the internet. So, it basically imitates a private network over the public one. Using VPN, we can hide our IP address and the location, prevent exposure of our sensitive data and protect our privacy. OpenVPN is an open-source Virtual Private Network which creates a secure connections over the internet using custom security protocol utilizing SSL/TLS.
Below image shows the server instance that we configured for our vpn server.
Connect to the VPN server instance using the first method of SSH connection, that we discussed in our previous chapter. We will be using terminal/command prompt from our local machine.
ssh -i "travel-app-vpn.cer" email@example.com
For you, if you are using Amazon Linux 2 image for setting up the VPN server instance, user (ec2-user) will be same but static ip will be different. Modify accordingly to connect to the instance.
As discussed in our previous chapter, the first thing that we should be doing is, update all the presently installed packages to their latest available versions and remove all the obsolete packages.
sudo yum -y update sudo yum -y upgrade
OpenVPN server is not available in yum package manager by default. So, to access it, we need to install Extra Packages for Enterprise Linux(EPEL) repository and then enable it. It is not included in Amazon Linux 2 by default. Enabling EPEL repository provides access to some of the packages that are not available in yum package manager. OpenVPN server is one of such package provided by it. Install it by issuing following command:
sudo amazon-linux-extras install epel -y
Now that EPEL is installed, we need to also enable it.
sudo yum-config-manager --enable epel
To verify that EPEL repository is installed and enabled, run the following command:
sudo yum repolist
It will show the following output:
Install OpenVPN server:
sudo yum install openvpn -y
Now that the OpenVPN server is successfully installed, check the version of it.
For successful installation, it should look like image below:
Now that our OpenVPN server is installed, before we can run it, we need to create a server configuration file.
sudo vi /etc/openvpn/server/server.conf
We are referencing a following link to create our server.conf file. Also, please give the creators a star.
Our final server.conf file looks like below:
################################################# # Sample OpenVPN 2.0 config file for # # multi-client server. # # # # This file is for the server side # # of a many-clients <-> one-server # # OpenVPN configuration. # # # # OpenVPN also supports # # single-machine <-> single-machine # # configurations (See the Examples page # # on the web site for more info). # # # # This config should work on Windows # # or Linux/BSD systems. Remember on # # Windows to quote pathnames and use # # double backslashes, e.g.: # # "C:\\Program Files\\OpenVPN\\config\\foo.key" # # # # Comments are preceded with '#' or ';' # ################################################# # Which local IP address should OpenVPN # listen on? (optional) ;local a.b.c.d # Which TCP/UDP port should OpenVPN listen on? # If you want to run multiple OpenVPN instances # on the same machine, use a different port # number for each one. You will need to # open up this port on your firewall. port 1194 # TCP or UDP server? proto udp4 # "dev tun" will create a routed IP tunnel, # "dev tap" will create an ethernet tunnel. # Use "dev tap0" if you are ethernet bridging # and have precreated a tap0 virtual interface # and bridged it with your ethernet interface. # If you want to control access policies # over the VPN, you must create firewall # rules for the the TUN/TAP interface. # On non-Windows systems, you can give # an explicit unit number, such as tun0. # On Windows, use "dev-node" for this. # On most systems, the VPN will not function # unless you partially or fully disable # the firewall for the TUN/TAP interface. ;dev tap dev tun # Windows needs the TAP-Win32 adapter name # from the Network Connections panel if you # have more than one. On XP SP2 or higher, # you may need to selectively disable the # Windows firewall for the TAP adapter. # Non-Windows systems usually don't need this. ;dev-node MyTap # SSL/TLS root certificate (ca), certificate # (cert), and private key (key). Each client # and the server must have their own cert and # key file. The server and all clients will # use the same ca file. # # See the "easy-rsa" directory for a series # of scripts for generating RSA certificates # and private keys. Remember to use # a unique Common Name for the server # and each of the client certificates. # # Any X509 key management system can be used. # OpenVPN can also use a PKCS #12 formatted key file # (see "pkcs12" directive in man page). ca /etc/openvpn/ca.crt cert /etc/openvpn/server.crt key /etc/openvpn/server.key # This file should be kept secret crl-verify /etc/openvpn/crl.pem # Diffie hellman parameters. # Generate your own with: # openssl dhparam -out dh2048.pem 2048 dh /etc/openvpn/dh.pem # Network topology # Should be subnet (addressing via IP) # unless Windows clients v2.0.9 and lower have to # be supported (then net30, i.e. a /30 per client) # Defaults to net30 (not recommended) topology subnet # Configure server mode and supply a VPN subnet # for OpenVPN to draw client addresses from. # The server will take 10.8.0.1 for itself, # the rest will be made available to clients. # Each client will be able to reach the server # on 10.8.0.1. Comment this line out if you are # ethernet bridging. See the man page for more info. server 10.8.0.0 255.255.255.0 # Maintain a record of client <-> virtual IP address # associations in this file. If OpenVPN goes down or # is restarted, reconnecting clients can be assigned # the same virtual IP address from the pool that was # previously assigned. ifconfig-pool-persist ipp.txt # Configure server mode for ethernet bridging. # You must first use your OS's bridging capability # to bridge the TAP interface with the ethernet # NIC interface. Then you must manually set the # IP/netmask on the bridge interface, here we # assume 10.8.0.4/255.255.255.0. Finally we # must set aside an IP range in this subnet # (start=10.8.0.50 end=10.8.0.100) to allocate # to connecting clients. Leave this line commented # out unless you are ethernet bridging. ;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100 # Configure server mode for ethernet bridging # using a DHCP-proxy, where clients talk # to the OpenVPN server-side DHCP server # to receive their IP address allocation # and DNS server addresses. You must first use # your OS's bridging capability to bridge the TAP # interface with the ethernet NIC interface. # Note: this mode only works on clients (such as # Windows), where the client-side TAP adapter is # bound to a DHCP client. ;server-bridge # Push routes to the client to allow it # to reach other private subnets behind # the server. Remember that these # private subnets will also need # to know to route the OpenVPN client # address pool (10.8.0.0/255.255.255.0) # back to the OpenVPN server. ;push "route 192.168.10.0 255.255.255.0" ;push "route 192.168.20.0 255.255.255.0" # To assign specific IP addresses to specific # clients or if a connecting client has a private # subnet behind it that should also have VPN access, # use the subdirectory "ccd" for client-specific # configuration files (see man page for more info). # EXAMPLE: Suppose the client # having the certificate common name "Thelonious" # also has a small subnet behind his connecting # machine, such as 192.168.40.128/255.255.255.248. # First, uncomment out these lines: ;client-config-dir ccd ;route 192.168.40.128 255.255.255.248 # Then create a file ccd/Thelonious with this line: # iroute 192.168.40.128 255.255.255.248 # This will allow Thelonious' private subnet to # access the VPN. This example will only work # if you are routing, not bridging, i.e. you are # using "dev tun" and "server" directives. # EXAMPLE: Suppose you want to give # Thelonious a fixed VPN IP address of 10.9.0.1. # First uncomment out these lines: ;client-config-dir ccd ;route 10.9.0.0 255.255.255.252 # Then add this line to ccd/Thelonious: # ifconfig-push 10.9.0.1 10.9.0.2 # Suppose that you want to enable different # firewall access policies for different groups # of clients. There are two methods: # (1) Run multiple OpenVPN daemons, one for each # group, and firewall the TUN/TAP interface # for each group/daemon appropriately. # (2) (Advanced) Create a script to dynamically # modify the firewall in response to access # from different clients. See man # page for more info on learn-address script. ;learn-address ./script # If enabled, this directive will configure # all clients to redirect their default # network gateway through the VPN, causing # all IP traffic such as web browsing and # and DNS lookups to go through the VPN # (The OpenVPN server machine may need to NAT # or bridge the TUN/TAP interface to the internet # in order for this to work properly). push "redirect-gateway def1" # Certain Windows-specific network settings # can be pushed to clients, such as DNS # or WINS server addresses. CAVEAT: # http://openvpn.net/faq.html#dhcpcaveats # The addresses below refer to the public # DNS servers provided by opendns.com. push "dhcp-option DNS 18.104.22.168" push "dhcp-option DNS 22.214.171.124" # Uncomment this directive to allow different # clients to be able to "see" each other. # By default, clients will only see the server. # To force clients to only see the server, you # will also need to appropriately firewall the # server's TUN/TAP interface. ;client-to-client # Uncomment this directive if multiple clients # might connect with the same certificate/key # files or common names. This is recommended # only for testing purposes. For production use, # each client should have its own certificate/key # pair. # # IF YOU HAVE NOT GENERATED INDIVIDUAL # CERTIFICATE/KEY PAIRS FOR EACH CLIENT, # EACH HAVING ITS OWN UNIQUE "COMMON NAME", # UNCOMMENT THIS LINE OUT. ;duplicate-cn # The keepalive directive causes ping-like # messages to be sent back and forth over # the link so that each side knows when # the other side has gone down. # Ping every 10 seconds, assume that remote # peer is down if no ping received during # a 120 second time period. keepalive 10 120 # For extra security beyond that provided # by SSL/TLS, create an "HMAC firewall" # to help block DoS attacks and UDP port flooding. # # Generate with: # openvpn --genkey tls-auth ta.key # # The server and each client must have # a copy of this key. # The second parameter should be '0' # on the server and '1' on the clients. tls-crypt /etc/openvpn/ta.key 0 # This file is secret # Select a cryptographic cipher. # This config item must be copied to # the client config file as well. # Note that v2.4 client/server will automatically # negotiate AES-256-GCM in TLS mode. # See also the ncp-cipher option in the manpage cipher AES-256-CBC # Enable compression on the VPN link and push the # option to the client (v2.4+ only, for earlier # versions see below) ;compress lz4-v2 ;push "compress lz4-v2" # For compression compatible with older clients use comp-lzo # If you enable it here, you must also # enable it in the client config file. ;comp-lzo # The maximum number of concurrently connected # clients we want to allow. ;max-clients 100 # It's a good idea to reduce the OpenVPN # daemon's privileges after initialization. # # You can uncomment this out on # non-Windows systems. user nobody group nobody # The persist options will try to avoid # accessing certain resources on restart # that may no longer be accessible because # of the privilege downgrade. persist-key persist-tun # Output a short status file showing # current connections, truncated # and rewritten every minute. status openvpn-status.log # By default, log messages will go to the syslog (or # on Windows, if running as a service, they will go to # the "\Program Files\OpenVPN\log" directory). # Use log or log-append to override this default. # "log" will truncate the log file on OpenVPN startup, # while "log-append" will append to it. Use one # or the other (but not both). ;log openvpn.log ;log-append openvpn.log # Set the appropriate level of log # file verbosity. # # 0 is silent, except for fatal errors # 4 is reasonable for general usage # 5 and 6 can help to debug connection problems # 9 is extremely verbose verb 3 # Silence repeating messages. At most 20 # sequential messages of the same message # category will be output to the log. ;mute 20 # Notify the client that when the server restarts so it # can automatically reconnect. explicit-exit-notify 1 tls-server tls-version-min 1.2 auth SHA512 auth-nocache
Here, from the above server.conf file, there are couple of important directives that points to some files. Those files are missing at the moment and we need to generate those files.
ca /etc/openvpn/ca.crt cert /etc/openvpn/server.crt key /etc/openvpn/server.key # This file should be kept secret crl-verify /etc/openvpn/crl.pem dh /etc/openvpn/dh.pem tls-crypt /etc/openvpn/ta.key 0 # This file is secret
As you can see, we don't have any of those files - ca.crt, server.crt, server.key, dh.pem, crl.pem and ta.key
To generate those files, we need to use easy-rsa library. easy-rsa is a CLI utility to build and manage a Public Key Infrastructure (PKI) Certificate Authority (CA). In laymen's terms, this means to create a root certificate authority, and request and sign certificates, including intermediate CAs and certificate revocation lists (CRL).
To use easy-rsa library, we will be using git so that we can clone easy-rsa library. So, let's install git in our server.
sudo yum install git -y
Let's create a folder called workspace in the home directory and download easy-rsa package there.
mkdir $HOME/workspace && cd workspace/
In workspace folder, let's create some bash script files to generate all the necessary files. First create .env.sh file to store dynamic values/variables.
touch .env.sh && vi .env.sh
Paste the following contents in the file:
Replace nodexplained with your user name. It can be name of the person to whom VPN connection will be allowed.
Create another file called easy_rsa.sh
touch easy_rsa.sh && vi easy_rsa.sh
Paste the following contents in the file:
echo "Loading env variables: " source ./.env.sh certs_dir="$HOME/acm-vpn-certs" mkdir -p $certs_dir file_path="$certs_dir/certs.txt" filename=$file_path if [ ! -f $filename ] then touch $filename fi file_content=$(<"$file_path") if [[ $file_content != "CERTS_ISSUED" ]]; then echo "Running certs.sh file" chmod +x certs.sh ./certs.sh $USER fi
Create another file called certs.sh
touch certs.sh && vi certs.sh
If you want to know what each of those easy-rsa commands do, please refer to the following link:
Paste the following contents in the file:
#!/bin/bash client_cert_name=$1 export EASYRSA_BATCH=1 echo "================================================================" echo $client_cert_name cd $HOME rm -rf acm-vpn-certs-builder mkdir acm-vpn-certs-builder mkdir acm-vpn-certs cd acm-vpn-certs-builder/ echo "Generate the server and client certificates and keys and upload them to ACM" git clone https://github.com/OpenVPN/easy-rsa.git cd easy-rsa/easyrsa3/ echo "Initialize a new PKI environment." ./easyrsa init-pki echo "To build a new certificate authority (CA), run this command and follow the prompts." ./easyrsa build-ca nopass echo "Generate the server certificate and key" ./easyrsa build-server-full server nopass echo "Generate the client certificate and key" ./easyrsa build-client-full $client_cert_name nopass echo "Generate a strong Diffie-Hellman key to use for the key exchange" ./easyrsa gen-dh echo "Generating a certificate revokation list" ./easyrsa gen-crl echo "Copy the server certificate and key and the client certificate and key to a custom folder and then navigate into the custom folder" cp pki/ca.crt $HOME/acm-vpn-certs/ cp pki/issued/server.crt $HOME/acm-vpn-certs/ cp pki/private/server.key $HOME/acm-vpn-certs/ cp pki/dh.pem $HOME/acm-vpn-certs/ cp pki/issued/$client_cert_name.crt $HOME/acm-vpn-certs cp pki/private/$client_cert_name.key $HOME/acm-vpn-certs/ cp pki/crl.pem $HOME/acm-vpn-certs/ cd $HOME/acm-vpn-certs/ echo "Generate a shared-secret key that is used in addition to the standard RSA certificate/key:" openvpn --genkey --secret ta.key echo "CERTS_ISSUED" > certs.txt sudo cp ca.crt server.crt server.key ta.key dh.pem crl.pem /etc/openvpn/
Now, we need to make all these 3 files executable. Issue the following commands:
chmod u+x .env.sh chmod u+x easy_rsa.sh chmod u+x certs.sh
Let's execute these bash script files:
Check the acm-vpn-certs folder in the home directory. You will see all the required files there. Now that we have all the required files generated and copied to the OpenVPN server configuration directory, it's time to start the VPN server. If you want to re-generate all the keys, modify the certs.txt file located inside of acm-vpn-certs folder. Empty the file contents.
echo > $HOME/acm-vpn-certs/certs.txt
Then execute the bash script again just as above.
We also need to enable ip forwarding to make OpenVPN work. Issue the following command:
sudo vi /etc/sysctl.conf
Paste the following content in the sysctl.conf file:
net.ipv4.ip_forward = 1
Apply sysctl rules using following commands:
sudo service network restart sudo sysctl --system
We also need to issue the following command to create an iptable rule for NAT forwarding in order to allow through VPN traffic to our server.
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
Here eth0 is the network interface used in the current server. To check for your server instance, issue following command
ip link show
As we can see, there is eth0 shown in the image. If something different is shown on your server instance, use that value.
To start OpenVPN server:
sudo systemctl start openvpn-server@server
To restart OpenVPN server:
sudo systemctl restart openvpn-server@server
To check the status of OpenVPN server:
sudo systemctl status openvpn-server@server
To stop OpenVPN server:
sudo systemctl stop openvpn-server@server
To make sure that OpenVPN server starts after each system reboot
sudo systemctl enable openvpn-server@server
Now that our OpenVPN server is up and running, we can initiate VPN connection from our machine using .ovpn file. For creating client .ovpn file, Please refer to the following GitHub link:
Create a file in your local machine:
Replace [USER_NAME] with the name that you have specified in .env.sh file. Please note that, [USER_NAME] can be replaced with anything you like as long as that makes sense to you but a good practice will be to keep the same name that you have used to generate the certificate files.
Copy the following contents into [USER_NAME].ovpn file.
client proto udp4 explicit-exit-notify remote 126.96.36.199 1194 dev tun resolv-retry infinite nobind persist-key persist-tun remote-cert-tls server cipher AES-256-CBC redirect-gateway def1 auth-nocache verb 3 remote-random tls-client tls-version-min 1.2 reneg-sec 0 ignore-unknown-option block-outside-dns setenv opt block-outside-dns # Prevent Windows 10 DNS leak key-direction 1 auth SHA512 user nobody group nobody <ca> </ca> <cert> </cert> <key> </key> <tls-crypt> </tls-crypt>
Modify the Ip address in remote directive. Replace 188.8.131.52 with the static ip of your server instance. We need to also enter the contents for <ca></ca>, <cert></cert>, <key></key> and <tls-crypt></tls-crypt>.
|.ovpn Directive||File to copy content from|
Here, replace [USER_NAME] with the name of the user you have placed in .env.sh bash script file.
Final version of the [USER_NAME].ovpn file looks like below:
client proto udp4 explicit-exit-notify remote 184.108.40.206 1194 dev tun resolv-retry infinite nobind persist-key persist-tun remote-cert-tls server cipher AES-256-CBC redirect-gateway def1 auth-nocache verb 3 remote-random tls-client tls-version-min 1.2 reneg-sec 0 ignore-unknown-option block-outside-dns setenv opt block-outside-dns # Prevent Windows 10 DNS leak key-direction 1 auth SHA512 user nobody group nobody <ca> -----BEGIN CERTIFICATE----- MIIDNTCCAh2gAwIBAgIJANA3fmyi8y/xMA0GCSqGSIb3DQEBCwUAMBYxFDASBgNV BAMMC0Vhc3ktUlNBIENBMB4XDTIyMDcyODAwMTQ1MloXDTMyMDcyNTAwMTQ1Mlow FjEUMBIGA1UEAwwLRWFzeS1SU0EgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw ggEKAoIBAQDI1Up2oshLY8nRFneheXIf138pkAlGC31MSQCw1eUCQ23CFlT6XqDY C4GE3v7Foykg3ch41KPBhMxdR9frOvvc43oJWJLFFDbgSNwWp5rUY42qnQcKZ37Q TmBdp4rEF3XnqXWQLpA1HiH9+IbOuGroFHghoac+qiaFOoJ9yEgQbXUby9bs5Bgi tdpFJxJcdmcOYVqanSCah2bGa9uoqiBouT2dVNjuTEwBiXhZXwCvtKKLuQ61/SOc WxnD/9+jU4bbHOc3l44defsNXwE4xg9dXZQIz5bHvy6T/Sd2D7yNAt5a/zlzBfNd 3XLpDsSb9x05A4OHLAWY9AbybwxRlkbxAgMBAAGjgYUwgYIwDAYDVR0TBAUwAwEB /zAdBgNVHQ4EFgQUPhpUgtghyaxVXM6nn8rS1gZslCkwRgYDVR0jBD8wPYAUPhpU gtghyaxVXM6nn8rS1gZslCmhGqQYMBYxFDASBgNVBAMMC0Vhc3ktUlNBIENBggkA 0Dd+bKLzL/EwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBCwUAA4IBAQAyfjVTcOMY LR1bDsXxgcUPc+CJwj2RD+9mr+SoXqGiXGRua+SrVCBlad+GNCVf2U3KIn/4UOhU TtJ7dlaepahW9hAfwSIV+B+cDj0ANFd3iDijHomz7TaxTpdzX1KIBsndAO3Ps1HP IV9Z8MvjO4gq/3/XW67WrKCJPBI/FdkldRuPi+CELu3DL8YSSTOy0C3+2Xfn0v8F mYmmZOX6Nb2UfKcijwN9iYBWxdxQSDIf1TEVG7R2YnzrUTU7q+WI//rd/ei0Pyhk 9DDPowsQOHsgd7HgReBuLJLYDFx4hj4JnG85FBNVssf9NKzs7Gw6uWxzSbgzdK3H yNFEh1JHsBO9 -----END CERTIFICATE----- </ca> <cert> Certificate: Data: Version: 3 (0x2) Serial Number: 17:d8:5c:64:98:58:3a:8c:be:25:f7:c1:f9:50:15:12 Signature Algorithm: sha256WithRSAEncryption Issuer: CN=Easy-RSA CA Validity Not Before: Jul 28 00:14:52 2022 GMT Not After : Oct 30 00:14:52 2024 GMT Subject: CN=nodexplained Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:ba:b5:0c:d2:a2:c9:ec:cc:22:69:8e:d0:6b:b8: 1e:a1:4f:a9:64:9e:f3:ba:3c:b0:51:0b:0d:4e:a2: 0b:7a:27:52:77:ed:93:bc:fc:4b:3b:0a:4f:b6:e3: c3:35:91:ce:4a:41:ec:a7:51:57:91:da:4f:10:17: be:70:ee:59:86:86:80:d5:85:0d:a5:fb:19:18:fb: f4:5a:1e:ef:e7:29:cc:b7:26:c8:6a:ee:26:37:f9: e0:48:41:6d:f9:49:b7:e1:b6:72:f9:2b:1a:fa:fc: 3d:81:64:5d:85:c7:e1:ed:13:22:9a:21:4c:27:c0: 0c:d9:db:f7:77:19:3f:55:5d:27:8e:0a:69:9a:e9: 1d:c7:10:6a:f5:72:02:2c:42:f0:a0:81:1c:e2:81: 6a:98:37:1a:c1:b5:82:5d:78:ff:3b:72:d7:17:4c: aa:ce:d2:1c:ea:af:a1:5c:da:ee:22:59:9a:17:87: 24:db:74:38:87:73:1d:1f:79:a7:9e:58:9a:ec:a0: ab:ca:65:ab:91:b2:ea:08:2b:5a:b0:30:ee:af:63: 4c:1a:1f:6d:a4:7c:91:0d:a1:0c:7a:f8:78:37:b4: 16:03:47:5e:8e:da:11:28:9a:74:86:e9:2e:c2:2a: 5f:80:3d:02:6c:3e:b7:19:e3:22:00:c7:73:05:31: f2:b9 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: CA:FALSE X509v3 Subject Key Identifier: 36:C5:F8:4D:2D:E9:F9:57:68:2B:39:E4:B9:4C:BE:AF:09:0D:37:6E X509v3 Authority Key Identifier: keyid:3E:1A:54:82:D8:21:C9:AC:55:5C:CE:A7:9F:CA:D2:D6:06:6C:94:29 DirName:/CN=Easy-RSA CA serial:D0:37:7E:6C:A2:F3:2F:F1 X509v3 Extended Key Usage: TLS Web Client Authentication X509v3 Key Usage: Digital Signature Signature Algorithm: sha256WithRSAEncryption 27:80:60:52:1f:94:a7:dc:6c:27:be:53:86:e1:f5:06:6b:a1: 2e:d1:42:8c:26:88:bd:f5:44:ff:82:f3:26:e8:2f:63:19:4f: e8:d4:cd:30:7e:ab:f1:46:05:4a:3c:8c:0c:e9:92:fb:10:27: 83:12:24:7e:37:0b:69:18:57:01:74:5a:99:55:bd:e7:9d:3e: 80:a6:ec:88:c2:75:dd:df:ca:f3:8f:07:97:e0:67:63:e7:fa: 9d:1a:8d:fb:1d:a4:19:1e:9b:c2:6e:29:52:b3:bf:d1:f0:9c: 46:09:df:e8:69:ac:a5:4d:42:c2:13:83:3e:63:df:b9:c9:e8: a0:79:f2:7d:ac:76:ab:54:ca:3e:c7:70:30:61:81:24:a3:08: 23:61:50:78:df:73:52:28:86:7e:0c:ba:b6:4f:c6:1e:0b:c1: ce:dc:1e:e9:7f:cb:e2:12:09:c1:3c:18:b0:fb:3d:ea:a9:5b: 52:4e:28:19:58:48:a9:80:d7:95:8c:ff:69:49:32:a5:86:68: df:d4:09:e3:bf:71:9e:db:1f:5d:64:84:e4:60:60:89:14:d0: 17:67:e9:e5:ac:c4:5f:b1:67:be:b4:50:a2:7c:d7:3a:7d:2a: 82:e0:a1:ac:f3:ff:39:1f:97:26:da:0d:f2:14:37:4f:d8:78: e6:ae:9f:77 -----BEGIN CERTIFICATE----- MIIDTzCCAjegAwIBAgIQF9hcZJhYOoy+JffB+VAVEjANBgkqhkiG9w0BAQsFADAW MRQwEgYDVQQDDAtFYXN5LVJTQSBDQTAeFw0yMjA3MjgwMDE0NTJaFw0yNDEwMzAw MDE0NTJaMBcxFTATBgNVBAMMDG5vZGV4cGxhaW5lZDCCASIwDQYJKoZIhvcNAQEB BQADggEPADCCAQoCggEBALq1DNKiyezMImmO0Gu4HqFPqWSe87o8sFELDU6iC3on Unftk7z8SzsKT7bjwzWRzkpB7KdRV5HaTxAXvnDuWYaGgNWFDaX7GRj79Foe7+cp zLcmyGruJjf54EhBbflJt+G2cvkrGvr8PYFkXYXH4e0TIpohTCfADNnb93cZP1Vd J44KaZrpHccQavVyAixC8KCBHOKBapg3GsG1gl14/zty1xdMqs7SHOqvoVza7iJZ mheHJNt0OIdzHR95p55Ymuygq8plq5Gy6ggrWrAw7q9jTBofbaR8kQ2hDHr4eDe0 FgNHXo7aESiadIbpLsIqX4A9Amw+txnjIgDHcwUx8rkCAwEAAaOBlzCBlDAJBgNV HRMEAjAAMB0GA1UdDgQWBBQ2xfhNLen5V2grOeS5TL6vCQ03bjBGBgNVHSMEPzA9 gBQ+GlSC2CHJrFVczqefytLWBmyUKaEapBgwFjEUMBIGA1UEAwwLRWFzeS1SU0Eg Q0GCCQD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N OpenVPN Static key V1----- 3600ca0bd6e8435ae41c07ac917e29ad 91895152cd0cf9dd04bc4cdc7e562648 757ad5d421f66ac2ab7303e54a48865c 1b61d49bbb9f1a92fdd52cb23e9314dc 9aa2bcfd07eb74de8621294d20870ce2 d3480bba6c9e3fc9bc32e24bbdc9aa8c 52daf623d92bef505407c73d161d8ce5 e779d80dd330e214eb32fa9c7e460be8 51084895623f0366971b77b365a1357c ae5f3b36cc4631a96b71297755a7c7e6 5b7db8af39b9836fa0bbd556ba51bf90 cb25fba36701e38bcf853bcbc75fd30a 1d37ff79e9b6b30d6cc4d817d1c22d0e 7ea51d9d6cc63e2e990dfedccdb655e7 c597d3b809a63a73b5304a60eed28a92 48d2d7c098d0bce3dfc565f31b970336 -----END OpenVPN Static key V1----- </tls-crypt>
Please make sure that this file is kept private and secure so that no one can impersonate you. I have shown this file just for reference and by the time you see it, this OpenVPN server is already deleted.
To connect to the VPN server, we need to download VPN clients. For macOS users, Tunnelblick and OpenVPN client is very popular and for linux and windows users, OpenVPN client is very popular.
To download Tunnelblick, go to the following link:
To download OpenVPN client for linux distributions, go to the following link:
To download OpenVPN client for Windows machines, go to the following link:
If you choose to download and install OpenVPN client, following image shows it's user interface.
In OpenVPN client, we need to upload .ovpn file from FILE tab by clicking on Browse button.
Once the .ovpn profile is loaded to the VPN client, it may also ask to enter the username and password of your local machine. Then check checkbox for connect after import.
Click on Add button at the top after filling all necessary details.
Following images shows our VPN connection being successful.
Now, check your ip address using one of the following links:
In our server deployment architecture, as of now, we have limited usage of OpenVPN server - only the secure SSH connection to our remote server instances. As part of the enhancements to our current server architecture, we will expand the usage of OpenVPN server so that admin applications, all of the monitoring and logging tools will be accessible only after successful VPN connection. It will be discussed in later chapters.
AWS also provides a managed VPN service called AWS client VPN.
In our next chapter, we will setup and configure NGINX web server.