A Mac mini that lives in another country is only useful if you can reach it reliably. For terminal work with a coding agent, the most common pattern is a private overlay network such as Tailscale, with plain SSH running on top. This guide walks through how that setup fits together, which settings matter, and how to keep the connection predictable when the machine is thousands of kilometres away.
Why an overlay network instead of a public SSH port
Opening port 22 on a residential connection invites constant brute-force traffic, and many home routers make port forwarding awkward or impossible behind carrier-grade NAT. An overlay network sidesteps both problems. Each device gets a stable private address on your tailnet, traffic is end-to-end encrypted with WireGuard, and NAT traversal is handled for you. The Mac never needs a port exposed to the open internet.
For an always-on build or agent machine this has a second benefit: the address you type does not change when the ISP reassigns the public IP, so scripts, SSH config entries and editor remotes keep working.
The basic shape of the setup
On the remote Mac, Tailscale runs as a background service and joins your tailnet. On your laptop, the same client joins the same tailnet. Once both show as connected, you can reach the Mac by its tailnet IP (in the 100.x.y.z range) or by its MagicDNS name, for example mac-mini-tokyo.
From there, SSH works exactly as it would on a local network:
ssh you@mac-mini-tokyo
A short entry in ~/.ssh/config makes this even easier:
Host agentmac
HostName mac-mini-tokyo
User you
ServerAliveInterval 30
ServerAliveCountMax 4
ServerAliveInterval keeps idle sessions from being silently dropped by middleboxes, which matters on long agent runs where the terminal may sit quiet for minutes.
Direct connections versus relays
Tailscale tries to build a direct peer-to-peer path between your devices. When that fails, usually because of strict NAT on one side, traffic falls back to DERP relay servers. Relayed connections still work, but they add latency and can cap throughput.
You can check which path you are on with:
tailscale status
tailscale ping mac-mini-tokyo
If tailscale ping reports "via DERP" instead of a direct address, a few things are worth trying:
- Make sure UDP is not blocked on your local network. Some office and hotel networks block it outright.
- Restart the client on both ends after a network change so it renegotiates the path.
- Check
tailscale netcheckon each side to see NAT type and which relay region is nearest.
On a remote Mac sitting on residential broadband, direct connections are common, but the laptop side is often the weak link when travelling.
Choosing a region with latency in mind
Interactive terminal work is sensitive to round-trip time. Typing into a shell that is 250 ms away feels sluggish; a session at 40 ms feels local. When a provider lets you choose where the machine is hosted, pick the region closest to where you usually work, not the one closest to the services the agent calls.
Coding agents spend most of their time talking to APIs and package registries, which tolerate latency well. You, on the other hand, are typing and reading output in real time. Optimise for the human side of the connection.
If you regularly work from more than one location, tools like Mosh can smooth over high-latency or flaky links by echoing keystrokes locally and surviving IP changes. Mosh runs over UDP and works fine across a tailnet.
Keeping the Mac reachable after reboots and updates
A remote machine you cannot physically touch needs a few safeguards:
- Run Tailscale as a system service so it starts before anyone logs in. On macOS this is the standalone or Homebrew-installed daemon rather than only the menu-bar app tied to a user session.
- Disable key expiry for the server node in the admin console, or set a reminder to re-authenticate. A node whose key expires drops off the tailnet and cannot be reached until someone logs in again.
- Enable automatic login or FileVault handling carefully. With FileVault on, a reboot may stop at the pre-boot unlock screen before the network stack is up. Know how your host handles this before applying macOS updates remotely.
- Keep a second access path. A remote desktop tool configured independently of Tailscale gives you a way back in if the tailnet client misbehaves.
Using Tailscale SSH or regular SSH
Tailscale offers its own SSH server that authenticates using tailnet identity instead of keys. It is convenient, but many developers prefer the standard macOS sshd with key-based login because it behaves the same everywhere and works with existing tooling such as rsync, scp and editor remote extensions.
If you use standard SSH, a reasonable baseline is:
- Key-based authentication only, with
PasswordAuthentication noinsshd_config. - Restrict SSH to the tailnet interface or use the macOS firewall so it is not reachable on the public IP.
- Use Tailscale ACLs to limit which of your devices can reach port 22 on the Mac.
ACLs are worth setting up early. A tailnet often grows to include phones, tablets and shared machines, and there is no reason all of them need shell access to your build host.
Forwarding ports for previews and dev servers
When an agent starts a dev server on the remote Mac, you can reach it over the tailnet directly at http://mac-mini-tokyo:3000, as long as the server binds to all interfaces rather than only localhost. If it binds only to localhost, an SSH local forward works:
ssh -L 3000:localhost:3000 agentmac
Then open http://localhost:3000 on your laptop. This is handy for checking a web UI the agent just changed without pushing anything.
Troubleshooting checklist
When a connection suddenly stops working, go through these in order:
tailscale statuson your laptop: is the Mac listed and online?tailscale pingto the Mac: direct, relayed, or timing out?- If the Mac shows offline, check the admin console for key expiry or a recent reboot.
- If the tailnet is fine but SSH fails, test with
ssh -vto see whether it is a network, key orsshdproblem. - If everything looks right but sessions keep dropping, lower
ServerAliveIntervalor switch to Mosh.
A ready-made option
Setting all of this up on your own hardware abroad means finding hosting, configuring the network and keeping the machine alive. Services such as CCRent rent a dedicated Mac mini M4 hosted overseas on residential broadband, reachable through Tailscale and SSH for terminal work or through remote desktop tools for the full macOS interface, with Claude Code already installed. Whichever route you choose, the networking principles above stay the same: private overlay, key-based SSH, a second way in, and a region close to the person at the keyboard.
Claude is a trademark of Anthropic. CCRent is an independent provider, not affiliated with Anthropic.