{"id":2332,"date":"2016-05-02T15:19:49","date_gmt":"2016-05-02T12:19:49","guid":{"rendered":"https:\/\/upcloud.com\/global\/us\/resources\/tutorials\/openvpn-access-server\/"},"modified":"2016-05-02T15:19:49","modified_gmt":"2016-05-02T12:19:49","slug":"openvpn-access-server","status":"publish","type":"tutorial","link":"https:\/\/upcloud.com\/global\/resources\/tutorials\/openvpn-access-server\/","title":{"rendered":"How to install OpenVPN Access Server in the cloud"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A virtual private network or VPN for short is a convenient way of setting up a secure connection to another networked host. OpenVPN Access Server is open-source software that implements VPN techniques through custom security protocols. VPN connections can be essential for development environments, allow secure browsing over public WiFi, or provide an anchor point for devices for which a static IP address&nbsp;might not be possible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OpenVPN clients can be installed on Windows, Mac and Linux as well as Android and iOS while the OpenVPN Access Server (AS) is available for most Linux distributions. This introductory guide to OpenVPN goes through the steps for setting up and configuring your personal Access Server, and how to connect to it.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/signup.upcloud.com\/\">Try UpCloud for free!<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Installing OpenVPN&nbsp;Access Server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">OpenVPN AS supports multiple configurations such as secure remote access to an internal network and private cloud network resources with fine-grained access control. The OpenVPN AS setup consists of three main components:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Access Server is the underlying component that does all of the background work like routing, tunnelling and encryption.<\/li>\n\n\n\n<li>Admin Web Interface makes server management simple through an easy-to-use&nbsp;control panel.<\/li>\n\n\n\n<li>Connect client, which can be downloaded directly from the Access Server, allows login through the AS web portal.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The server software is available for a variety of Linux distributions and versions. You can check out the OpenVPN Access Server&nbsp;<a rel=\"noopener\" href=\"https:\/\/openvpn.net\/index.php\/access-server\/download-openvpn-as-sw.html\" target=\"_blank\">Software Packages page<\/a>&nbsp;or click the links below to find the correct software for your system.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image\"><a href=\"https:\/\/openvpn.net\/index.php\/access-server\/download-openvpn-as-sw\/113.html?osfamily=RedHat\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/redhat-2.png\" alt=\"redhat\" class=\"wp-image-1864\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image\"><a href=\"https:\/\/openvpn.net\/index.php\/access-server\/download-openvpn-as-sw\/113.html?osfamily=CentOS\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/centos-2.png\" alt=\"centos\" class=\"wp-image-1866\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image\"><a href=\"https:\/\/openvpn.net\/index.php\/access-server\/download-openvpn-as-sw\/113.html?osfamily=Ubuntu\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/ubuntu-2.png\" alt=\"ubuntu\" class=\"wp-image-1867\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image\"><a href=\"https:\/\/openvpn.net\/index.php\/access-server\/download-openvpn-as-sw\/113.html?osfamily=Fedora\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/fedora-2.png\" alt=\"fedora\" class=\"wp-image-1865\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image\"><a href=\"https:\/\/openvpn.net\/index.php\/access-server\/download-openvpn-as-sw\/113.html?osfamily=Debian\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/debian-2.png\" alt=\"debian\" class=\"wp-image-1868\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image\"><a href=\"https:\/\/openvpn.net\/index.php\/access-server\/download-openvpn-as-sw\/113.html?osfamily=openSUSE\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/opensuse-2.png\" alt=\"opensuse\" class=\"wp-image-1869\" \/><\/a><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Getting the Access Server installed is simple, download the appropriate package for your system and then use a package manager to install it. The installation process will set up\u00a0a default configuration, which allows a quick and easy way to get a server running.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once the installation is complete, you will see an output similar to the example below. You can then continue ahead with configuring your new VPN server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">The Access Server has been successfully installed in \/usr\/local\/openvpn_as\nConfiguration log file has been written to \/usr\/local\/openvpn_as\/init.log\nPlease enter \"passwd openvpn\" to set the initial\nadministrative password, then login as \"openvpn\" to continue\nconfiguration here: https:\/\/public_ip:943\/admin\nTo reconfigure manually, use the \/usr\/local\/openvpn_as\/bin\/ovpn-init tool.<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring the Access Server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As mentioned towards the end of the installation output, you will need to set a password for the default user to log into the AS. Set a new password for the user <em>openvpn<\/em> with the command underneath. Make sure the password is secure as the control panel&nbsp;is accessible from the public internet by default.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo passwd openvpn<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With the password set, open the OpenVPN Access Server admin panel at the address specified by the installation output.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/<span style=\"color: #ff0000;\">public_ip<\/span>:943\/admin<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When opening the page for the first time, you will see a warning that your connection is not secure. This notice is normal as your web browser does not trust the OpenVPN self-signed SSL certificate by default. You will need to bypass the warning or add an exception on your web browser to continue to the login screen.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/ssl_sercurity_warning.png\" alt=\"ssl_sercurity_warning\" class=\"wp-image-1883\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Log in with the username <em>openvpn<\/em> and the password you assigned. Once in, you will see the OpenVPN status page similar to the image below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the Status Overview, you can find a summary of the server settings and a start\/stop button to turn the VPN server on or off. At the right side panel, is an <i>At-a-glance<\/i> server and connections status.&nbsp;The OpenVPN Access Server allows two concurrent users for free.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/status_overview.png\" alt=\"status_overview\" class=\"wp-image-1875\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">User Management<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once logged in, open the&nbsp;<em>User Permissions<\/em>&nbsp;tab under <em>User Management<\/em>.&nbsp;OpenVPN AS uses the same account credentials as the Linux server it is hosted on, this allows access control based on the user and group permissions defined in the control panel.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/adding_user.png\" alt=\"adding_user\" class=\"wp-image-1885\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To make connecting and logging in easier, you should add your username to the <em>User Permissions<\/em>&nbsp;table.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Type your username in the <em>New Username<\/em>&nbsp;field, select the admin permissions and auto-login if you wish, then press the&nbsp;<em>Save Settings<\/em>&nbsp;button.<\/li>\n\n\n\n<li>After making changes to the OpenVPN&nbsp;AS, restart the server to apply the new configuration by pressing the <em>Update Running Server<\/em>&nbsp;button.<\/li>\n\n\n\n<li>You can then log out from the control panel with the link at the top right corner, and back in again with your username and password.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For improved security, you might wish to lock the default user account; this can be done with the <em>passwd<\/em>&nbsp;terminal command shown below using the <em>-l<\/em> parameter. The same command with parameter <em>-u<\/em> will unlock the account later if needed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">passwd openvpn -l<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also control user-specific IP address settings under User Permissions by clicking the Show -link to open the advanced options. These settings allow you to assign a static IP address to each user, choose between NAT and routing, define the networks the users should have access to, configure a VPN Gateway, or set up DMZ addresses that allow connections to the client through the public IP of the VPN server.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/user_ip_settings.png\" alt=\"user_ip_settings\" class=\"wp-image-1876\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If you are possibly&nbsp;going to have more than a couple of users connecting to the VPN, you might wish to define the permissions on the group level. Create a user group on your cloud server and add the same group name to the <em>Group Permissions<\/em> list, you can then give access to users directly from your server terminal, adding them to the authorised&nbsp;user group, without needing to add every user manually in the web admin panel.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Server Network Settings<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The IP settings can be configured in the <em>Server Network Settings<\/em> under the <em>Configurations<\/em>&nbsp;-menu. By default, the AS listens for incoming connections on the first network interface, but if you have multiple public IP addresses, it is possible to select between the interfaces or to listen to all of them.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the VPN Server settings, you will find the hostname, IP addresses and protocols, as well as the port numbers all easily configured straight from the control panel.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/server_network_settings-1.png\" alt=\"-\" class=\"wp-image-1887\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If you have a valid domain name configured for your server, you can set the hostname to the <em>Hostname or IP Address<\/em> -field to allow the AS to validate the configuration in the <em>Web Server<\/em> -settings. The hostname also sets the server address in the AS-generated profiles. Keep it set to the IP address the server is listening to if you do not have a DNS record pointing to the server\u2019s IP.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next are the&nbsp;IP address settings for the&nbsp;Admin Web control panel and port selection. Be careful when making changes to the admin IPs not to lock yourself out from the admin panel by changing the IP to something unreachable.&nbsp;In such a case, it is possible to reconfigure the AS manually at your cloud server side using the <em>\/usr\/local\/openvpn_as\/bin\/ovpn-init<\/em>&nbsp;tool as mentioned in the installation output.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced VPN<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">With the basic configuration settings, go to the Advanced VPN settings and scroll down to the bottom of the page. Here you will find the Additional OpenVPN Config Directives that allow you to specify any&nbsp;additional server and client options.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/additional_config_directives.png\" alt=\"Additional Config Directives\" class=\"wp-image-3528\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To improve the server-client encryption, include the following&nbsp;cypher and authentication options in both directives as shown above and then click the Save Settings button.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cipher AES-256-CBC\nauth SHA256<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Remember to reload the server with the prompt at the top of the page as well.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Connecting to the&nbsp;Access Server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For Mac and Windows users, the easiest way to set up a&nbsp;VPN client is to use OpenVPN Connect. It can be installed directly from your Access Server&nbsp;and allows connecting to the VPN by logging in through the web portal. Linux users should use the OpenVPN client available through their system package manager.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the web connection login page on your browser. By default, the connection page can be found at port 943 of your cloud server. You can use either the public IP address or domain name if you have one configured. Note that the connection needs to use HTTPS.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/<span style=\"color: #ff0000;\">server_ip_or_domain<\/span>:943<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Opening the address&nbsp;will show a warning that your connection is not trusted. Acknowledge the warning and proceed to sign in with your username and password.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/logging_in.png\" alt=\"logging_in\" class=\"wp-image-1878\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Mac and Windows<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After logging in, click the link to continue. It will start a&nbsp;download for the Connect -client.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/connecting.png\" alt=\"connecting\" class=\"wp-image-1879\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Install the client software, while keeping the OpenVPN connection page open. Follow the instructions in the installation wizard, and allow the application to connect to an untrusted SSL certificate when asked.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When the installation is complete, the client will automatically connect to the VPN and the login page will update to show the connection details. You can close the browser tab without interrupting the VPN,&nbsp;but it can be helpful for disconnecting from the Access Server.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/vpn_connected.png\" alt=\"vpn_connected\" class=\"wp-image-1891\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Linux<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When logged in, you will be greeted by a list of connection options and a profile download shortcut, click the <em>Yourself (user-locked profile)<\/em>&nbsp;link to download your OpenVPN profile.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/image2.jpg\" alt=\"download_config\" class=\"wp-image-1881\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Save the file anywhere you can find it later, e.g. in your <em>~\/<\/em>&nbsp;home directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OpenVPN client for most distributions can be installed from the standard repositories.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Debian and Ubuntu\nsudo apt-get install openvpn\n# CentOS\nsudo yum install openvpn<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That is all that is needed. You can then connect to the Access Server with the command below where the <em>~\/client.ovpn<\/em> is your profile saved in your home directory. Enter your username and password when prompted.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo openvpn --config ~\/client.ovpn<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When the VPN is up and running, you will see an output message&nbsp;like the one below, a timestamp and a confirmation that the connection was successful.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Tue Apr 26 04:17:24 2016 Initialization Sequence Completed<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Keep the terminal open while you wish to remain connected to the OpenVPN server. You can disconnect at any time by stopping the client with <em>Ctrl+c<\/em> or by closing the terminal window.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing your connection<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">With the VPN connection up and running, you should check that everything is working as expected. First, make sure you have access to the internet. If that works, you should test where you are connecting. Below are some easy ways to verify that your connection is being routed through the OpenVPN Access Server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Your IP to the internet<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When connected to a VPN, your network traffic first goes through the VPN server before heading to its real destination. For anyone else on the internet, it seems that your requests originate from your AS. Many online services can show the source address of your connection. One such is a Google search for \u201cmy IP\u201d, you can use the link below for a shortcut.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.google.com\/search?q=my+ip\" target=\"_blank\" rel=\"noopener\">https:\/\/www.google.com\/search?q=my+ip<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the IP address displayed above the search results matches that of your server\u2019s public IP address, the VPN is routing correctly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using the private IP addresses<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">UpCloud servers have a private IP address only accessible to the cloud servers on your account. While connected through a VPN, your client is essentially linked to the server\u2019s private network, but only on that host. As such, you should be able to reach the VPN server\u2019s private IP address, which is listed in your <a rel=\"noopener\" href=\"https:\/\/hub.upcloud.com\/networks\/private\" target=\"_blank\">UpCloud Control Panel<\/a> under the <em>Network<\/em>&nbsp;menu and <em>Private Network<\/em>&nbsp;tab.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can test the connections for example with the <em>ping<\/em>&nbsp;command in your client computer\u2019s terminal or command prompt.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ping <span style=\"color: #ff0000;\">private_ip<\/span><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you get a reply, your OpenVPN Access Server is working and you can use the private IP address on your VPN server for other connections.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note that CentOS and other Red Hat variants might block ICMP requests at their firewall by default, in such case, you can test the routing with SSH instead.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Having your personal VPN server can provide many advantages from improved security and privacy to the convenience of a fixed IP or a local area network between computers on different continents. OpenVPN Access Server is capable of much more than could be explained in a simple start-up guide. If you wish to learn more about the various configuration options, check out their <a href=\"https:\/\/openvpn.net\/images\/pdf\/OpenVPN_Access_Server_Sysadmin_Guide_Rev.pdf\" target=\"_blank\" rel=\"noopener\">Sysadmin Guide to OpenVPN AS<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note that when using a VPN to connect to your cloud server, the VPN does not provide anonymity and any network traffic must comply with&nbsp;<a href=\"https:\/\/upcloud.com\/global\/terms-of-service\/\">UpCloud Terms of Service and Acceptable Use Policy<\/a>.<\/p>\n","protected":false},"author":3,"featured_media":24587,"comment_status":"open","ping_status":"closed","template":"","community-category":[223,259],"class_list":["post-2332","tutorial","type-tutorial","status-publish","has-post-thumbnail","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/types\/tutorial"}],"author":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/comments?post=2332"}],"version-history":[{"count":0,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2332\/revisions"}],"wp:attachment":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/media?parent=2332"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/community-category?post=2332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}