Introduction

My homelab is managed from a terminal: kubectl, talosctl, Terraform, a Git repository and the key that decrypts its secrets. All of that lives on my laptop. That works until something breaks while the laptop is closed in a bag, or sitting at home when I am not.

For those moments there is a second machine. It has everything the laptop has, it is always on, and I can reach it from a phone. That machine is a jump host.

This post explains what a jump host is, how I use mine, how I lost the first one, and why its replacement runs NixOS and can be rebuilt from my Git repository with one command.

What a Jump Host Is

A jump host (also called a jump host or a bastion) is a machine you log into first, in order to reach other machines.

The idea comes from company networks. Servers are not reachable from the outside. One small, hardened machine is. Administrators connect to it, and “jump” from there to the server they need. SSH even has an option for it:

ssh -J me@jumphost.example.com admin@192.0.2.30

The benefit is that there is one door instead of fifty. One machine to harden, one place where access is granted, logged and revoked. The servers behind it never face the internet.

In a homelab the principle is the same, with a twist. My jump host is not only a door. It is also a workstation that never leaves the house: a place where the tools are installed, the repository is cloned and a session can stay open for days.

How I Use Mine

graph TD
    P[Phone, over the VPN] -->|SSH or mosh| J[Jump host]
    B[Any browser, remote desktop gateway] -->|SSH or desktop| J
    J --> K[Kubernetes and Talos APIs]
    J --> H[Hypervisors]
    J --> F[Firewall]
    J --> G[Git server]

    style J fill:#ae81ff,stroke:#272822,color:#fff
  
  • From my phone. The phone joins my VPN (Tailscale), an SSH client connects to the jump host, and the login drops me straight into a tmux session. If the connection dies in the middle of a command, the command keeps running and I find it again when I reconnect. mosh keeps the session alive when the phone moves between Wi-Fi and mobile data.
  • From any browser. My remote desktop gateway, behind single sign-on and a second factor, offers the same SSH terminal in a web page. It can also open a graphical desktop on the jump host, started on demand, for the web interfaces that only exist inside the network: the hypervisors, the firewall.
  • With everything already there. A clone of my infrastructure repository that updates itself, the key to decrypt its secrets, and the same tools, versions and shell aliases as on my laptop. just talos::status gives the same answer from either machine.
  • With an assistant. I run Claude Code, an AI coding assistant, in that terminal. It has the repository and the tools at hand, which is a large part of what makes repairing something from a phone keyboard realistic.
  • As a second way in. The jump host also announces my home network to the VPN. The main announcer runs in the Kubernetes cluster, so if the cluster is down, there is still a route into the house.

Put together, this machine is my rescue host. It is what I use when the cluster, the storage or the laptop is the thing that is missing.

How I Lost the First One

My first jump host died of a successful migration.

It was an Ubuntu virtual machine I had configured by hand, one tool at a time. One day the hypervisor’s high-availability manager moved it to another host. Its disk was copied onto a storage pool that turned out to be full. The last few gigabytes of the copy were never written. The task ended with migration finished successfully and deleted the source. Nothing looked wrong until the next kernel update, weeks later:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

About 14,000 files were damaged, and there was no backup of that machine.

That migration deserves its own post. This one is about what I built next. I did not want a backup of a hand-made machine. I wanted a machine with nothing on it worth backing up: one that can be destroyed and rebuilt from Git.

It also made me write down a rule that the first one had quietly broken. A rescue host is needed precisely when other things are down, so:

The rescue host must not depend on anything it may have to rescue.

NixOS in Three Ideas

This is the first NixOS post on this blog, so a short ramp.

The whole system is one declaration. On most distributions you reach a state by running commands: install this, edit that file, enable that service. On NixOS you write the state itself, in files: these packages, these users, these services, this network configuration. A tool builds the system from it. Remove a line and the thing is gone at the next build, with no leftovers.

Every build is a generation. Applying a change does not modify the running system in place. It builds a new, complete system next to the old one and switches to it. The previous generations stay on disk and show up in the boot menu. A bad change is undone by booting the previous entry.

Flakes pin the inputs. A flake is a directory with a flake.nix (what to build, from which sources) and a flake.lock (the exact commit of each source). Two machines building the same flake at the same lock get the same system. That is the property that makes “rebuild from Git” literal.

