Skip to content

feat(vpn): add a preshared key to the cluster VPN - #1441

Draft
gsanchietti wants to merge 1 commit into
mainfrom
feat-vpn-psk
Draft

gsanchietti wants to merge 1 commit into
mainfrom
feat-vpn-psk

Conversation

@gsanchietti

Copy link
Copy Markdown
Member

The cluster VPN (wg0) carries Redis, LDAP, logs and metrics in clear text inside the tunnel. A future quantum computer could decrypt recorded WireGuard traffic, because the tunnel keys are agreed with Curve25519 only. A WireGuard preshared key mixed into the handshake closes this gap. This PR adds it for nodes that join from now on.

The leader keeps one preshared key for the whole cluster, handled like the WireGuard private key: a root-only file /etc/nethserver/wg0.psk, plus a copy in Redis (private/nodes/vpn_psk) so a new leader can recreate it. A joining node asks for the key and receives it in the join reply. Nodes that do not ask for it, such as older workers and the NS7 migration tool, work as before. Existing nodes are not changed: that needs a later step with a short tunnel interruption.

  • create-cluster makes the key; add-node makes it if missing, returns it when the input has vpn_psk: true, and marks the node with psk in node/<id>/vpn.
  • join-cluster asks for the key; join-node writes it and adds PresharedKey to the first wg0.conf.
  • apply-vpn-routes reads Redis as the local cluster user, rewrites the key file if it is missing or different, and sets the key only on links to marked nodes.

Known limit: the key is in the add-node task output, which is not masked and stays in Redis for some hours. A possible fix is to let the new node read the key from Redis after replication starts.

How to test

Tested so far on a single node with a fake node added and removed (key file, Redis copy, key on the link, restart, file rebuilt from Redis, removal). Still to test on a real cluster:

  1. Create a cluster and join a second node: wg show wg0 preshared-keys shows a key on both ends; Redis replication works.
  2. Reboot both nodes: the tunnel comes back with the key.
  3. Promote the worker to leader and back: the tunnel stays up with the key.
  4. Join a new node to a cluster made before this change: old links stay without key, the new one has it.
  5. Remove the worker: its link is gone.

Generated by Claude Code:claude-opus-5-5 with nethserver-pr

A WireGuard preshared key mixed into the handshake protects recorded
cluster VPN traffic against a future quantum computer.

The leader keeps one preshared key for the whole cluster, in
/etc/nethserver/wg0.psk (mode 600) and in Redis at
private/nodes/vpn_psk. create-cluster makes it; add-node makes it if
missing. A joining node asks for it with the new add-node input
vpn_psk, gets it as vpn_preshared_key and writes it in its first
wg0.conf. add-node marks the node with "psk" in node/<id>/vpn.

apply-vpn-routes reads the replica as the cluster user, writes the key
file from Redis if it is missing or different (leader change), and
sets the key on the links of flagged workers only.

Nodes that do not ask for the key, like older workers and the NS7
migration tool, work as before.

Assisted-by: Claude Code:claude-opus-5-5
@gsanchietti gsanchietti self-assigned this Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant