My girlfriend asked me how to run Claude Code in an isolated, secure environment so it won’t mess with her files.
The instinct is to reach for sandboxes, containers, permission flags. But the cleanest way to stop an agent from touching your files is much simpler: don’t run it on the machine that has your files. Rent a cheap VPS, run Claude Code there, and her laptop is never in the blast radius. If Claude does something dumb, the worst it can touch is a throwaway box you can delete and rebuild in minutes.
She wanted to use OVH, so that’s what this is. The “isolate it from my files” problem solves itself the moment Claude lives on a different computer. That just leaves a second problem: a public VPS is an internet-facing target the moment it boots. The rest of this post is about making that box safe — closing every port, exposing nothing to the world, and reaching it only over Tailscale.
The threat model
Three things we’re actually defending against, so the steps below have a spine:
- Claude touching her files. Solved by running it on a remote box that doesn’t have them.
- The internet attacking a public VPS. Solved by a default-deny firewall plus Tailscale.
- Claude breaking the box itself, or leaking secrets. Solved by a non-root user, the built-in sandbox, snapshots, and keeping real secrets off the box entirely.
End state:
laptop ──Tailscale──> OVH VPS (no open ports to the world)
Spin up the OVH VPS
Order a small VPS and pick Ubuntu 24.04 LTS. OVH also gives you a Network Firewall at the infrastructure edge and a KVM console in the panel — we’ll do the real work with host-level ufw, but keep that OVH console handy: it’s your way back in if you ever fence yourself out with a bad firewall rule.
First thing after boot, get current:
apt update && apt upgrade -yA non-root user with SSH keys
Don’t run as root, don’t use passwords. Create a user, give it sudo, push your key from the laptop:
# on the server:
adduser claude
usermod -aG sudo claude
# from the laptop:
ssh-copy-id claude@<server-ip>Then turn off root login and password auth. Edit /etc/ssh/sshd_config (or drop a file in /etc/ssh/sshd_config.d/):
PermitRootLogin no
PasswordAuthentication no
sudo systemctl restart sshReconnect as claude in a second terminal before you close the first one — that way, if you fat-fingered the config, you still have a live session to fix it.
Firewall: default deny
Least privilege: block everything coming in, allow everything going out. Allow SSH first, then enable — the classic footgun is enabling ufw before allowing SSH and locking yourself out of your own box.
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp # temporary — we remove this in "Close the door"
sudo ufw enable
sudo ufw status verboseTailscale: a private network of two
Tailscale is a WireGuard-based mesh VPN — not a server, just networking. It gives the box a second, private IP that only your own devices can reach. Install it on the VPS, bring it up, grab the address:
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
tailscale ip -4 # -> 100.x.y.z (the CGNAT range 100.64.0.0/10)Install Tailscale on her laptop the same way (or the desktop app) and sign into the same account. In the admin console, disable key expiry on the server so it doesn’t silently drop off the tailnet in 90 days.
Verify from the laptop — this should connect over the Tailscale IP, with Tailscale running on both ends:
ssh claude@100.x.y.zClose the door
Now make SSH reachable only over Tailscale, then drop the public port-22 rule. Tailscale’s own guide does this by allowing the tailscale0 interface:
sudo ufw allow in on tailscale0 # anything over the tailnet
sudo ufw allow from 100.64.0.0/10 to any port 22 proto tcp # explicit, defence in depth
# optional: also allow her home/office IP directly
sudo ufw allow from <her.home.ip.address> to any port 22 proto tcp
# remove the public rule from the firewall step:
sudo ufw delete allow 22/tcp
sudo ufw status verboseAbout that home-IP rule: residential IPs are usually dynamic, so the rule breaks the moment her ISP rotates the address — and then she’s locked out until she fixes it from the OVH console. That’s exactly why Tailscale is the better default. Keep the home-IP line only if she has a static IP; otherwise rely on Tailscale alone.
The payoff: port-scan the public IP now and there’s nothing there. SSH is invisible to the internet. Only her tailnet can reach the box.
Hardening Claude on the box
The box is locked down. Now make Claude itself safe to run, ideally unattended:
- It’s already a non-root user. Claude runs as
claude, so a bad command is confined to that account — and the box holds none of her real data anyway. - Use the built-in sandbox. Claude Code ships a sandboxed Bash tool (
/sandbox, backed bybubblewrapon Linux). Most commands run without prompting, but the OS still enforces filesystem and network boundaries. --dangerously-skip-permissionsbelongs here, not on the laptop. Inside a contained, disposable box that flag is reasonable; on your real machine it isn’t. It also refuses to run as root — one more reason for theclaudeuser.- Snapshot a clean state. Take an OVH snapshot once the box is set up. If Claude trashes it, roll back in minutes. Treat the box as cattle, not a pet.
- Keep real secrets off it. Don’t copy her personal
~/.sshkeys, cloud credentials, or password store onto the server. Use repo-scoped or short-lived tokens for whatever she’s building. - Make sessions durable. Run Claude inside
tmux(ormosh) so a flaky connection doesn’t kill a long task. Reattach later — even from a phone, over Tailscale, with an SSH app like Termius.
Wrap-up
Two layers, two payoffs. Her files are safe because they were never on the box. The box is safe because nothing on the public internet can reach it. For about €5/month she gets a sandbox she can hand to an AI agent and nuke whenever it gets weird.
Inspired by @levelsio’s Tailscale thread and Deepak’s Hetzner + Tailscale writeup.