If you read my Talos post, the philosophy is familiar: describe the machine, do not administer it. The difference is that Talos only runs Kubernetes, while NixOS is a general-purpose Linux that I can log into.

The Design: Depend on Nothing

The rescue rule from earlier became a list of concrete choices. In every case the “nice” option was the one that would be down at the same time as the thing I need to fix.

DependencyThe tempting choiceWhat the jump host does
StorageThe Ceph cluster, like every other VMA local disk on one hypervisor. A storage outage is a prime reason to need this machine
AvailabilityHypervisor HA, restart elsewhere on failureNo HA. HA plus a local disk is exactly what destroyed the old one. A rebuild replaces it
DNSThe VPN’s managed DNSThe firewall’s resolver, and a static IP that needs no DHCP
Gitgitlab.example.com, which resolves to a reverse proxy inside the clusterSSH straight to the Git server’s IP, with a mirror on GitHub as fallback
Remote accessThe VPN connector running in KubernetesIts own Tailscale node, which is also a second route into the LAN if the cluster is down

The Git line is the least obvious one. The friendly host name of my Git server goes through the cluster’s ingress. A jump host that clones through that name cannot fetch its own configuration when the cluster is the thing that is broken.

The Pieces

Everything lives in the same repository as the rest of my homelab:

nixos/
├── flake.nix                  # inputs and the list of hosts
├── flake.lock                 # exact versions
└── hosts/jumphost/
    ├── default.nix            # boot, users, SSH, secrets, auto-upgrade
    ├── disko.nix              # disk layout
    ├── network.nix            # static IP, Tailscale
    ├── tools.nix              # packages, heartbeat
    ├── home.nix               # my shell, tmux, dotfiles
    ├── secrets.yaml           # runtime secrets (SOPS)
    └── bootstrap.sops.yaml    # the machine's own key (SOPS)
terraform/jumphost.tf          # the virtual machine itself
just/jumphost.just             # iso, install, switch, set-secret

The Flake

