Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
selfhost:external_server [2025/02/19 09:54] – willy | selfhost:external_server [2025/03/13 09:29] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== External Server ====== | + | ====== |
The external server is used for a few different tasks: | The external server is used for a few different tasks: | ||
Line 46: | Line 46: | ||
===== External server Setup ===== | ===== External server Setup ===== | ||
- | I assume you can install your own OS, so let's install Gentoo. Follow the [[gentoo: | + | I assume you can install your own OS, so let's install Gentoo. Follow the [[gentoo: |
- | You don't need to install **anything** beside the bare minimum of the basic text-only installation. | + | You don't need to install **anything** beside the bare minimum of the basic text-only installation, except the specific packages described below. |
- | Do not create any additional users except one unprivileged user, because you don't want to login as root remotely. | ||
==== Required packages ==== | ==== Required packages ==== | ||
- | PHP, NGINX, wireguard-tools, | + | Do not forget to install the following minimum stuff, required for any reasonable server: |
- | + | * // | |
- | ==== Filesystem sharing with internal | + | * // |
+ | * // | ||
+ | * // | ||
+ | * //net-vpn/wireguard-tools//: needed to create the VPN tunnel between the home server and the external server | ||
+ | * // | ||
+ | * // | ||
+ | * // | ||
+ | * // | ||
+ | * // | ||
+ | * //net-fs/nfs-utils// (optional): if you want to share filesystem between home server an external | ||
+ | As a quick reminder, with suggested USE flags: | ||
<code bash> | <code bash> | ||
- | emerge -vp nfs-utils | + | # to use only nftables and not iptables: |
+ | echo " | ||
+ | # nginx and PHP cross support | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | emerge -vp app-admin/ | ||
</ | </ | ||
+ | |||
+ | |||
+ | ==== Unpriviledged users & SSH access ==== | ||
+ | |||
+ | SSH access for user root must be disabled. Also, password login sohuld be disabled as well, limiting SSH access to using public/ | ||
+ | |||
+ | The SSH server should also be moved to a port other than 22. This will **not** prevent brute force attacks, but greatly reduce them. | ||
+ | |||
+ | To allow remote access, add the **public** key of the users from the home server to the **/ | ||
+ | |||
+ | Given that the //root// user must never be used for remote login, you need the following unproviledged users: | ||
+ | * //user//: this one will be used by you for remote SSH access. | ||
+ | * //backup//: this will be used by the home server to upload the offsite backups | ||
+ | * //tunnel//: this will be used by the home server to setup SSH tunnels (alternative to using WireGuard) | ||
+ | |||
+ | |||
+ | ==== Filesystem sharing with internal server ==== | ||
+ | |||
+ | In case you want to share a filesystem between your home server and the external server, you can do that with NFS v4.2 over the Wireguard tunnel. Do not use NFS without the wireguard tunnel: it will be unencrypted. | ||
Create **/ | Create **/ | ||
Line 66: | Line 100: | ||
OPTS_RPC_NFSD=" | OPTS_RPC_NFSD=" | ||
</ | </ | ||
- | to bind NFS to the wireguard interface and disable all legacy NFS versions | + | to bind NFS to the wireguard interface and disable all legacy NFS versions. |
+ | |||
+ | For wireguard tunneling, see [[gentoo: | ||
- | ===== Networking | + | ===== Connecting home server and external server |
+ | There are two ways to achieve this, which preserve security: | ||
+ | * Create a wireguard tunnel | ||
+ | * Create an SSH tunnel | ||
+ | Both solutions have pros and cons, and both require the home server to initiate the connection to the external server and this will let you escape any kind of CG-NAT and let you do port-forwarding as well. | ||
- | Having an external server, like a VPS (Virtual Private Server) let you bypass CG-NAT (carrier-grade NAT) and give you the access to a real public, static IP address. | + | This topic is covered [[networking: |
- | I will detail more on this topic in the future, for the moment refer to the following pages: | ||
- | * [[networking: | ||
- | * [[router: |