Run Claude Code on a Server over SSH: tmux, Xcode and a Cloud Mac
·8 min read
Claude Code is at its best on long tasks: refactor this module, make the tests pass, build the feature and open a pull request. The problem is where it runs. On a laptop, the agent stops when the lid closes, slows down when you join a call, and works inside the same account that holds your SSH keys, browser sessions and tax returns. Moving it to a dedicated cloud Mac fixes all three, and if the project touches iOS it also gives the agent Xcode and the Simulator. This guide sets that up from scratch.
Why a Mac server, and why a rented one
Claude Code runs on Linux, macOS and Windows, so for a pure web backend a cheap Linux VPS is enough. A Mac becomes necessary the moment Apple's toolchain is involved: xcodebuild, the iOS Simulator, code signing, TestFlight uploads. Those only exist on macOS, which Apple only licenses on Apple hardware. A Mac Mini in a data center is the cheapest way to have that available all day.
Renting instead of using your own Mac is about isolation. An agent is most useful when it can run commands without asking every time, and that is a bad idea on the machine where your password manager lives. On a rented Mac the worst case is a reset. You also get a static IP, a wired gigabit connection and a machine that does not sleep, travel or run out of battery.
What you need
- A dedicated cloud Mac with SSH access. The steps below assume a MacRent Mac Mini M4 or M6, but any Mac with full-admin rights works.
- A Claude account with Claude Code access (Pro, Max, Team or Enterprise, or an Anthropic Console API key; the free plan does not include it).
- An SSH client on your computer. Windows 10 and 11 ship one in the terminal; macOS and Linux have it built in.
- Optional: RustDesk or a VNC client for the graphical side (Xcode, the Simulator, browser testing).
Step 1: Claude Code over SSH
Your welcome email lists the IP address, username, password and SSH command. From a terminal on your own machine, run ssh username@your-mac-ip and accept the host key. The first thing to do is set up key-based login so the agent box never depends on a password you have to type: ssh-copy-id username@your-mac-ip from macOS or Linux, or paste your public key into ~/.ssh/authorized_keys on the Mac from Windows.
Step 2: Install the tools
Install Homebrew if it is not there yet (the one-line installer from brew.sh), then the basics: brew install git tmux gh. gh lets the agent open pull requests, and tmux is what keeps the session alive after you disconnect.
Install Claude Code with Anthropic's native installer, curl -fsSL https://claude.ai/install.sh | bash, which needs no Node and updates itself in the background. (brew install --cask claude-code works too but does not auto-update.) Open a new shell, check claude --version, then run claude once and follow the login prompt: it prints a URL, you open it on your own computer, approve, and the Mac is authenticated. Claude Code needs a Pro, Max, Team, Enterprise or Console account; the free plan does not include it. With an API key instead, export ANTHROPIC_API_KEY in your shell profile.
Step 3: Run Claude Code in tmux so it survives disconnects
Authenticate GitHub with gh auth login, clone your repository, and start a tmux session named after the project: tmux new -s myapp. Inside it, cd into the repo and run claude. Give it a real task, something like "run the test suite and fix what fails, then open a PR". Watch the first few actions to make sure the permissions prompts match what you expect.
When you are happy, detach with Ctrl-b d. The agent keeps running on the Mac. Close your laptop, go to lunch, reconnect later with ssh and tmux attach -t myapp and the session is exactly where you left it.
Step 4: Claude Code with Xcode and the iOS Simulator
For iOS work the agent needs Xcode. Install it from the App Store over a remote desktop session, or from the command line with xcodes (brew install xcodesorg/made/xcodes, then xcodes install --latest), which avoids the App Store login dance. Accept the licence with sudo xcodebuild -license accept and install a simulator runtime with xcodebuild -downloadPlatform iOS.
From then on Claude Code can build with xcodebuild, boot a simulator with xcrun simctl boot, run XCTest suites and read the results, all without a screen. When you want to see the app yourself, connect with RustDesk or VNC and the Simulator window is there. A 16GB Mac Mini runs Xcode, one simulator and the agent comfortably.
Step 5: Keeping a headless Mac Mini healthy
- Sleep: a MacRent Mac is configured never to sleep. On another Mac, run
sudo pmset -a sleep 0 disksleep 0. - Updates: the native install updates itself;
claude updateforces it andclaude doctorshows the install state. - Disk: Xcode, simulators and DerivedData add up.
xcrun simctl delete unavailableand clearing~/Library/Developer/Xcode/DerivedDatafree the most space. - Secrets: keep only the tokens the agent needs on the box, scoped as narrowly as the provider allows. A fine-grained GitHub token limited to the one repository is enough for most work.
- Several projects: one tmux session per repository.
tmux lsshows them all.
Checking on Claude Code from a phone
Two ways. Claude Code's own Remote Control feature lets you continue a session that is running on the Mac from the Claude app on your phone or from claude.ai, with the conversation and the code right there; Anthropic's docs describe how to enable it, and an always-on Mac is exactly the machine it is designed around. The second way needs nothing new: because the work lives in tmux, any SSH app does. Termius or Blink on iOS, Termux or JuiceSSH on Android, connect, tmux attach, and you are reading the agent's output on the train. For the graphical side, the RustDesk mobile app shows the Mac's screen, Simulator included.
What it costs
A dedicated Mac Mini M4 or M6 on MacRent is $15 for a day, $89 for a week or $159 for a month, with the machine on 24 hours a day and a static IP. Your Claude subscription or API usage is separate. For a week-long push on an iOS project that is less than a single afternoon of hosted CI minutes, and you also have a Mac for the manual parts: Xcode UI, Safari testing, the App Store upload. See the cloud Mac for Claude Code page for the short version, or rent a Mac and have the agent running within the hour.
Frequently asked questions
Why run Claude Code on a cloud Mac instead of my own computer?
Three reasons come up most: the agent keeps working when your laptop sleeps or travels, it runs on a machine that holds none of your personal files or credentials, and you get macOS tools like Xcode and the iOS Simulator even from a Windows PC. A rented Mac can be reset in minutes if something goes wrong, your laptop cannot.
Does Claude Code need a Mac?
No, it runs on macOS, Linux and Windows. A Mac matters when the project needs Apple's toolchain: building an iOS or macOS app, running the Simulator, signing and uploading to TestFlight. Those steps only work on macOS.
Can I check on the agent from my phone?
Yes. Because the session lives in tmux on the Mac, any SSH app on iOS or Android reattaches to it. Open the app, run tmux attach, and you see exactly what the agent is doing. For anything graphical, RustDesk or a VNC client works on a phone too.
How much does it cost to keep an agent running?
On MacRent a dedicated Mac Mini M4 or M6 is $15 for a day, $89 for a week or $159 for a month, with the machine on around the clock. Your Claude subscription or API usage is separate and billed by Anthropic.
Need a Mac without buying one?
Rent a dedicated Mac Mini M4 in the cloud from $15/day. Full-admin access, ready in minutes, cancel anytime.
Rent a Mac