{
  inputs = {
    # Stable for the whole OS: every package is in the binary cache.
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
    # Unstable for one fast-moving package only.
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";

    disko.url = "github:nix-community/disko";
    disko.inputs.nixpkgs.follows = "nixpkgs";
    sops-nix.url = "github:Mic92/sops-nix";
    sops-nix.inputs.nixpkgs.follows = "nixpkgs";
    home-manager.url = "github:nix-community/home-manager/release-26.05";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { nixpkgs, disko, sops-nix, home-manager, ... }: {
    nixosConfigurations.jumphost = nixpkgs.lib.nixosSystem {
      modules = [
        disko.nixosModules.disko
        sops-nix.nixosModules.sops
        home-manager.nixosModules.home-manager
        ./hosts/jumphost
      ];
    };
  };
}

Three community projects do the heavy lifting:

  • disko declares the partitions and filesystems, so the installer does not need a human typing fdisk commands.
  • sops-nix decrypts secrets at boot and places them as files with the right owner and mode.
  • home-manager applies the same idea to my user: shell, aliases, tmux configuration.

The “stable” choice has a practical reason. This VM runs on a low-power Celeron. Everything in the stable channel is available pre-built from the binary cache, so that CPU never has to compile anything.

Secrets and a Stable Identity

My repository already encrypts secrets with SOPS and age. The jump host fits into that with a two-step chain:

graph TD
    MK["Master age key (my laptop)"] -->|decrypts| BS["bootstrap.sops.yaml: the VM's own age key"]
    BS -->|placed on disk at install| VK[VM age key]
    VK -->|decrypts at every boot| SEC[secrets.yaml]
    SEC --> A[SSH host key]
    SEC --> B[User password hash]
    SEC --> C[VPN auth key]

    style MK fill:#ae81ff,stroke:#272822,color:#fff
    style VK fill:#ae81ff,stroke:#272822,color:#fff
  

The detail I like most is the SSH host key. It is one of the secrets:

sops.secrets.ssh_host_ed25519_key = {
  path = "/etc/ssh/ssh_host_ed25519_key";
  mode = "0600";
};

A freshly installed machine normally generates a new host key, and every client then shouts REMOTE HOST IDENTIFICATION HAS CHANGED. Here the rebuilt machine comes back with the same identity. No warning, nothing to clean up in known_hosts. The same trick keeps its file-sync identity, so nothing has to be paired again.

Put together, this is why there is nothing to back up. The system is in Git. The secrets are in Git, encrypted. The working copy of the repository is cloned again at first boot.

Updates: GitOps for an Operating System

system.autoUpgrade = {
  enable = true;
  flake = "git+ssh://git@gitlab.example.com/homelab/homelab-cluster.git?dir=nixos#jumphost";
  dates = "04:40";
  randomizedDelaySec = "15min";
  allowReboot = false;
};

Every night the machine pulls the main branch, builds the system it describes, and switches to it only if the build succeeds. It is the same pull model as Flux on my cluster, applied to an OS: I merge a change, and the machine follows.

It never reboots on its own, because a long-running terminal session may be open in tmux. When a new kernel is waiting, the shell prints a notice at login.

The package versions move through flake.lock. Renovate opens a merge request every week that refreshes it. So an OS update is a commit I can read, and a rollback is either a git revert or the previous entry in the boot menu.

Two Sources of Tools

Generic tools come from the stable channel: git, just, sops, k9s, restic, tmux and friends.

The cluster tools do not. talosctl, kubectl, flux and terraform must match the versions of what they talk to, and a stable distribution channel lags behind. When I built the machine, the channel shipped a talosctl one minor version behind my cluster. Those four binaries are downloaded at the exact versions pinned in the repository (the same pins my laptop uses), with their checksums verified. A small user service does it at boot and once a day, after pulling the repository.

It is less pure than “everything from Nix”. It guarantees something more useful here: the rescue host and the cluster never disagree on versions.

The Laptop and the Jump Host Move Together

A rescue is the worst moment to discover that k is not a command on this machine. Muscle memory has to work on both sides.

So I follow one habit: when I notice that I keep using an alias or a tool on my laptop, I declare it in the jump host configuration right away, not “when I have time”. It costs one line and one commit:

shellAliases = {
  ll = "ls -alh";
  k = "kubectl";
  kubectl = "kubecolor";   # coloured output, same binary underneath
  h = "helm";
  ks = "k9s";
  v = "nvim";
  y = "yazi";
};

The same rule is written in the instructions of my AI agent. When it sees me rely on a tool or adds an alias on the laptop, it declares it for the jump host as well. That way the habit does not depend on me remembering it.

It is not a blind copy. A few laptop aliases are left out because they make no sense here: the one that updates packages (this machine updates itself), the one that switches between clusters (there is only one). My tmux configuration came over with deliberate differences too, because a session opened from the laptop is tmux inside tmux, and the two must not fight over the same key bindings.

Because the configuration is declarative, this stays cheap. The next nightly upgrade applies the new line, and a rebuilt machine has it from the first boot.

Watching It

A systemd timer pushes a heartbeat to my monitoring every five minutes. It reports down when the last nightly upgrade failed. If the VM dies or loses its network, the pushes stop and the silence raises the alert.

The Install, With No Hands

The rebuild is four commands:

just jumphost::iso        # download the NixOS installer ISO to the hypervisor
just terraform::apply -target=proxmox_vm_qemu.jumphost \
  -var jumphost_iso=local:iso/<NIXOS_ISO>     # create the VM, ISO attached
just jumphost::install    # wipe, partition, install, reboot
just terraform::apply -target=proxmox_vm_qemu.jumphost   # detach the ISO

The third one is where it got interesting.

Typing an SSH Key Through a Virtual Keyboard

To install over SSH, I need my public key on the booted installer. The usual way on a hypervisor is the guest agent, which can run commands inside a VM. The NixOS installer image does not ship one.

What the installer does have is a console that is already logged in. And the hypervisor can press keys on a VM’s virtual keyboard through the QEMU monitor. So the recipe types the command, one key at a time:

sym = {" ": "spc", "-": "minus", "/": "slash", ".": "dot", "=": "equal",
       "|": "shift-backslash", "_": "shift-minus", "&": "shift-7"}
keys = ["ctrl-c"] + [sym.get(c) or (f"shift-{c.lower()}" if c.isupper() else c)
                     for c in command] + ["ret"]
for k in keys:
    print(f"sendkey {k}", flush=True)
    time.sleep(0.08)

Each character is translated to a QEMU key name and piped to the VM’s monitor. The 80 ms pause is not decoration. Sent in one burst, QEMU dropped some of the keys, and an SSH public key with a missing character is just noise.

After that it is ordinary SSH: copy the flake, run disko to partition the disk, write the machine’s age key where sops-nix expects it, run nixos-install, reboot.

What Went Wrong

The configuration evaluated without an error on my laptop. Reality added a few lessons, some during the first installation and some in the days after.

  • The install died with my SSH session. nixos-install downloads a few gigabytes. A pipe on my side closed early, took the SSH session with it, and the installation stopped halfway. It now runs as a transient systemd unit on the installer (systemd-run), and the recipe only polls its status. A dropped connection no longer matters.
  • An ampersand in a URL. My first auto-upgrade URL had two query parameters joined by &. The upgrade module pastes that URL into a shell script without quoting it. The shell read & as “run this in the background” and tried to execute the rest as a new command: --upgrade: command not found. One parameter, no ampersand.
  • A directory owned by root. A service created ~/.config as root before my user’s configuration ran, and home-manager then failed to write into it. One line declaring the directory with the right owner fixed it.
  • Flakes only see what Git tracks. A new file that is not yet git add-ed does not exist for the build. It is the first thing to check when Nix says a file is missing while you are looking at it.
  • The update bot needed Nix too. Refreshing flake.lock requires running Nix. My Renovate job ran under a user ID that its image did not know, which broke the on-demand install of Nix. No error surfaced: every other update kept flowing, only the weekly lock-file merge request never appeared. Once that was fixed, the first Monday run was killed for exceeding its memory limit, because nix flake update runs inside the same container.

None of these is exotic. All of them are the kind of thing you only find by running the installation for real, which is the argument for making it cheap to run.

Break Glass

Root login is disabled and SSH accepts keys only. If I lock myself out, there is one more door, and it does not need a password. From the hypervisor:

qm guest exec <VMID> -- <command>

The installed system does have the guest agent, and it runs commands as root. The boot menu is also mirrored on a serial console, so an older generation can be selected from the hypervisor’s web interface.

The Honest Downsides

  • This machine can decrypt everything. To be useful in a rescue, its key is a recipient of every secret in the repository. That makes it the most valuable target on my network. I limit how it can be reached (keys only, no root login, and from outside only the VPN or a remote desktop gateway with its own second factor), but the risk is real. Removing its key later would protect future secrets, not the ones already in the Git history.
  • The Nix language has a learning curve. The error messages are long, and the documentation assumes you already know where things are. I got there by reading other people’s configurations.
  • Stable lags. For a fast-moving tool I had to add a second channel, and for the cluster tools a different mechanism altogether.
  • Foreign binaries do not just run. A program downloaded from a release page expects a standard Linux layout that NixOS does not have. There is an option for that (programs.nix-ld), but you need to know it exists.
  • No HA means downtime. If the hypervisor under this VM dies, the jump host is gone until I rebuild it somewhere else. That is a deliberate trade: ten to fifteen minutes of rebuild against a mechanism that already cost me the machine once.

Key Takeaways

ConceptWhat I Learned
Rebuild beats backupIf the system and its secrets are in Git, there is nothing on the machine to save
Depend on nothingA rescue host must avoid the storage, DNS, ingress and HA of what it rescues
Hidden dependenciesA friendly host name can route through the very cluster you need to repair
Stable identityKeeping the SSH host key as a secret makes a rebuild invisible to clients
Pull-based OS updatessystem.autoUpgrade on a flake is GitOps for one machine, with boot-menu rollback
Pin what must matchCluster tools follow the repository’s pins, not the distribution’s channel
Keep two machines alikeAn alias or tool I start using on the laptop is declared on the jump host at once, by me or by my AI agent
Run the install for realMost of the problems only showed up on an actual installation
No guest agent?The QEMU monitor can type on a VM’s keyboard, slowly

Conclusion

The old jump host took me years to shape and one silent migration to lose. The new one is 900 lines of Nix that I can read in an afternoon, and losing it costs me a coffee break.

What changed is not really the distribution. It is where the value sits. Before, the value was on the machine, in a state nobody could reproduce. Now the machine is disposable and the value is in a repository that is mirrored, encrypted and versioned. It is the same idea that runs through my Talos nodes, my Terraform state and my Flux layout: any machine should be replaceable, including the one I use to fix the others.


Useful Resources: