Skip to content

Installing Algo VPN: opinionated WireGuard + IPsec from Trail of Bits

How Algo VPN bootstraps a hardened personal/team VPN on a fresh VPS — what it actually installs, where it differs from a hand-built stack, and when to use it.

Algo VPN is the opinionated installer Trail of Bits ships for spinning up a personal or small-team VPN: an Ansible playbook that takes a fresh Ubuntu VPS and turns it into a WireGuard + strongSwan IKEv2 gateway with hardened defaults, mobile-ready profiles, and no telemetry. We use it when a client wants a VPN on their own VPS without us hand-rolling the whole stack — Algo’s defaults are sensible enough that the operational layer is what we add on top, not the install itself.

How to verify

Before running the playbook, confirm you have a fresh-ish Ubuntu LTS, SSH key access, and the local machine has Python 3 and Ansible available.

ssh root@<vps-ip> 'lsb_release -ds; uname -r'
python3 --version
ansible --version
git --version

Algo runs the playbook from your laptop (or a CI runner) against the target VPS. It is not installed on the VPS itself — only the resulting WireGuard + strongSwan stack lives there. If you have an existing WireGuard or strongSwan setup on the VPS, Algo will overwrite the config; back up first.

What’s happening

Algo is a curated Ansible playbook that installs:

  • strongSwan with IKEv2 + EAP for native client support (iOS, macOS, Windows native VPN).
  • WireGuard for clients that prefer it (desktop, Android via WG app, iOS via WG app).
  • dnscrypt-proxy for DNS resolution inside the tunnel, defaulting to a public resolver.
  • iptables/ip6tables rulesets that block everything except established tunnel traffic.
  • unattended-upgrades so the box patches itself.
  • CA bootstrapping and per-user certs/keys generated locally on your laptop.

The output is a directory of ready-to-import profiles: a .mobileconfig for iOS/macOS that bundles the CA, server identity, and EAP settings; a .conf for WireGuard; a QR code for phones. The CA private key sits on your laptop, not on the VPS.

What Algo does not do well:

  • Multi-user revocation. The model is “users are baked in at install time”; revoking means re-running the playbook with the user removed.
  • Server-side observability. You get systemd logs; you do not get the structured audit pipeline a managed engagement needs.
  • Multiple servers / HA. Algo is one server, one config.

For a homelab or a small team, this is exactly enough. For a fleet, you graduate to a hand-built stack with the pieces Algo skips.

The procedure

  1. Clone Algo on your laptop.

    git clone https://github.com/trailofbits/algo.git
    cd algo
    python3 -m venv .env
    source .env/bin/activate
    pip install -r requirements.txt
  2. Copy the example config.

    cp config.cfg config.cfg.local

    Edit config.cfg.local:

    users:
      - alice
      - bob
      - carol
    
    wireguard_enabled: true
    ipsec_enabled: true
    dns_encryption: true
    ssh_tunneling: false
    store_pki: true   # keep CA private key on your laptop
  3. Run the playbook against your VPS. The interactive mode walks you through the cloud-provider question; pick “Install to existing Ubuntu server” if you already have the VPS.

    ./algo

    When prompted:

    • Server IP: the public IP of your VPS.
    • SSH user: root (or whatever has passwordless sudo).
    • VPN endpoint hostname: a DNS name pointing at the VPS (saves cert pain later).
  4. Wait. Algo runs ~15 minutes the first time. It installs packages, generates the CA, generates per-user keys and certs, writes /etc/wireguard/, writes /etc/swanctl/, configures iptables, restarts everything.

  5. Distribute the profiles from configs/<server-ip>/.

    • iOS/macOS: users/alice.mobileconfig — drop on the device, profile imports VPN.
    • Android: users/alice.conf + WireGuard app, or the IKEv2 profile in the strongSwan app.
    • Windows: users/alice.ps1 PowerShell script that registers the IKEv2 connection.
    • Linux: wireguard/alice.conf for wg-quick.
  6. Connect a client and confirm.

    curl -s https://ifconfig.me

    Should return the VPS IP, not your local one.

  7. Patch and refresh quarterly. Algo writes /etc/cron.d/unattended-upgrades; the box patches itself. For Algo updates (new versions of the playbook), pull git fetch upstream && git rebase and re-run the playbook — Algo idempotency is decent but not perfect; expect to re-issue some user profiles.

Common pitfalls

  • Losing the local configs/ directory — that is where the CA lives. Without it, you cannot add or revoke users. Back it up like a password vault.
  • Re-running Algo with the same hostname after the VPS was reinstalled — the CA will not match the new server cert and clients will refuse the connection. Always rebuild from scratch or restore from the laptop-side backup.
  • Adding users by editing config files on the VPS directly — Algo expects users to be declared in config.cfg; manual edits get reverted on the next playbook run.
  • Pointing public DNS at the VPS IP without a hostname — works, but iOS will complain about the cert SAN. Always use an FQDN.
  • Assuming dnscrypt is on by default forever — Algo’s defaults can change between versions. Read the config.cfg after each git pull.

In the engagements we run, Algo is a fine choice when the client wants a single-server VPN they control and we are not contracted to operate it long-term. When the engagement covers ops, we layer the audit logging, multi-server HA, and revocation discipline that Algo intentionally leaves out. For everything beyond a small team, see the broader Managed Operations model.