WireGuard without laptop route changes: private SSH in userspace

Private SSH through a separate WireGuard process, access checks and session cleanup. Managed CLI and wizard startup without changing the laptop’s system routes.

An isolated laptop client joined to a server by a green channel, with other routes running separately.

WireGuard was already running on the educational E-01, while the laptop retained its previous key and configuration. After a new laptop boot, the client interface was absent. We checked the retained settings, attempted one start and rolled back after other routes stopped matching. We ultimately verified private SSH through a separate userspace WireGuard client, without a system interface or laptop route changes.

Start with the existing key and configuration

The retained private key remained root-owned on the laptop. Its derived public key matched the historical journal, and the complete configuration matched the retained plan. Both nodes' public keys, the IPv4 endpoint, UDP port and reciprocal /32 addresses matched the current server peer.

The configuration contained only the interface address, key and one peer with its endpoint and AllowedIPs. It contained no DNS, default route, hooks or additional keepalive. The /etc/wireguard/${WG_IF}.conf file was root:root 0600. We exported neither the private key nor its hash.

The historical journal recorded active for its old boot. The current service was inactive/disabled, so the old record could not prove a current connection. We read service properties separately; WG_IF below names the verified client:

sudo systemctl show "wg-quick@${WG_IF}.service" \
  --property=Id,LoadState,UnitFileState,ActiveState,SubState

One start and restoration of the original network

Following separate approval, we started only this existing instance, without enable or new keys. It became active/exited; for this oneshot, the start command had completed while the interface operated in the kernel. However, the route snapshot for another active connection differed from the original.

We did not accept that state. We stopped only our new instance and compared the network: addresses, routes, rules, DNS and the connection list returned to their original values. The key, configuration and old journal were also retained. We did not repair other connections' configuration or attribute the cause to a particular external component.

sudo systemctl start "wg-quick@${WG_IF}.service"
# After the network snapshot differed, roll back only the owned instance:
sudo systemctl stop "wg-quick@${WG_IF}.service"

This was one start and one rollback in our environment. We did not substitute a new boot into the old plan, rewrite the journal or repeat start.

WireGuard and TCP/IP inside a process

We prepared the next session using wireguard-go/netstack. The official WireGuard example shows a WireGuard device combined with an application's network stack. A packet can therefore carry a private address inside the process without creating a system TUN interface.

The abbreviated API shape below illustrates creating that stack. clientIP has type netip.Addr; nil means that we supply no DNS servers. This is a separate API example, rather than a complete ready-to-run client:

tun, tcpNet, err := netstack.CreateNetTUN(
    []netip.Addr{clientIP},
    nil,
    1280,
)

In our session, the process read the same existing root0600 configuration. It used the key in memory for the same server peer, with no new disk copy or value in arguments, environment or stdout. Tunnel AllowedIPs remained a single server IPv4 /32. Access to the private file required root, but no system interface, NetworkManager profile, routes or DNS were created.

Ordinary SSH over a private TCP stream

We prepared a local stream adapter for OpenSSH. It opened TCP to E-01's private address through in-memory WireGuard. The local UNIX socket was accessible only to the operator; destinations were restricted to this server's SSH and control HTTPS ports.

The example below shows OpenSSH options. WG_STREAM_PROXY names a prepared adapter carrying bytes through stdin/stdout. It is not the name of an already published command in our CLI. Populate every variable with your own verified value:

ssh -F /dev/null -T \
  -o IdentitiesOnly=yes -i "$SSH_IDENTITY_FILE" \
  -o StrictHostKeyChecking=yes \
  -o UserKnownHostsFile="$KNOWN_HOSTS_FILE" \
  -o HostKeyAlias="$SERVER_PUBLIC_IPV4" \
  -o PasswordAuthentication=no \
  -o KbdInteractiveAuthentication=no \
  -o ControlPath=none \
  -o ProxyCommand="$WG_STREAM_PROXY" \
  "$ADMIN_USER@$SERVER_WG_IPV4"

HostKeyAlias retained the binding to this server's previously verified host key. The administrator's SSH key remained separate from the WireGuard key. On the server, we checked the actual SSH_CONNECTION source and destination: both addresses belonged to the private connection. The machine and current boot matched, and a fresh authenticated handshake confirmed peer operation.

Passwordless sudo was denied, while password-based sudo yielded UID0. A separate fresh SSH connection through the public management address, also with password-based sudo, passed. We did not substitute fallback host trust or another authentication key.

Check HTTPS against a healthy listener

The existing HTTPS service on server loopback returned 401 before and after the negative request. We checked the CA, exact leaf certificate, SNI and noindex/no-store without weakening TLS. TCP443 did not connect through the private WireGuard channel.

