VPN two computers together with Wireguard
WireGuard is a nice modern lightweight performant VPN that doesn't come with a bewildering array of configuration guns to shoot yourself in the foot with.
This will create a bidirectional VPN between the server and the client, using 10.0.0.1 for the server, and 10.0.0.2 for the client.
Adjust file/interface names, and IP addresses to suit.
Note that the PublicKey configs are the other side's public keys.
It's not super easy to document it simply, but hopefully this will suffice.
SERVER
apt-get install wireguard-tools# Generate the server's keypair
PRI=`wg genkey`; PUB=`echo $PRI | wg pubkey` ; echo $PRI $PUB
cat /etc/wireguard/toclient.conf
[Interface] Address = 10.0.0.1/24 SaveConfig = true ListenPort = 51820 PrivateKey = SERVER private key [Peer] PublicKey = CLIENT public key AllowedIPs = 10.0.0.2/32
systemctl enable --now wg-quick@toclient
ifconfig toclient
toclient flags=209
CLIENT
apt-get install wireguard-tools# Generate client's key pair
PRI=`wg genkey`; PUB=`echo $PRI | wg pubkey` ; echo $PRI $PUB
cat /etc/wireguard/toserver.conf
[Interface] Address = 10.0.0.2/24 SaveConfig = true PrivateKey = CLIENT private key [Peer] PublicKey = SERVER public key AllowedIPs = 10.0.0.1/32 Endpoint = <server ip address>:51820
systemctl enable --now wg-quick@toserver
ifconfig toserver
toserver: flags=209
# Should be able to ping the server
ping -c 4 10.0.0.1
SERVER
# Should be able to ping the clientping -c 4 10.0.0.2