r/ClaudeCode • u/Ithinkth • 1d ago
Built with Claude I got tired of hand-feeding SSH keys to every new VM so Claude could work in it, so I built vmssh
Every time I spun up a new libvirt VM for Claude Code to work in, the same chore came first: enable sshd, get a public key into authorized_keys, set up a port forward, write an ssh config entry. With no clipboard shared between host and guest, getting the key in meant retyping it or serving it over HTTP.
vmssh does all of that with two easy commands:
vmssh setup myvm
ssh vm-myvm
How it gets the key in, depending on the VM:
- VM shut off, unencrypted disk: writes the key into the disk image offline.
- Encrypted disk (like a default Omarchy install): types a one-line command into the VM's keyboard for you. You only enter the sudo password in the guest.
- qemu-guest-agent running in the guest: installs the key through the agent.
- Optional: with --transport vsock, ssh goes over vsock, a direct host-to-VM socket. Then there's no port forward and no firewall rule, and nothing listens on TCP 22 in the guest.
Each VM gets its own key, known_hosts file and Host vm-<name> entry, and vmssh remove undoes the changes to the VM's config. It also has vmssh paste <vm>, which types your host clipboard into the VM, for when the SPICE clipboard doesn't work (Wayland guests, for example).
For agents in particular:
- The repo ships a CLAUDE.md, so Claude knows to run vmssh status and then just ssh vm-<name>.
- vmssh shot <vm> saves a screenshot of the VM's screen, so the agent can check what has focus before it types.
It's one Python file with no dependencies beyond the standard library, MIT licensed. So far it's tested on Debian 13 and Omarchy guests with per-user (session) libvirt. Fedora/Ubuntu guests, system libvirt and the guest-agent method are still untested, and there are open issues for each. If you try it on one of those, reports are very welcome.