On the server's WG interface, we separately observed the corresponding SYN from the private client to that port. We retained only selected header fields and saved no application payload. The named input_drop counter increased. We do not attribute its entire increase exclusively to our packets: the owned SYN and TCP connection result are separate evidence.

End the session without a background service

While the client was running, network snapshots before and after the checks matched: other routes, rules, addresses, DNS and connections remained unchanged. This is an abbreviated actual result of that session:

{
  "status": "passed",
  "actual_private_SSH_tuple_verified": true,
  "private_password_sudo": true,
  "public_recovery_SSH_password_sudo": true,
  "NOPASSWD_denied_both": true,
  "private_TCP443_denied": true,
  "owned_SYN_header_observed": true,
  "kernel_interface_created": false,
  "NetworkManager_profile_created": false,
  "unrelated_network_DNS_exact": true,
  "whole_host_ready": false
}

After the checks, the process exited normally, its PID disappeared and its UNIX socket was removed. The system client remained inactive/disabled; no autostart was configured. This is a verified session-based private channel.

Genuine VTE terminal summarizing saved results: one kernel start was rolled back to the original network, and private and public SSH with password-based sudo passed during a separate userspace session. The owned SYN to denied TCP443 was observed on the server; the background process exited. Commands and checks did not rerun during capture.

Repeat the checks through the CLI

After the manual run, we moved the session mode into the local Go CLI and repeated the checks on the same training server. The verify-access command confirmed private SSH with password-based sudo, a separate public recovery connection, and the machine and current boot matching the independent console. HTTPS returned 401 before and after; the private TCP443 connection was not established, and the corresponding SYN was observed on the server.

The key stayed in the original root-owned configuration. Process control uses an abstract UNIX socket with UID verification on both ends. The controlling program holds a separate pipe: closing it ends the session if control is lost. Both directions of the SSH stream close together, so completed SSH does not wait indefinitely for stdin.

The stop-requested response acknowledges the stop request. We then separately waited for the stopped event and process exit code 0. The old key, configuration and journals, routes and DNS were preserved. This mode now works in the local CLI.

Explicit channel selection in the setup wizard

The wizard now has an explicit userspace selection. It uses an already running session, compares its addresses and port with the server plan, and matches the peer key against the server public key. It then verifies private SSH with password-based sudo and separate public recovery. A changed request or failed check stops the workflow without switching to another access method.

On the already configured E-01, we ran only the separate host setup wizard channel-check command. It passed through the same verifier without running server setup again. After the checks, the controlling program stopped the session and waited for the root process to exit; old files and network settings remained unchanged.

In the full wizard, the channel check precedes independent runtime acceptance and runs again after the server reboot with fresh console evidence. After the automated probes, the operator supplies separate acceptance files. Managed root-session startup was added next.

CLI owns client startup and shutdown

We added a managed foreground mode. The CLI verifies password-based sudo on the client, starts the same prepared executable as root, and holds a pipe that controls the process lifetime. The WireGuard key stays in the prepared root configuration. The startup command is:

"$CLI" local wireguard userspace run \
  --request-file "$SESSION_REQUEST" \
  --request-sha256 "$SESSION_SHA256" \
  --sudo-password-file "$LOCAL_SUDO_PASSWORD_FILE" \
  --approve-client-privileges

LOCAL_SUDO_PASSWORD_FILE names a private file containing the client machine’s sudo password. This is separate from access to the VPS. The password travels through stdin; command arguments and status messages contain no password value. This mode requires password-based sudo and refuses NOPASSWD.

The prepared wizard profile can select this field:

{
  "client_transport": "userspace-managed"
}

Starting the wizard also requires the separate --approve-client-privileges permission. After the channel checks, the operator supplies independent runtime and postboot acceptance files. The CLI owns the client session through the remaining setup and server reboot, then closes the lifetime pipe and waits for the root process to exit before completing the wizard.

We ran the full sequence on a separate clean fixture with a prepared client: initial access, server runtime, private channel, protected Symfony site, and two controlled reboots. Private and public SSH with password-based sudo were repeated after the final reboot. After client shutdown, its configuration, routes and DNS were preserved, and no kernel interface appeared. The existing E-01 was not configured again during this run.

  1. Operations & Security WireGuard on Debian: private SSH access and a post-reboot check
  2. Operations & Security Client WireGuard in local setup: key and configuration
  3. Operations & Security Client WireGuard in setup: NetworkManager, start and acceptance
  4. Platform Engineering Checking an existing E-01: APT checkpoint, services and private HTTPS