{"id":333,"date":"2019-04-12T20:57:22","date_gmt":"2019-04-12T20:57:22","guid":{"rendered":"https:\/\/bootstrap-it.com\/blog\/?p=333"},"modified":"2019-04-12T20:57:22","modified_gmt":"2019-04-12T20:57:22","slug":"securing-your-network-connections-using-openvpn","status":"publish","type":"post","link":"https:\/\/bootstrap-it.com\/blog\/?p=333","title":{"rendered":"Securing your network connections using OpenVPN"},"content":{"rendered":"<div id=\"s-share-buttons\" class=\"horizontal-w-c-circular s-share-w-c\"><a href=\"http:\/\/www.facebook.com\/sharer.php?u=https:\/\/bootstrap-it.com\/blog\/?p=333\" target=\"_blank\" title=\"Share to Facebook\" class=\"s3-facebook hint--top\"><\/a><a href=\"http:\/\/twitter.com\/intent\/tweet?text=Securing your network connections using OpenVPN&url=https:\/\/bootstrap-it.com\/blog\/?p=333\" target=\"_blank\"  title=\"Share to Twitter\" class=\"s3-twitter hint--top\"><\/a><a href=\"http:\/\/reddit.com\/submit?url=https:\/\/bootstrap-it.com\/blog\/?p=333&title=Securing your network connections using OpenVPN\" target=\"_blank\" title=\"Share to Reddit\" class=\"s3-reddit hint--top\"><\/a><a href=\"http:\/\/www.linkedin.com\/shareArticle?mini=true&url=https:\/\/bootstrap-it.com\/blog\/?p=333\" target=\"_blank\" title=\"Share to LinkedIn\" class=\"s3-linkedin hint--top\"><\/a><a href=\"mailto:?Subject=Securing%20your%20network%20connections%20using%20OpenVPN&Body=Here%20is%20the%20link%20to%20the%20article:%20https:\/\/bootstrap-it.com\/blog\/?p=333\" title=\"Email this article\" class=\"s3-email hint--top\"><\/a><\/div>\n<p><em>This article, which also appears on <a href=\"https:\/\/medium.com\/@dbclin\">my Medium account<\/a>, is excerpted from chapter 10 of my Manning book, <\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/www.manning.com\/books\/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9\" target=\"_blank\"><em>Linux in Action<\/em><\/a><em>. Besides the book, you can also work through\u00a0<\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/www.manning.com\/livevideo\/linux-in-motion?a_aid=bootstrap-it&amp;a_bid=0c56986f&amp;chan=motion1\" target=\"_blank\"><em>Linux in Motion<\/em><\/a><em>\u200a\u2014\u200aa hybrid course made up of more than two hours of video and around 40% of the text of Linux in Action.<\/em><\/p>\n\n\n\n<p>They tell us we live in a hyper-mobile world. Not that I\u2019d know: I rarely leave my home office. But of course I only get to enjoy the comforts of my home office because all the server resources I could possibly need are available remotely.<\/p>\n\n\n\n<p>Apparently I\u2019m not alone. Almost everyone whose work touches IT will access their professional tools from remote locations from time to time. And given that the public networks through which you access those remote locations are by their nature insecure, you\u2019re going to want to carefully control those connections.<\/p>\n\n\n\n<p>Website encryption is about making sure that the data consumed by your remote clients is reliably transferred and invisible to anyone who might be lurking on the connecting network. VPNs, by sharp contrast, focus on making sure that the data consumed by your remote clients is reliably transferred and invisible to anyone who might be lurking on the connecting network. Do you see the difference? Neither do I.<\/p>\n\n\n\n<p>In fact, there are all kinds of technologies devoted to securing network communication, and the principle of _defence in depth_ teaches us that you should never rely on just one. So here\u2019s where you\u2019ll learn about _adding new_ layers of protection for your remote activities. Specifically, using encryption to build a virtual private network (VPN) tunnel to permit secure and invisible remote connections.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"8b1e\">Building an OpenVPN&nbsp;tunnel<\/h4>\n\n\n\n<p>My&nbsp;<a href=\"https:\/\/www.manning.com\/books\/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9\" rel=\"noreferrer noopener\" target=\"_blank\">Linux in Action book<\/a>&nbsp;talks a lot about encryption. SSH and SCP can protect data transferred through remote connections (chapter 3), file encryption can protect data at rest (chapter 8), and TLS\/SSL certificates can protect data in transit between websites and client browsers (chapter 9). But sometimes your requirements demand protection across a broader range of connections, because sometimes you\u2019ve got different kinds of work to do.<\/p>\n\n\n\n<p>F\u2019rinstance? Some members of your team need to work from the road using public WiFi hotspots. It\u2019s definitely not smart to assume that random WiFi access points are secure, but your people do need a way to connect with company resources. VPNs to the rescue.<\/p>\n\n\n\n<p>A properly designed VPN tunnel provides a direct connection between remote clients and a server in a way that hides data as it\u2019s transferred across an insecure network. But so what? You\u2019ve already seen lots of tools that can do that using encryption. The real value of a VPN is that once you\u2019ve opened a tunnel, it\u2019s possible to connect remote networks as though they\u2019re all together locally. In a way, you\u2019re circumventing that dodgy coffee shop hot spot.<\/p>\n\n\n\n<p>Using such an extended network, admins can get their work done on their servers no matter where they might happen to be. But more importantly, as you can see in the figure, a company with resources spread through multiple branch offices can make them all both visible and accessible to all the teams who need them\u2026wherever they are.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*G4AiguIz4CU9i4Kzk0yz8w.png\" alt=\"\"\/><figcaption>Tunnel connecting remote private connections through a public&nbsp;network<\/figcaption><\/figure>\n\n\n\n<p>The mere existence of a tunnel alone doesn\u2019t guarantee security. But one of a number of encryption standards can be incorporated into the design, making things a great deal better. Tunnels built with the open source OpenVPN package use the same TLS\/SSL encryption you\u2019ve already seen in use elsewhere. OpenVPN is not the only available choice for tunnelling, but it is among the best known, and it\u2019s widely assumed to be a bit faster and likely more secure than the alternative Layer 2 Tunnel Protocol using IPsec encryption.<\/p>\n\n\n\n<p>So that your team can safely connect with each other from out on the road or between multiple campuses, you\u2019re going to build an OpenVPN server to permit sharing both applications and access to the server\u2019s local network environment. To make it work, it should be sufficient to fire up two VMs or containers. One to play the role of a server\/host and the other of the client.<\/p>\n\n\n\n<p>Building a VPN involves quite a few steps, so taking a few moments to think about the big picture of how this is going to work will probably be worthwhile.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"8c67\">Configuring an OpenVPN&nbsp;server<\/h4>\n\n\n\n<p>Before getting started, here\u2019s a helpful tip. If you\u2019re going to follow along with this process on your own\u200a\u2014\u200aand I strongly recommend that you do\u200a\u2014\u200ayou\u2019ll probably find yourself working with multiple terminal windows open on your desktop, each logged into a different machine. Take it from me: at some point you\u2019re going to enter a command into the wrong window and totally mess up your environment.<\/p>\n\n\n\n<p>You can use the hostname command to change the machine name displayed on the command line to something that will visually remind you where you are. Once that\u2019s done, you\u2019ll need to exit the server and log back in again for the new setting to take effect.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ubuntu@ubuntu:~# hostname OpenVPN-Server<br>ubuntu@ubuntu:~$ exit <br>&lt;Host Workstation&gt;$ ssh ubuntu@10.0.3.134<br>ubuntu@OpenVPN-Server:~# <\/pre>\n\n\n\n<p>Following that approach to assign appropriate names to each of the machines you\u2019re working with should help you keep track of where you are.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1532\">Prepare your server for&nbsp;OpenVPN<\/h4>\n\n\n\n<p>Installing OpenVPN on your server requires two packages: openvpn and, to manage the encryption key-generation process, easy-rsa. CentOS users should, if necessary, first install the epel-release repository the way you did back in chapter 2. To give you an easy way to test access to a server application, you could also install the Apache webserver (apache2 for Ubuntu and httpd on CentOS).<\/p>\n\n\n\n<p>While you\u2019re setting up your server, you might as well do it right and activate a firewall that blocks all ports besides 22 (SSH) and 1194 (the default OpenVPN port). This example illustrates the way that will work on Ubuntu\u2019s ufw, but I\u2019m sure you still remember CentOS\u2019 firewalld from chapter 9.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># ufw enable<br># ufw allow 22<br># ufw allow 1194<\/pre>\n\n\n\n<p>To permit internal routing between network interfaces on the server you\u2019ll need to uncomment a single line (net.ipv4.ip_forward=1) in the \/etc\/sysctl.conf file. This will allow remote clients to be redirected as needed once they\u2019re connected. To load the new setting, run sysctl -p.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># nano \/etc\/sysctl.conf<br># sysctl -p<\/pre>\n\n\n\n<p>The server environment is now all set up, but there\u2019s still a way to go before you\u2019re ready to flip the switch.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"0401\">Generate encryption keys<\/h4>\n\n\n\n<p>When you installed OpenVPN, a \/etc\/openvpn\/ directory was automatically created, but there isn\u2019t a whole lot in it just yet. However, both the openvpn and easy-rsa packages come with sample template files that you can use as a base for you configuration. To jump start the certification process, copy the easy-rsa template directory from \/usr\/share\/ to \/etc\/openvpn\/ and then change to the new easy-rsa\/ directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># cp -r \/usr\/share\/easy-rsa\/ \/etc\/openvpn<br>$ cd \/etc\/openvpn\/easy-rsa<\/pre>\n\n\n\n<p>The first file you\u2019ll work with is called simply vars, and contains environment variables that easy-rsa will use when it generates its keys. You will want to edit the file to substitute your own values for the sample defaults that are already there. Here\u2019s what my file would look like:<\/p>\n\n\n\n<p>Key excerpts from the \/etc\/openvpn\/easy-rsa\/vars file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export KEY_COUNTRY=\u201dCA\u201d<br>export KEY_PROVINCE=\u201dON\u201d<br>export KEY_CITY=\u201dToronto\u201d<br>export KEY_ORG=\u201dBootstrap IT\u201d<br>export KEY_EMAIL=\u201d<a href=\"mailto:info@bootstrap-it.com\" rel=\"noreferrer noopener\" target=\"_blank\">info@bootstrap-it.com<\/a>\u201d<br>export KEY_OU=\u201dIT\u201d<\/pre>\n\n\n\n<p>Running the vars file will pass its values to the shell environment from where they\u2019ll be incorporated into the contents of your new keys. When that\u2019s done, the script will encourage you to run the clean-all script to delete any existing contents in the \/etc\/openvpn\/easy-rsa\/keys\/ directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cd \/etc\/openvpn\/easy-rsa\/<br># . .\/vars <br>NOTE: If you run .\/clean-all, I will be doing a rm -rf on \/etc\/openvpn\/easy-rsa\/keys<\/pre>\n\n\n\n<p>Naturally, your next step will be to run that clean-all script\u2026followed by build-ca that will use the pkitool script to create your root certificate. You\u2019ll be asked to confirm the identification settings provided by vars.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># .\/clean-all<br># .\/build-ca<br>Generating a 2048 bit RSA private key<\/pre>\n\n\n\n<p>Next, the build-key-server script, since it uses the same pkitool script along with the new root certificate, will ask you the same confirmation questions to generate a key pair. The keys will be given names based on the argument you pass\u200a\u2014\u200awhich, unless you\u2019re running multiple VPNs on this machine, would normally be server, as in this example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># .\/build-key-server server<br>[\u2026]<br>Certificate is to be certified until Aug 15 23:52:34 2027 GMT (3650 days)<br>Sign the certificate? [y\/n]:y<br>1 out of 1 certificate requests certified, commit? [y\/n]y<br>Write out database with 1 new entries<br>Data Base Updated<\/pre>\n\n\n\n<p>OpenVPN will use parameters generated using the Diffie-Hellman algorithm (by running build-dh) to negotiate authentication for new connections. The file that will be created here does not need to remain secret, but must have been generated using the build-dh script against the RSA keys that are currently active. If you create new RSA keys at some time in the future, you\u2019ll also need to update the Diffie-Hellman file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># build-dh<\/pre>\n\n\n\n<p>Your server-side keys will now have been written to the \/etc\/openvpn\/easy-rsa\/keys\/ directory, but OpenVPN doesn\u2019t know that. By default OpenVPN will lookfor them in \/etc\/openvpn\/, so copy them over.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># cp \/etc\/openvpn\/easy-rsa\/keys\/server* \/etc\/openvpn<br># cp \/etc\/openvpn\/easy-rsa\/keys\/dh2048.pem \/etc\/openvpn<br># cp \/etc\/openvpn\/easy-rsa\/keys\/ca.crt \/etc\/openvpn<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"81a8\">Prepare client encryption keys<\/h4>\n\n\n\n<p>As you\u2019ve already seen, TLS encryption uses matching key pairs, one installed on the server and the other on a remote client. That means you\u2019re going to need client keys, and our old friend pkitool is just the thing to cook some up. This example, run while still in the \/etc\/openvpn\/easy-rsa\/ directory, passes client as an argument to generate files called client.crt and client.key.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># .\/pkitool client<\/pre>\n\n\n\n<p>The two client files, along with the original ca.crt file that\u2019s still in the keys\/ directory, will now have to be securely transferred to your client. Because of their ownership and permissions, this might be a bit complicated. The simplest approach is to manually copy the contents of the source file (and nothing but those contents) in a terminal running on your PC\u2019s desktop (by highlighting the text, right-clicking over it, and selecting copy from the menu) and then pasting it into a new file of the same name you create in a second terminal logged into your client.<\/p>\n\n\n\n<p>But anyone can cut and paste. Instead, think like an admin\u200a\u2014\u200aespecially since you won\u2019t always have access to a GUI where cutting and pasting is possible. Instead, copy the files to your user\u2019s home directory (so a remote scp operation can access them) and then use chown to change the ownership of the files from root to your regular, non-root user so that remote scp action can work. Make sure your files are all settled and comfy for now\u2026you\u2019ll move them over to the client a bit later.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># cp \/etc\/openvpn\/easy-rsa\/keys\/client.key \/home\/ubuntu\/<br># cp \/etc\/openvpn\/easy-rsa\/keys\/ca.crt \/home\/ubuntu\/<br># cp \/etc\/openvpn\/easy-rsa\/keys\/client.crt \/home\/ubuntu\/<br># chown ubuntu:ubuntu \/home\/ubuntu\/client.key<br># chown ubuntu:ubuntu \/home\/ubuntu\/client.crt<br># chown ubuntu:ubuntu \/home\/ubuntu\/ca.crt<\/pre>\n\n\n\n<p>With a full set of encryption keys ready for action, you\u2019ll need to tell your server how you want to build your VPN. That\u2019s done using the server.conf file.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"8262\">Configure server.conf file<\/h4>\n\n\n\n<p>How are you supposed to know what the server.conf file should look like? Well, remember the easy-rsa directory template you copied over from \/usr\/share\/? Well there are more goodies where that came from. The OpenVPN installation left a compressed template configuration file which you can copy over to \/etc\/openvpn\/.<\/p>\n\n\n\n<p>I\u2019ll use the fact that the template is compressed to introduce you to a useful tool: zcat. You\u2019re already know about printing a file\u2019s text contents to the screen with cat, but what if the file is compressed using gzip? Of course, you could always decompress the file and cat will then be happy to print it, but that\u2019s one or two steps too many. Instead, as you\u2019ve probably already guessed, you can use zcat to load the decompressed text into memory all in one step. In our case, rather than print it to the screen, you\u2019ll redirect the text to a new file called server.conf.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># zcat \\<br> \/usr\/share\/doc\/openvpn\/examples\/sample-config-files\/server.conf.gz<br> &gt; \/etc\/openvpn\/server.conf<br>$ cd \/etc\/openvpn<\/pre>\n\n\n\n<p>Leaving out the extensive and helpful documentation that comes with the file, here\u2019s how it might look once you\u2019re done editing. Note that a semicolon (;) tells OpenVPN _not_ to read and execute the line that follows.<\/p>\n\n\n\n<p>The active settings from a \/etc\/openvpn\/server.conf file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><br>port 1194<br># TCP or UDP server?<br>proto tcp<br>;proto udp<br>;dev tap<br>dev tun<br>ca ca.crt<br>cert server.crt<br>key server.key # This file should be kept secret<br>dh dh2048.pem<br>server 10.8.0.0 255.255.255.0<br>ifconfig-pool-persist ipp.txt<br>push \u201croute 10.0.3.0 255.255.255.0\u201d<br>keepalive 10 120<br>comp-lzo<br>port-share localhost 80 <br>user nobody <br>group nogroup<br>persist-key<br>persist-tun<br>status openvpn-status.log<br>log openvpn.log <br>;log-append openvpn.log<br>verb 3 <\/pre>\n\n\n\n<p>Let\u2019s work through some of those one at a time.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>By default, OpenVPN works over port 1194. You can change that\u200a\u2014\u200aperhaps to further obscure your activities, or avoid conflicts with other active tunnels. But, because it will require the least coordination between clients, 1194 is normally your best choice.<\/li><li>OpenVPN can use either the Transmission Control Protocol (TCP) or User Datagram Protocol (UDP) for data transmissions. TCP might be a little bit slower, but it\u2019s more reliable and more likely to get along with applications running at either end of the tunnel.<\/li><li>You specify dev tun when you want to create a simpler and more efficient IP tunnel that transfers data content and nothing much else. If, on the other hand, you\u2019ll need to connect multiple network interfaces (and the networks they represent) by creating an _ethernet bridge_, then you\u2019ll have to select dev tap. If you haven\u2019t a clue what all that means, go with tun.<\/li><li>The next four lines pass OpenVPN the names of the three server authentication files and the dh2048 parameters file you created earlier.<\/li><li>The server line sets the subnet range and netmask that will be used for assigning IP addresses to clients when they log in.<\/li><li>The optional push \u201croute 10.0.3.0 255.255.255.0\u201d setting will allow remote clients to access private subnets \u201cbehind\u201d the server. Making this work will also require network configuration on to server itself to ensure that the private subnet is aware of the OpenVPN subnet (10.8.0.0).<\/li><li>port-share localhost 80 allows client traffic coming in on port 1194 to be rerouted to a local web server listening on port 80. This will be useful in our case since we\u2019re going to use a web server to test our VPN. This will only work when proto is set to tcp.<\/li><li>The user nobody and group nogroup lines should be enabled by removing the semicolons. Forcing remote clients to work as nobody and nogroup ensures that their sessions on the server will be unprivileged.<\/li><li>log sets current log entries to overwrite old entries every time OpenVPN starts up, while log-append appends new entries to the existing log file. The openvpn.log itself will be written to the \/etc\/openvpn\/ directory.<\/li><\/ul>\n\n\n\n<p>In addition, it is also very common to add client-to-client to the config file so multiple clients will be able to see each other in addition to the OpenVPN server.<\/p>\n\n\n\n<p>Once you\u2019re satisfied with your configuration, you\u2019re ready to fire up the OpenVPN server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># systemctl start openvpn<\/pre>\n\n\n\n<p>Running ip addr to list your server\u2019s network interfaces should now include a reference to a new interface called tun0. This will have been created by OpenVPN for the use of incoming clients.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ ip addr<br>[\u2026]<br>4: tun0: &lt;POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP&gt; mtu 1500 qdisc [\u2026]<br> link\/none <br> inet 10.8.0.1 peer 10.8.0.2\/32 scope global tun0<br> valid_lft forever preferred_lft forever<\/pre>\n\n\n\n<p>It is _possible_ that you\u2019ll need to reboot the server before everything will fully function. Next stop: the client computer.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"353f\">Configuring an OpenVPN&nbsp;client<\/h4>\n\n\n\n<p>Traditionally, tunnels are built with at least two ends (otherwise we prefer calling them caves). Having OpenVPN properly configured on the server directs traffic into and out of the tunnel at that end. But you\u2019ll need some kind of software running on the client side as well.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>In this section I\u2019m going to focus on manually configuring a Linux computer of one sort or another to act as an OpenVPN client. But that\u2019s not the only way you might want to consume the service. OpenVPN itself maintains client apps that can be installed and used on Windows or Mac desktop\/laptops, or Android and iOS smart phones and tablets. See the&nbsp;<a href=\"https:\/\/openvpn.net\/\" rel=\"noreferrer noopener\" target=\"_blank\">https:\/\/openvpn.net<\/a>&nbsp;web site for details.<\/p><\/blockquote>\n\n\n\n<p>The OpenVPN package will need to be installed on the client machine, as it was on the server\u200a\u2014\u200aalthough there\u2019s no need for easy-rsa over here, because the keys you\u2019ll use already exist. You will need to copy the client.conf template file over to the \/etc\/openvpn\/ directory that the installation just created. This time, for some reason, the file won\u2019t be compressed, so a regular cp will do the job just fine.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># apt install openvpn<br># cp \/usr\/share\/doc\/openvpn\/examples\/sample-config-files\/client.conf \\<br> \/etc\/openvpn\/<\/pre>\n\n\n\n<p>Most of the settings in your client.conf file will be fairly obvious: they\u2019ll need to match the values used by the server. As you can see from the sample file below, one that\u2019s unique is remote 192.168.1.23 1194\u200a\u2014\u200awhich points the client to the server\u2019s IP address. Again, make sure you use your server\u2019s actual address. You should also force your client to verify the authenticity of the server certificate to prevent a possible man-in-the-middle attack. One way to do this is by adding the remote-cert-tls server line.<\/p>\n\n\n\n<p>The active settings in a VPN client\u2019s \/etc\/openvpn\/client.conf file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">client <br>;dev tap<br>dev tun<br>proto tcp<br>remote 192.168.1.23 1194 <br>resolv-retry infinite<br>nobind<br>user nobody<br>group nogroup<br>persist-key<br>persist-tun<br>ca ca.crt<br>cert client.crt<br>key client.key<br>comp-lzo<br>verb 3<br>remote-cert-tls server <\/pre>\n\n\n\n<p>Now you can move to the \/etc\/openvpn\/ directory and pull those certification keys from the server. You will obviously substitute your server\u2019s actual IP address or domain name for the one in the example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cd \/etc\/openvpn<br># scp ubuntu@192.168.1.23:\/home\/ubuntu\/ca.crt . <br># scp ubuntu@192.168.1.23:\/home\/ubuntu\/client.crt .<br># scp ubuntu@192.168.1.23:\/home\/ubuntu\/client.key .<\/pre>\n\n\n\n<p>Nothing exciting is likely to happen until you start up OpenVPN on the client. Because you\u2019ll need to pass a couple of arguments, you\u2019ll pull the trigger from the command line.\u200a\u2014\u200atls-client tells OpenVPN that you\u2019ll be acting as a client and connecting via TLS encryption while\u200a\u2014\u200aconfig points to your config file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># openvpn \u2014 tls-client \u2014 config \/etc\/openvpn\/client.conf<\/pre>\n\n\n\n<p>Read the command output carefully to make sure you\u2019re connected properly. If something does go wrong the first time, it\u2019s probably either due to a setting mismatch between the server and client configuration files or perhaps a network connectivity\/firewall issue. Here are some troubleshooting steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Carefully read the output from the OpenVPN operation on the client\u200a\u2014\u200ait will often contain valuable hints to exactly what it couldn\u2019t do and why.<\/li><li>Check for error-related messages in the openvpn.log and openvpn-status.log files in the \/etc\/openvpn\/ directory on the server.<\/li><li>Check OpenVPN-related and timely messages in the system logs on both the server and client (journalctl -ce will print out a screenfull of the most recent entries).<\/li><li>Confirm that you\u2019ve got an active network connection between the server and client (see chapter 14 for details).<\/li><\/ul>\n\n\n\n<p><em>This article is excerpted from my&nbsp;<\/em><a href=\"https:\/\/www.manning.com\/books\/linux-in-action?a_aid=bootstrap-it&amp;a_bid=4ca15fc9\" rel=\"noreferrer noopener\" target=\"_blank\"><em>Manning \u201cLinux in Action\u201d book<\/em><\/a><em>. There\u2019s lots more fun&nbsp;<\/em><a href=\"https:\/\/bootstrap-it.com\/index.php\/books\/\" rel=\"noreferrer noopener\" target=\"_blank\"><em>where this came from<\/em><\/a><em>,&nbsp;<\/em>including a hybrid course called&nbsp;<a href=\"https:\/\/www.manning.com\/livevideo\/linux-in-motion?a_aid=bootstrap-it&amp;a_bid=0c56986f&amp;chan=motion1\" rel=\"noreferrer noopener\" target=\"_blank\">Linux in Motion<\/a>&nbsp;that\u2019s made up of more than two hours of video and around 40% of the text of Linux in Action.<em>&nbsp;Who knows\u2026you might also enjoy my&nbsp;<\/em><a href=\"https:\/\/www.manning.com\/books\/learn-amazon-web-services-in-a-month-of-lunches?a_aid=bootstrap-it&amp;amp;a_bid=1c1b5e27\" rel=\"noreferrer noopener\" target=\"_blank\"><em>Learn Amazon Web Services in a Month of Lunches<\/em><\/a><em>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article, which also appears on my Medium account, is excerpted from chapter 10 of my Manning book, Linux in Action. Besides the book, you can also work through\u00a0Linux in Motion\u200a\u2014\u200aa hybrid course made up of more than two hours&hellip; <a href=\"https:\/\/bootstrap-it.com\/blog\/?p=333\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-333","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.2.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Securing your network connections using OpenVPN - Bootstrap IT<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bootstrap-it.com\/blog\/?p=333\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Securing your network connections using OpenVPN - Bootstrap IT\" \/>\n<meta property=\"og:description\" content=\"This article, which also appears on my Medium account, is excerpted from chapter 10 of my Manning book, Linux in Action. Besides the book, you can also work through\u00a0Linux in Motion\u200a\u2014\u200aa hybrid course made up of more than two hours&hellip; Continue Reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bootstrap-it.com\/blog\/?p=333\" \/>\n<meta property=\"og:site_name\" content=\"Bootstrap IT\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-12T20:57:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*G4AiguIz4CU9i4Kzk0yz8w.png\" \/>\n<meta name=\"author\" content=\"dbclin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@davidbclinton\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dbclin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/?p=333\",\"url\":\"https:\/\/bootstrap-it.com\/blog\/?p=333\",\"name\":\"Securing your network connections using OpenVPN - Bootstrap IT\",\"isPartOf\":{\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#website\"},\"datePublished\":\"2019-04-12T20:57:22+00:00\",\"dateModified\":\"2019-04-12T20:57:22+00:00\",\"author\":{\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/ae0fb1d5b3b01558b92b6426d77766ec\"},\"breadcrumb\":{\"@id\":\"https:\/\/bootstrap-it.com\/blog\/?p=333#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/bootstrap-it.com\/blog\/?p=333\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/?p=333#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/bootstrap-it.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Securing your network connections using OpenVPN\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#website\",\"url\":\"https:\/\/bootstrap-it.com\/blog\/\",\"name\":\"Bootstrap IT\",\"description\":\"Learn technology using technology\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/bootstrap-it.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/ae0fb1d5b3b01558b92b6426d77766ec\",\"name\":\"dbclin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a93785d437350478a7f1dfcbec58d26bc28e0124e405179acbe1b4325c09f90a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a93785d437350478a7f1dfcbec58d26bc28e0124e405179acbe1b4325c09f90a?s=96&d=mm&r=g\",\"caption\":\"dbclin\"},\"sameAs\":[\"http:\/\/bootstrap-it.com\/\",\"dbclinton\",\"https:\/\/twitter.com\/davidbclinton\"],\"url\":\"https:\/\/bootstrap-it.com\/blog\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Securing your network connections using OpenVPN - Bootstrap IT","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bootstrap-it.com\/blog\/?p=333","og_locale":"en_US","og_type":"article","og_title":"Securing your network connections using OpenVPN - Bootstrap IT","og_description":"This article, which also appears on my Medium account, is excerpted from chapter 10 of my Manning book, Linux in Action. Besides the book, you can also work through\u00a0Linux in Motion\u200a\u2014\u200aa hybrid course made up of more than two hours&hellip; Continue Reading &rarr;","og_url":"https:\/\/bootstrap-it.com\/blog\/?p=333","og_site_name":"Bootstrap IT","article_published_time":"2019-04-12T20:57:22+00:00","og_image":[{"url":"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*G4AiguIz4CU9i4Kzk0yz8w.png"}],"author":"dbclin","twitter_card":"summary_large_image","twitter_creator":"@davidbclinton","twitter_misc":{"Written by":"dbclin","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/bootstrap-it.com\/blog\/?p=333","url":"https:\/\/bootstrap-it.com\/blog\/?p=333","name":"Securing your network connections using OpenVPN - Bootstrap IT","isPartOf":{"@id":"https:\/\/bootstrap-it.com\/blog\/#website"},"datePublished":"2019-04-12T20:57:22+00:00","dateModified":"2019-04-12T20:57:22+00:00","author":{"@id":"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/ae0fb1d5b3b01558b92b6426d77766ec"},"breadcrumb":{"@id":"https:\/\/bootstrap-it.com\/blog\/?p=333#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bootstrap-it.com\/blog\/?p=333"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/bootstrap-it.com\/blog\/?p=333#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bootstrap-it.com\/blog"},{"@type":"ListItem","position":2,"name":"Securing your network connections using OpenVPN"}]},{"@type":"WebSite","@id":"https:\/\/bootstrap-it.com\/blog\/#website","url":"https:\/\/bootstrap-it.com\/blog\/","name":"Bootstrap IT","description":"Learn technology using technology","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bootstrap-it.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/ae0fb1d5b3b01558b92b6426d77766ec","name":"dbclin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bootstrap-it.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a93785d437350478a7f1dfcbec58d26bc28e0124e405179acbe1b4325c09f90a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a93785d437350478a7f1dfcbec58d26bc28e0124e405179acbe1b4325c09f90a?s=96&d=mm&r=g","caption":"dbclin"},"sameAs":["http:\/\/bootstrap-it.com\/","dbclinton","https:\/\/twitter.com\/davidbclinton"],"url":"https:\/\/bootstrap-it.com\/blog\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=333"}],"version-history":[{"count":1,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/333\/revisions"}],"predecessor-version":[{"id":334,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/333\/revisions\/334"}],"wp:attachment":[{"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bootstrap-it.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}