technische_naslag:sid:roer
Verschillen
Dit geeft de verschillen weer tussen de geselecteerde revisie en de huidige revisie van de pagina.
| Beide kanten vorige revisieVorige revisieVolgende revisie | Vorige revisie | ||
| technische_naslag:sid:roer [2025/05/26 11:38] – OpenVPN michelle | technische_naslag:sid:roer [2026/06/04 20:33] (huidige) – Layout verbeteringen michelle | ||
|---|---|---|---|
| Regel 1: | Regel 1: | ||
| - | ===== Introductie ===== | + | ====== Introductie |
| Al jaren draai ik thuis een servertje, vroeger was dat nogal uitgebreid met diverse netwerk-segmenten waarvoor 't ding router was en had ik mijn eigen mailserver en wat niet meer draaien. Tegenwoordig is het vooral een veredelde NAS, maar wel op een echte server die energiezuinig is met z'n SSD's en een echte distributie erop: | Al jaren draai ik thuis een servertje, vroeger was dat nogal uitgebreid met diverse netwerk-segmenten waarvoor 't ding router was en had ik mijn eigen mailserver en wat niet meer draaien. Tegenwoordig is het vooral een veredelde NAS, maar wel op een echte server die energiezuinig is met z'n SSD's en een echte distributie erop: | ||
| Regel 5: | Regel 5: | ||
| * Hardware: HP Proliant Microserver Gen10+ | * Hardware: HP Proliant Microserver Gen10+ | ||
| * Storage: 2x Western Digital Red 2TB SSD | * Storage: 2x Western Digital Red 2TB SSD | ||
| - | * OS: Debian GNU/ | + | * OS: Debian GNU/ |
| - | ===== Installatie en Configuratie ===== | + | ====== Installatie en Configuratie |
| - | ==== Webserver: Apache2 ==== | + | ===== Webserver: Apache2 |
| Met Let's Encrypt certificaat: | Met Let's Encrypt certificaat: | ||
| Regel 15: | Regel 15: | ||
| * [[https:// | * [[https:// | ||
| - | ==== OpenVPN ==== | + | ===== OpenVPN |
| - | <code bash> | + | ==== Installeer |
| - | root@roer: | + | |
| - | Welcome to the OpenVPN | + | |
| - | The git repository is available at: https:// | + | |
| - | I need to ask you a few questions before starting the setup. | + | Hiervoor gebruik ik een handig scrippie: [[https:// |
| - | You can leave the default options and just press enter if you are ok with them. | + | Download het geval en maak het executable: |
| - | I need to know the IPv4 address of the network interface you want OpenVPN listening to. | + | <code bash> |
| - | Unless your server is behind NAT, it should be your public IPv4 address. | + | curl -O https://raw.githubusercontent.com/ |
| - | IP address: 192.168.1.2 | + | chmod +x openvpn-install.sh |
| + | </ | ||
| - | It seems this server is behind NAT. What is its public IPv4 address or hostname? | + | Voer het uit en gebruik het meest de defaults: |
| - | We need it for the clients to connect to the server. | + | |
| - | Public IPv4 address or hostname: roer.vlet.net | + | |
| - | Checking | + | <code bash> |
| + | michelle@roer: | ||
| + | [INFO] === OpenVPN Non-Interactive Install === | ||
| + | [INFO] Running in non-interactive mode with the following settings: | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] | ||
| + | [INFO] Setting up official OpenVPN repository... | ||
| + | > apt-get update | ||
| + | > apt-get install -y ca-certificates curl | ||
| + | > mkdir -p / | ||
| + | > curl -fsSL https:// | ||
| + | [INFO] Updating package lists with new repository... | ||
| + | > apt-get update | ||
| + | [INFO] OpenVPN official repository configured | ||
| + | [INFO] Installing OpenVPN and dependencies... | ||
| + | > apt-get install -y openvpn iptables openssl curl ca-certificates tar dnsutils socat | ||
| + | [INFO] Data Channel Offload (DCO) is not available (requires OpenVPN 2.6+ and kernel support) | ||
| + | > mkdir -p / | ||
| + | > curl -fL --retry 5 -o / | ||
| + | [INFO] Verifying Easy-RSA checksum... | ||
| + | > mkdir -p / | ||
| + | > tar xzf / | ||
| + | > rm -f / | ||
| + | [INFO] Initializing PKI... | ||
| + | > ./easyrsa init-pki | ||
| + | [INFO] Building CA... | ||
| + | > ./easyrsa --batch --req-cn=cn_jPf4c13rKvpdCoX7 build-ca nopass | ||
| + | [INFO] Building server certificate... | ||
| + | > ./easyrsa --batch build-server-full server_JtWaiX0iDcYANtAt nopass | ||
| + | > ./easyrsa gen-crl | ||
| + | [INFO] Generating TLS key... | ||
| + | > openvpn --genkey tls-crypt-v2-server / | ||
| + | [INFO] Copying certificates... | ||
| + | > cp pki/ca.crt pki/ | ||
| + | > chmod 644 / | ||
| + | [INFO] Generating server configuration... | ||
| + | > mkdir -p / | ||
| + | > mkdir -p / | ||
| + | [INFO] Enabling IP forwarding... | ||
| + | > mkdir -p / | ||
| + | > sysctl --system | ||
| + | [INFO] Configuring OpenVPN service... | ||
| + | > cp / | ||
| + | > sed -i s|LimitNPROC|# | ||
| + | > sed -i / | ||
| + | > systemctl daemon-reload | ||
| + | > systemctl enable openvpn-server@server | ||
| + | > systemctl restart openvpn-server@server | ||
| + | [INFO] Configuring firewall rules... | ||
| + | > mkdir -p / | ||
| + | > chmod +x / | ||
| + | > chmod +x / | ||
| + | > systemctl daemon-reload | ||
| + | > systemctl enable iptables-openvpn | ||
| + | > systemctl start iptables-openvpn | ||
| + | [INFO] Creating client template... | ||
| + | [INFO] Generating first client certificate... | ||
| + | [INFO] Generating client certificate... | ||
| + | > ./easyrsa --batch build-client-full client nopass | ||
| + | [OK] Client client added and is valid for 3650 days. | ||
| + | > cp / | ||
| + | [OK] The configuration file has been written to / | ||
| + | [INFO] Download the .ovpn file and import it in your OpenVPN client. | ||
| + | [OK] If you want to add more clients, you simply need to run this script another time! | ||
| + | </ | ||
| - | Your host appears to have IPv6 connectivity. | + | ==== Open poort op Fritz!Box firewall ==== |
| - | Do you want to enable IPv6 support (NAT)? [y/n]: y | + | Vervolgens moet ik op mijn **Fritz!Box** wel deze **poort openen** natuurlijk! |
| - | What port do you want OpenVPN to listen to? | + | |
| - | | + | * Protocol: UDP |
| - | 2) Custom | + | |
| - | 3) Random [49152-65535] | + | |
| - | Port choice [1-3]: 1 | + | |
| - | What protocol do you want OpenVPN | + | ==== Configureer |
| - | UDP is faster. Unless it is not available, you shouldn' | + | |
| - | 1) UDP | + | |
| - | 2) TCP | + | |
| - | Protocol [1-2]: 1 | + | |
| - | What DNS resolvers do you want to use with the VPN? | + | Daarna nog wat eigen aanpassingen gedaan aan de server config: |
| - | 1) Current system resolvers (from / | + | |
| - | 2) Self-hosted DNS Resolver (Unbound) | + | |
| - | 3) Cloudflare (Anycast: worldwide) | + | |
| - | 4) Quad9 (Anycast: worldwide) | + | |
| - | 5) Quad9 uncensored (Anycast: worldwide) | + | |
| - | 6) FDN (France) | + | |
| - | 7) DNS.WATCH (Germany) | + | |
| - | 8) OpenDNS (Anycast: worldwide) | + | |
| - | 9) Google (Anycast: worldwide) | + | |
| - | 10) Yandex Basic (Russia) | + | |
| - | 11) AdGuard DNS (Anycast: worldwide) | + | |
| - | 12) NextDNS (Anycast: worldwide) | + | |
| - | 13) Custom | + | |
| - | DNS [1-12]: 1 | + | |
| - | Do you want to use compression? | + | <code bash> |
| - | Enable compression? | + | michelle@roer: |
| + | ##server 10.8.0.0 255.255.255.0 | ||
| + | server 192.168.3.0 255.255.255.0 | ||
| + | push " | ||
| + | push "route 192.168.1.0 255.255.255.0" | ||
| + | ##push " | ||
| + | </code> | ||
| - | Do you want to customize encryption settings? | + | ==== Maak OpenVPN |
| - | Unless you know what you're doing, you should stick with the default parameters provided by the script. | + | |
| - | Note that whatever you choose, all the choices presented in the script are safe. (Unlike | + | |
| - | See https:// | + | |
| - | Customize encryption settings? [y/n]: n | + | <code bash> |
| + | michelle@roer:~/bin$ sudo ./ | ||
| - | Okay, that was all I needed. We are ready to setup your OpenVPN server now. | + | === New Client Setup === |
| - | You will be able to generate a client at the end of the installation. | + | |
| - | Press any key to continue... | + | |
| - | Ophalen:1 http:// | + | |
| - | Geraakt:2 http:// | + | |
| - | Ophalen:3 http:// | + | |
| - | 103 kB opgehaald in 0s (287 kB/s) | + | |
| - | Pakketlijsten worden ingelezen... Klaar | + | |
| - | Pakketlijsten worden ingelezen... Klaar | + | |
| - | Boom van vereisten wordt opgebouwd... Klaar | + | |
| - | De statusinformatie wordt gelezen... Klaar | + | |
| - | ca-certificates is reeds de nieuwste versie (20230311). | + | |
| - | gnupg is reeds de nieuwste versie (2.2.40-1.1). | + | |
| - | gnupg staat ingesteld op handmatig geïnstalleerd. | + | |
| - | 0 opgewaardeerd, | + | |
| - | Pakketlijsten worden ingelezen... Klaar | + | |
| - | Boom van vereisten wordt opgebouwd... Klaar | + | |
| - | De statusinformatie wordt gelezen... Klaar | + | |
| - | iptables is reeds de nieuwste versie (1.8.9-2). | + | |
| - | iptables staat ingesteld op handmatig geïnstalleerd. | + | |
| - | openssl is reeds de nieuwste versie (3.0.16-1~deb12u1). | + | |
| - | openssl staat ingesteld op handmatig geïnstalleerd. | + | |
| - | wget is reeds de nieuwste versie (1.21.3-1+deb12u1). | + | |
| - | ca-certificates is reeds de nieuwste versie (20230311). | + | |
| - | curl is reeds de nieuwste versie (7.88.1-10+deb12u12). | + | |
| - | De volgende extra pakketten zullen geïnstalleerd worden: | + | |
| - | easy-rsa libccid libnl-genl-3-200 libpcsclite1 libpkcs11-helper1 opensc opensc-pkcs11 pcscd | + | |
| - | Voorgestelde pakketten: | + | |
| - | pcmciautils resolvconf openvpn-dco-dkms openvpn-systemd-resolved | + | |
| - | De volgende NIEUWE pakketten zullen geïnstalleerd worden: | + | |
| - | easy-rsa libccid libnl-genl-3-200 libpcsclite1 libpkcs11-helper1 opensc opensc-pkcs11 openvpn pcscd | + | |
| - | 0 opgewaardeerd, | + | |
| - | Er moeten 2.575 kB aan archieven opgehaald worden. | + | |
| - | Na deze bewerking zal er 7.776 kB extra schijfruimte gebruikt worden. | + | |
| - | Ophalen:1 http:// | + | |
| - | Ophalen:2 http:// | + | |
| - | Ophalen:3 http:// | + | |
| - | Ophalen:4 http:// | + | |
| - | Ophalen:5 http:// | + | |
| - | Ophalen:6 http:// | + | |
| - | Ophalen:7 http:// | + | |
| - | Ophalen:8 http:// | + | |
| - | Ophalen:9 http:// | + | |
| - | 2.575 kB opgehaald in 0s (9.244 kB/s) | + | |
| - | Voorconfigureren van pakketten ... | + | |
| - | Voorheen niet geselecteerd pakket libccid wordt geselecteerd. | + | |
| - | (Database wordt ingelezen ... 74274 bestanden en mappen momenteel geïnstalleerd.) | + | |
| - | Uitpakken van .../ | + | |
| - | Bezig met uitpakken van libccid (1.5.2-1) ... | + | |
| - | Voorheen niet geselecteerd pakket libpcsclite1: | + | |
| - | Uitpakken van .../ | + | |
| - | Bezig met uitpakken van libpcsclite1: | + | |
| - | Voorheen niet geselecteerd pakket pcscd wordt geselecteerd. | + | |
| - | Uitpakken van .../ | + | |
| - | Bezig met uitpakken van pcscd (1.9.9-2) ... | + | |
| - | Voorheen niet geselecteerd pakket easy-rsa wordt geselecteerd. | + | |
| - | Uitpakken van .../ | + | |
| - | Bezig met uitpakken van easy-rsa (3.1.0-1) ... | + | |
| - | Voorheen niet geselecteerd pakket libnl-genl-3-200: | + | |
| - | Uitpakken van .../ | + | |
| - | Bezig met uitpakken van libnl-genl-3-200: | + | |
| - | Voorheen niet geselecteerd pakket libpkcs11-helper1: | + | |
| - | Uitpakken van .../ | + | |
| - | Bezig met uitpakken van libpkcs11-helper1: | + | |
| - | Voorheen niet geselecteerd pakket opensc-pkcs11: | + | |
| - | Uitpakken van .../ | + | |
| - | Bezig met uitpakken van opensc-pkcs11: | + | |
| - | Voorheen niet geselecteerd pakket opensc wordt geselecteerd. | + | |
| - | Uitpakken van .../ | + | |
| - | Bezig met uitpakken van opensc (0.23.0-0.3+deb12u2) ... | + | |
| - | Voorheen niet geselecteerd pakket openvpn wordt geselecteerd. | + | |
| - | Uitpakken van .../ | + | |
| - | Bezig met uitpakken van openvpn (2.6.3-1+deb12u3) ... | + | |
| - | Instellen van libccid (1.5.2-1) ... | + | |
| - | Instellen van libpkcs11-helper1: | + | |
| - | Instellen van opensc-pkcs11: | + | |
| - | Instellen van libpcsclite1: | + | |
| - | Instellen van libnl-genl-3-200: | + | |
| - | Instellen van easy-rsa (3.1.0-1) ... | + | |
| - | Instellen van openvpn (2.6.3-1+deb12u3) ... | + | |
| - | Created symlink / | + | |
| - | Instellen van opensc (0.23.0-0.3+deb12u2) ... | + | |
| - | Instellen van pcscd (1.9.9-2) ... | + | |
| - | Created symlink / | + | |
| - | pcscd.service is a disabled or a static unit, not starting it. | + | |
| - | Bezig met afhandelen van triggers voor mailcap (3.70+nmu1) ... | + | |
| - | Bezig met afhandelen van triggers voor libc-bin (2.36-9+deb12u10) ... | + | |
| - | Bezig met afhandelen van triggers voor man-db (2.11.2-2) ... | + | |
| - | Scanning processes... | + | |
| - | Scanning processor microcode... | + | |
| - | Scanning linux images... | + | |
| - | The processor microcode seems to be up-to-date. | + | [INFO] Generating client certificate... |
| + | > ./ | ||
| + | [OK] Client MichelleJanse added and is valid for 3650 days. | ||
| + | > cp / | ||
| - | No services need to be restarted. | + | [OK] The configuration file has been written |
| + | [INFO] Download the .ovpn file and import it in your OpenVPN client. | ||
| + | </ | ||
| - | No containers need to be restarted. | + | En klaar is Kees. Oh nee: **klaar is de oudste dochter van Kees!!** |
| - | No user sessions are running outdated binaries. | + | ====== Hardening ====== |
| - | No VM guests are running outdated hypervisor (qemu) binaries on this host. | + | Nadat de functionaliteit erin zit mag er ook nog wel aan de veiligheid gedaan worden. Want Debian GNU/Linux is out-of-the-box wel aardig in elkaar gestoken maar het kan nog altijd beter! |
| - | --2025-05-26 13: | + | |
| - | Herleiden van github.com (github.com)... 140.82.121.4 | + | |
| - | Verbinding maken met github.com (github.com)|140.82.121.4|: | + | |
| - | HTTP-verzoek | + | |
| - | Locatie: https:// | + | |
| - | --2025-05-26 13: | + | |
| - | Herleiden van objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.109.133, | + | |
| - | Verbinding maken met objects.githubusercontent.com (objects.githubusercontent.com)|185.199.109.133|: | + | |
| - | HTTP-verzoek is verzonden; wachten op antwoord... 200 OK | + | |
| - | Lengte: 68984 (67K) [application/ | + | |
| - | Wordt opgeslagen als: ‘/ | + | |
| - | / | + | ===== Lynis ===== |
| - | 2025-05-26 13:38:08 (9,07 MB/s) - '‘/root/ | + | Een tooltje om de hardening van het systeem te scannen en met adviezen te komen. Geen daemon maar een check van mijn systeem: kan er qua veiligheid nog wat verbeterd worden? De versie in Debian GNU/Linux loopt achter dus een aparte repo toegevoegd, zoals beschreven op [[https://packages.cisofy.com/ |
| + | <code bash> | ||
| + | root@roer: | ||
| + | root@roer: | ||
| + | deb [arch=amd64, | ||
| + | </ | ||
| - | Notice | + | Daarna een scan draaien: |
| - | ------ | + | |
| - | ' | + | |
| - | Your newly created PKI dir is: | + | <code bash> |
| - | * / | + | root@roer:~# sudo lynis audit system |
| + | </code> | ||
| - | * Using Easy-RSA configuration: | + | Een malware scanner had ik nog niet, dus..... |
| - | * The preferred location for ' | + | ==== Extra packages ==== |
| - | To silence this message move your ' | + | |
| - | or declare your ' | + | |
| - | * Using x509-types directory: / | + | <code bash> |
| + | root@roer:~# sudo apt install rkhunter apt-show-versions debsums | ||
| + | </code> | ||
| + | ==== Permissies ==== | ||
| - | * Using SSL: openssl OpenSSL 3.0.16 11 Feb 2025 (Library: OpenSSL 3.0.16 11 Feb 2025) | + | <code bash> |
| + | sudo chmod o-rwx /home/* | ||
| + | </ | ||
| - | * Using Easy-RSA configuration: | + | en in <code bash>/etc/login.defs< |
| - | * The preferred location for ' | + | ==== Blacklist rare modules ==== |
| - | To silence this message move your ' | + | |
| - | or declare your ' | + | |
| - | Using configuration from / | + | |
| - | ----- | + | |
| - | Notice | + | <code bash> |
| - | ------ | + | michelle@lummel: |
| - | CA creation complete and you may now import and sign cert requests. | + | install dccp /bin/true |
| - | Your new CA certificate file for publishing is at: | + | install sctp /bin/true |
| - | /etc/openvpn/easy-rsa/pki/ca.crt | + | install rds /bin/true |
| + | install tipc /bin/true | ||
| + | </ | ||
| - | * Using SSL: openssl OpenSSL 3.0.16 11 Feb 2025 (Library: OpenSSL 3.0.16 11 Feb 2025) | + | ==== Purge restanten van packages ==== |
| - | * Using Easy-RSA configuration: | + | Er slingeren soms nog configuratie-bestanden en andere cruft rond van packages die allang niet meer op het systeem staan. Die herken je in de output van `dpkg -l` doordat ze beginnen met rc. Mik deze weg: |
| - | * The preferred location for ' | + | <code bash> |
| - | To silence this message move your 'vars' | + | michelle@roer: |
| - | | + | |
| - | ----- | + | </ |
| - | + | ||
| - | Notice | + | |
| - | ------ | + | |
| - | Keypair and certificate request completed. Your files are: | + | |
| - | req: / | + | |
| - | key: / | + | |
| - | Using configuration from / | + | |
| - | Check that the request matches the signature | + | |
| - | Signature ok | + | |
| - | The Subject' | + | |
| - | commonName | + | |
| - | Certificate is to be certified until Aug 29 11:38:09 2027 GMT (825 days) | + | |
| - | + | ||
| - | Write out database with 1 new entries | + | |
| - | Database updated | + | |
| - | + | ||
| - | Notice | + | |
| - | ------ | + | |
| - | Certificate created at: | + | |
| - | * / | + | |
| - | + | ||
| - | Notice | + | |
| - | ------ | + | |
| - | Inline file created: | + | |
| - | * / | + | |
| - | + | ||
| - | * Using SSL: openssl OpenSSL 3.0.16 11 Feb 2025 (Library: OpenSSL | + | |
| - | * Using Easy-RSA configuration: | + | ===== AppArmor ===== |
| - | * The preferred location for ' | + | ** ToDo ** |
| - | To silence this message move your ' | + | |
| - | or declare your ' | + | |
| - | Using configuration from / | + | |
| - | + | ||
| - | Notice | + | |
| - | ------ | + | |
| - | An updated CRL has been created. | + | |
| - | CRL file: / | + | |
| - | + | ||
| - | 2025-05-26 13:38:09 DEPRECATED OPTION: The option --secret is deprecated. | + | |
| - | 2025-05-26 13:38:09 WARNING: Using --genkey --secret filename is DEPRECATED. | + | |
| - | * Applying / | + | |
| - | * Applying / | + | |
| - | * Applying / | + | |
| - | * Applying / | + | |
| - | * Applying / | + | |
| - | kernel.pid_max = 4194304 | + | |
| - | net.ipv4.ip_forward = 1 | + | |
| - | net.ipv6.conf.all.forwarding = 1 | + | |
| - | fs.protected_fifos = 1 | + | |
| - | fs.protected_hardlinks = 1 | + | |
| - | fs.protected_regular = 2 | + | |
| - | fs.protected_symlinks = 1 | + | |
| - | Created symlink / | + | |
| - | Created symlink / | + | |
| - | + | ||
| - | Tell me a name for the client. | + | |
| - | The name must consist of alphanumeric character. It may also include an underscore or a dash. | + | |
| - | Client name: MichelleJanse | + | |
| - | + | ||
| - | Do you want to protect the configuration file with a password? | + | |
| - | (e.g. encrypt the private key with a password) | + | |
| - | 1) Add a passwordless client | + | |
| - | 2) Use a password for the client | + | |
| - | Select an option [1-2]: 1 | + | |
| - | + | ||
| - | * Using SSL: openssl OpenSSL 3.0.16 11 Feb 2025 (Library: OpenSSL 3.0.16 11 Feb 2025) | + | |
| - | + | ||
| - | * Using Easy-RSA configuration: | + | |
| - | + | ||
| - | * The preferred location for ' | + | |
| - | To silence this message move your ' | + | |
| - | or declare your ' | + | |
| - | ----- | + | |
| - | + | ||
| - | Notice | + | |
| - | ------ | + | |
| - | Keypair and certificate request completed. Your files are: | + | |
| - | req: / | + | |
| - | key: / | + | |
| - | Using configuration from / | + | |
| - | Check that the request matches the signature | + | |
| - | Signature ok | + | |
| - | The Subject' | + | |
| - | commonName | + | |
| - | Certificate is to be certified until Aug 29 11:38:16 2027 GMT (825 days) | + | |
| - | + | ||
| - | Write out database with 1 new entries | + | |
| - | Database updated | + | |
| - | + | ||
| - | Notice | + | |
| - | ------ | + | |
| - | Certificate created at: | + | |
| - | * / | + | |
| - | + | ||
| - | Notice | + | |
| - | ------ | + | |
| - | Inline file created: | + | |
| - | * / | + | |
| - | Client MichelleJanse added. | + | |
| - | + | ||
| - | The configuration file has been written to / | + | |
| - | Download the .ovpn file and import it in your OpenVPN client. | + | |
| - | </ | + | |
technische_naslag/sid/roer.1748259534.txt.gz · Laatst gewijzigd: 2025/05/26 11:38 door michelle
