De software voor OpenSUSE 11.3 is te vinden op: https://openvpn.net/index.php/access-server/download-openvpn-as-sw.html
Het beta 2.5 programma heeft een Leap 42.3 (64 bit) versie: https://docs.openvpn.net/openvpn-access-server-beta-program/
Om dit verkeer via een “aparte” website (openvpn.famtenhoopen.nl) te laten verlopen; maak eerste in DNS een A-Record aan voor openvpn verwijzend naar het ip adres die we krijgen van de provider (Ziggo).
Download de software en installeer het via de packagemanager (YaST of zypper install openvpn-as of …).
Let op: openvpn-as niet openvpn!!
schuurpc:~ # rpm -ql openvpn-as /usr/local/openvpn_as/bin /usr/local/openvpn_as/bin/_ovpn-init /usr/local/openvpn_as/bin/ovpn-init /usr/local/openvpn_as/bin/python /usr/local/openvpn_as/bin/sqlite3 /usr/local/openvpn_as/doc ... ... ... ... /usr/local/openvpn_as/scripts/ucarp_active /usr/local/openvpn_as/scripts/ucarp_standby /usr/local/openvpn_as/scripts/update_as_conf /usr/local/openvpn_as/scripts/update_va_ver /usr/local/openvpn_as/scripts/userdba /usr/local/openvpn_as/scripts/web /usr/local/openvpn_as/tmp /var/tmp/openvpn_as schuurpc:~ #
Ongeveer 2400 bestanden. OpenVPN – AS wordt geinstalleerd in /usr/local/openvpn_as. Ga naar de bin directory
schuurpc:~ # cd /usr/local/openvpn_as/bin schuurpc:/usr/local/openvpn_as/bin # ls -l total 212 -rwxr-xr-x 1 root root 35537 Jan 4 17:36 _ovpn-init -rwxr-xr-x 1 root root 463 Jan 4 17:36 ovpn-init -rwxr-xr-x 1 root root 6352 Jan 4 17:36 python -rwxr-xr-x 1 root root 164896 Jan 4 17:36 sqlite3 schuurpc:/usr/local/openvpn_as/bin #
En voer uit:
schuurpc:/usr/local/openvpn_as/bin # ./ovpn-init
Dit is de installatie, een behoorlijk vraag en antwoord spelletje 🙂 maar we zijn tevreden met bijna alle default antwoorden.
Detected an existing OpenVPN-AS configuration.
Continuing will delete this configuration and restart from scratch.
Please enter 'DELETE' to delete existing configuration: DELETE
Ik had het eerder gedaan, dus nog ff de oude opruimen
Stopping openvpnas daemon... OpenVPN Access Server Initial Configuration Tool ------------------------------------------------------ OpenVPN Access Server End User License Agreement (OpenVPN-AS EULA) 1. Copyright Notice: OpenVPN Access Server License; Copyright (c) 2009-2017 OpenVPN, Inc.. All rights reserved. "OpenVPN" is a trademark of OpenVPN, Inc. 2. Redistribution of OpenVPN Access Server binary forms and related documents, ... ... veel licentie voorwaarden verwijderd ... ... credits or price adjustments toward any licenses that have already been issued. Furthermore, no discounts will be given for license maintenance renewals unless this is specified in your contract with OpenVPN Inc. Please enter 'yes' to indicate your agreement [no]: yes Once you provide a few initial configuration settings, OpenVPN Access Server can be configured by accessing its Admin Web UI using your Web browser. Will this be the primary Access Server node? (enter 'no' to configure as a backup or standby node) > Press ENTER for default [yes]: yes Please specify the network interface and IP address to be used by the Admin Web UI: (1) all interfaces: 0.0.0.0 (2) eth1: 213.46.67.252 (3) eth0: 10.0.0.150 Please enter the option number from the list above (1-3). > Press Enter for default [2]: 1
Onderhoud via de Admin WebUI vanuit het eigen netwerk (achter de firewall) en via Internet.
Please specify the port number for the Admin Web UI.
> Press ENTER for default [943]: 943
Dit is de poort voor de Admin WebUI. Je moet deze poort in de firewall dus open te zetten anders kun je er vanaf het Internet niet bij.
Please specify the TCP port number for the OpenVPN Daemon
> Press ENTER for default [443]: 444
Goed opletten hier. De default is 443 echter als je ook een webserver hebt lopen met 1 of meer beveiligde sites (https://) dan luistert de webserver ook naar deze poort. In dat geval kun je poort 443 niet gebruiken maar moet je een andere nemen. Ik heb een webserver lopen met beveiligde sites en heb daarom gekozen voor poort 444 (en open gezet in de firewall).
Heb je geen webserver lopen (of andere programma’s/deamons) dan kun je met een gerust hard poort 443 kiezen. Deze, 443, moet je dus (wel) open zetten in de firewall!
Should client traffic be routed by default through the VPN?
> Press ENTER for default [yes]: yes
Alles door VPN, we doen alsof we op het intranet zitten.
Should client DNS traffic be routed by default through the VPN?
> Press ENTER for default [yes]: yes
Alles door VPN, we doen alsof we op het intranet zitten.
Use local authentication via internal DB? > Press ENTER for default [yes]: yes Private subnets detected: ['10.0.0.0/24'] Should private subnets be accessible to clients by default? > Press ENTER for default [yes]: yes To initially login to the Admin Web UI, you must use a username and password that successfully authenticates you with the host UNIX system (you can later modify the settings so that RADIUS or LDAP is used for authentication instead). You can login to the Admin Web UI as "openvpn" or specify a different user account to use for this purpose. Do you wish to login to the Admin UI as "openvpn"? > Press ENTER for default [yes]: yes > Please specify your OpenVPN-AS license key (or leave blank to specify later): <blank>
We gebruiken de community versie. Deze geeft de mogelijkheid voor 2 “gratis” users. Daar zijn we nu wel tevreden mee.
Initializing OpenVPN... Adding new user login... useradd -s /sbin/nologin "openvpn"
Hier wordt een nieuwe user aangemaakt in /etc/passwd: openvpn
Writing as configuration file... Perform sa init... Wiping any previous userdb... Creating default profile... Modifying default profile... Adding new user to userdb... Modifying new user as superuser in userdb... Getting hostname... Hostname: schuurpc Preparing web certificates... Getting web user account... Adding web group account... Adding web group... Adjusting license directory ownership... Initializing confdb... Generating init scripts... Generating PAM config... Generating init scripts auto command... Error: Could not execute command to generate startup/shutdown scripts
Let op de “Error”: Geen idee wat er precies bedoeld wordt. De (ouderwetse) /etc/init.d scripts worden normaal geinstalleerd. Er worden geen systemd .service files gebruikt.
schuurpc:/usr/local/openvpn_as/bin # ls -l /etc/init.d/openvpnas -rwxr-xr-x 1 root root 2624 Jan 28 16:22 /etc/init.d/openvpnas schuurpc:/usr/local/openvpn_as/bin #
Het init script heeft geen status:
schuurpc:/usr/local/openvpn_as/bin # /etc/init.d/openvpnas Usage: openvpnas start|stop|restart schuurpc:/usr/local/openvpn_as/bin # /etc/init.d/openvpnas stop redirecting to systemctl stop openvpnas.service schuurpc:/usr/local/openvpn_as/bin # /etc/init.d/openvpnas status Usage: openvpnas start|stop|restart ● openvpnas.service - SYSV: Startup script for the openvpnas daemon Loaded: loaded (/etc/init.d/openvpnas; bad; vendor preset: disabled) Active: inactive (dead) Docs: man:systemd-sysv-generator(8) schuurpc:/usr/local/openvpn_as/bin #
Maar systemd pakt het wel lekker op 🙂
Tijdens de installatie is een user (openvpn) aangemaakt. Deze moet nog een password hebben. Via deze user kun je niet op de server inloggen, het is alleen user-id voor een gebruiker van OpenVPN – AS. Zet het password voor deze user en onthoud haar goed 🙂
schuurpc:/usr/local/openvpn_as/bin # passwd openvpn New password: Retype new password: passwd: password updated successfully schuurpc:/usr/local/openvpn_as/bin #
Veilige site via https
We gaan eerste een website bouwen voor http://openvpn.famtenhoopen.nl Deze site wordt gerund door apache en is er alleen maar voor om het leven makkelijk te maken.
We gaan namelijk een certificaat aanvragen bij Lets Encrypt (zie voor de achtergrond deze buil). Deze is er helemaal op ingericht om van een normale http website een https website te maken. In ons geval is die http website prima maar https moet straks opgepakt worden door OpenVPN – AS. OpenVPN – AS luistert op poort 443 (dit is de default! Heb je al wel https sites op je systeem dan heb je tijdens de installatie een andere poort opgegeven [444]).
Het enige wat we moeten doen is straks de certificaten van Lets Encrypt voor openvpn.famtenhoopen.nl “in” de OpenVPN – AS server worden gekopieerd. Er is dus straks een site http://openvpn.famtenhoopen.nl (die geserviced wordt door de webserver).
Website http://openvpn.famtenhoopen.nl opzetten
Bouw een nieuwe website in /tenhoopen/www/openvpnfamtenhoopen. Vervolgens alles opruimen wat niet nodig is en permissie (owner=wwwrun; group=www) goed zetten.
schuurpc:/tenhoopen/www # cp -r famtenhoopen openvpnfamtenhoopen schuurpc:/tenhoopen/www # cd open* schuurpc:/tenhoopen/www/openvpnfamtenhoopen # ls cgi-bin cops-1.0.1 dolibarr exchange password praktijkdekorenbloem solar solardashboard .well-known wordpress schuurpc:/tenhoopen/www/openvpnfamtenhoopen # rm -fr cops* dolibarr exchange password praktijkdekorenbloem solar solardashboard wordpress schuurpc:/tenhoopen/www/openvpnfamtenhoopen # mkdir htdocs schuurpc:/tenhoopen/www/openvpnfamtenhoopen # chown -R wwwrun . * schuurpc:/tenhoopen/www/openvpnfamtenhoopen # chgrp -R www . * schuurpc:/tenhoopen/www/openvpnfamtenhoopen # ls -l total 16 drwxr-xr-x 2 wwwrun www 4096 10 feb 20:10 cgi-bin drwxr-xr-x 2 wwwrun www 4096 10 feb 20:15 htdocs drwxr-xr-x 2 wwwrun www 4096 10 feb 20:10 .well-known schuurpc:/tenhoopen/www/openvpnfamtenhoopen # rm .well-known/* schuurpc:/tenhoopen/www/openvpnfamtenhoopen #
Nu apache configureren, eerst een conf.d directory maken :
schuurpc:/etc/apache2 # cp -r conf.d.tenhoopen conf.d.openvpnfamtenhoopen schuurpc:/etc/apache2 # cd conf.d.openvpnfamtenhoopen schuurpc:/etc/apache2/conf.d.openvpnfamtenhoopen # ls awstats.conf backup.conf cops.conf dolibarr.conf exchange.conf letsencrypt.conf media.conf OLD oldblog.conf owncloud.conf phpMyAdmin.conf praktijkdekorenbloem.conf solar.conf wordpress.conf zm.conf schuurpc:/etc/apache2/conf.d.openvpnfamtenhoopen # rm -fr awstats.conf backup.conf cops.conf dolibarr.conf exchange.conf media.conf OLD oldblog.conf owncloud.conf phpMyAdmin.conf praktijkdekorenbloem.conf solar.conf wordpress.conf zm.conf schuurpc:/etc/apache2/conf.d.openvpnfamtenhoopen # ls letsencrypt.conf schuurpc:/etc/apache2/conf.d.openvpnfamtenhoopen #
De conf file van letsencrypt:
schuurpc:/etc/apache2/conf.d.openvpnfamtenhoopen # cat letsencrypt.conf # # letsencrypt # Alias /.well-known "/tenhoopen/www/openvpnfamtenhoopen/.well-known" # <Directory "/tenhoopen/www/openvpnfamtenhoopen/.well-known"> Options +FollowSymLinks +Indexes AllowOverride None #Order allow,deny #Allow from all Require all granted </Directory> schuurpc:/etc/apache2/conf.d.openvpnfamtenhoopen #
Nu de virtual host maken. In /etc/apache2/vhosts.d/ip-based_vhosts.conf het volgende toevoegen:
############################################################## # # http://openvpn.famtenhoopen.nl # ############################################################## <VirtualHost *:80> DocumentRoot /tenhoopen/www/openvpnfamtenhoopen/htdocs ServerName openvpn.famtenhoopen.nl ServerAdmin arjan@famtenhoopen.nl <Directory /tenhoopen/www/openvpnfamtenhoopen/htdocs> Options +FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog /var/log/apache2/openvpnfamtenhoopen/error_log CustomLog /var/log/apache2/openvpnfamtenhoopen/access_log combined HostnameLookups Off UseCanonicalName Off IncludeOptional /etc/apache2/conf.d.openvpnfamtenhoopen/*.conf </VirtualHost>
Nu de directory /var/log/apache2/openvpnfamtenhoopen maken met de juiste permissies en apache de nieuwe config laten laden:
schuurpc:/var/log/apache2 # systemctl reload apache2 schuurpc:/var/log/apache2 # echo Hello, this is the end of the Rainbow ... however the Gold is on the other side ... sorry for the inconvenience. > /tenhoopen/www/openvpnfamtenhoopen/htdocs/index.html schuurpc:/var/log/apache2 #
Met de browser naar http://openvpn.famtenhoopen.nl .. 🙂
Certificaten maken met Lets Encrypt
We hebben nu http website die Lets Encrypt als basis kan nemen om er https van te maken (maar het is ons te doen om de certificaten). We gaan een certificaat aanvragen (zie voor de achtergrond deze buil):
schuurpc:/var/log/apache2 # cd /tenhoopen/git/letsencrypt schuurpc:/tenhoopen/git/letsencrypt # ./letsencrypt-auto certonly --webroot -w /tenhoopen/www/openvpnfamtenhoopen -d openvpn.famtenhoopen.nl --email arjan.ten.hoopen@zonnet.nl Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator webroot, Installer None Obtaining a new certificate Performing the following challenges: http-01 challenge for openvpn.famtenhoopen.nl Using the webroot path /tenhoopen/www/openvpnfamtenhoopen for all unmatched domains. Waiting for verification... Cleaning up challenges IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/openvpn.famtenhoopen.nl/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/openvpn.famtenhoopen.nl/privkey.pem Your cert will expire on 2018-05-12. To obtain a new or tweaked version of this certificate in the future, simply run letsencrypt-auto again. To non-interactively renew *all* of your certificates, run "letsencrypt-auto renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le schuurpc:/tenhoopen/git/letsencrypt #
We hebben dus nu alle certificaten in de directory /etc/letsencrypt/live/openvpn.famtenhoopen.nl. De certificaten hebben een beperkte levensduur (3 maanden) dus zorg er ook nog even voor dat je op gezette tijdstippen (in de cron) /tenhoopen/git/letsencrypt/letsencrypt-auto uitvoert om het certificaat te vernieuwen.
Op de juite plek zetten in OpenVPN AS
De certificaten staat in /usr/local/openvpn_as/etc/web-ssl/ In de documentatie staat hoe je via de Admin UI of via de backend certificaten plaats. Maar dit vereist ouderwets handwerk, en daar willen we van af. Voor de zekerheid maken we van de web-ssl directory nog wel even een kopie naar web-sslORG.
Een andere vrolijke knutselaar heeft hier ook mee zitten worstelen, je vindt zijn opsomming hier. Zijn script houden we maar aan; beter goed gejat, dan slecht bedacht 🙂
/etc/init.d/openvpnas stop /usr/local/openvpn_as/scripts/confdba -mk cs.ca_bundle -v "`cat /etc/letsencrypt/live/DOMAIN.TLD/fullchain.pem`" /usr/local/openvpn_as/scripts/confdba -mk cs.priv_key -v "`cat /etc/letsencrypt/live/DOMAIN.TLD/privkey.pem`" > /dev/null /usr/local/openvpn_as/scripts/confdba -mk cs.cert -v "`cat /etc/letsencrypt/live/DOMAIN.TLD/cert.pem`" /etc/init.d/openvpnas start
Nog een beetje opleuken naar moderne en onze tijden:
/usr/bin/systemctl stop openvpnas /usr/local/openvpn_as/scripts/confdba -mk cs.ca_bundle -v "`cat /etc/letsencrypt/live/openvpn.famtenhoopen.nl/fullchain.pem`" /usr/local/openvpn_as/scripts/confdba -mk cs.priv_key -v "`cat /etc/letsencrypt/live/openvpn.famtenhoopen.nl/privkey.pem`" > /dev/null /usr/local/openvpn_as/scripts/confdba -mk cs.cert -v "`cat /etc/letsencrypt/live/openvpn.famtenhoopen.nl/cert.pem`" /usr/bin/systemctl start openvpnas
Bovenstaande commando’s moet je nog samenvatten in een scriptje en (in de cron) uitvoeren op gezette tijden (levensduur van certificaat is 3 maanden). Speciale aandacht aan die “> /dev/null”. Als je die weglaat komt je private key op je scherm (of in de mail als je het door cron laat uitvoeren). Dit wil je niet.
De Admin WebUI is te benaderen via: https://openvpn.famtenhoopen.nl:943/admin
Het normale User WebUI is te benaderen via: https://openvpn.famtenhoopen.nl:943
Controle
Login op het Admin UI als openvpn met het password dat je goed onthouden hebt. Voer nu uit:
Configuration ⇒ Network Settings
- Zet hier de Hostname naar openvpn.famtenhoopen.nl
- Toets Save Settings
- Toets Update Running Server
Configuration ⇒ Web Server
- Controleer of hier openvpn.famtenhoopen.nl ziet met de bijbehorende certificaten.
De server is nu klaar voor gebruik. Verbinden van een client met deze server staat in in deze buil.