Claude Code with tmux on Remote Servers
Running Claude Code inside tmux on a remote server is one of the most practical ways to handle long coding tasks, large repositories, and unstable laptop connections. Compared with running Claude Code locally, the remote workflow keeps your tools, files, and process alive on a persistent machine. However, it also introduces SSH security, latency, authentication, and server maintenance concerns.
Local Claude Code Versus Remote tmux
A local installation is the simplest option. Claude Code can access your editor, Git credentials, local services, and files without network hops. It is usually the best choice for small projects, quick refactors, and work that depends on a local graphical environment. The main weakness is continuity: closing the terminal, losing Wi-Fi, or putting a laptop to sleep can interrupt an active session.
A remote server with tmux separates the development environment from your device. You SSH into a VPS or dedicated machine, start a tmux session, launch Claude Code, and safely disconnect. The process continues on the server, so you can reconnect later from another computer. This is particularly useful for test suites, migrations, indexing jobs, and repositories that require more RAM or CPU than a laptop provides.
- Local advantages: lower interactive latency, easier access to desktop tools, and less infrastructure to configure.
- Local disadvantages: laptop-dependent uptime, limited compute, and more risk of interrupted sessions.
- Remote advantages: persistent sessions, consistent environments, stronger hardware, and access from anywhere.
- Remote disadvantages: SSH latency, server costs, credential management, and the need to secure the machine.
Basic Remote Setup
Start with a Linux server that has Git, your project runtime, Node.js if required by your Claude Code installation, and tmux. Use a non-root account with SSH keys. After connecting, create a persistent workspace:
tmux new -s project
Clone the repository inside that session, install dependencies, and verify the test command before asking Claude Code to modify files. To detach without stopping the process, press Ctrl-b, then d. Reconnect later with tmux attach -t project. The command tmux ls lists active sessions.
Set the API endpoint and authentication in the server environment rather than placing secrets in the repository. For a compatible relay such as 59API, the configuration commonly follows this pattern: export ANTHROPIC_BASE_URL=https://api.59api.com, followed by the authentication variable required by your Claude Code version and 59API account. Check the current provider documentation for the exact token variable and model identifiers. Use a shell profile or a restricted environment file, and never commit those values.
Why Use 59API for the Remote Workflow?
Remote development can become expensive when an agent runs for hours or handles a large codebase. 59API is a low-cost, pay-as-you-go AI API relay that provides access to Claude Opus, Sonnet, Haiku, Fable, and GPT models through https://api.59api.com. It is compatible with Claude Code, Codex, and OpenAI SDKs, so it can fit into an existing command-line workflow without changing the entire toolchain.
The practical benefit is cost control: use a faster, less expensive model for routine exploration and reserve a stronger model for architecture, debugging, or complex edits. 59API states that it routes native official-quality models rather than downgraded substitutes. A referral rebate can further reduce effective usage costs for developers who introduce other users. Before relying on any relay for sensitive code, review its current retention, privacy, rate-limit, and billing policies.
Operational Risks and Good Practices
SSH disconnections are usually manageable with tmux, but they do not protect against server reboots or storage failure. Keep the repository in Git, push meaningful checkpoints, and use a persistent disk with backups for important work. Configure SSH keepalives, but treat them as a connection improvement rather than a persistence mechanism.
Give Claude Code a clear task boundary and inspect the diff after every substantial change. Run tests, linters, and security checks on the server before merging. Restrict firewall access, disable password authentication where appropriate, apply updates, and avoid giving an agent unrestricted access to production credentials. For a low-cost, persistent Claude Code setup, you can create a 59API account and test the relay with a small pay-as-you-go budget before moving larger projects to it.
Pronto para começar?
Conecte Claude e GPT em minutos pelos menores preços, sem cortes. Cadastre-se e obtenha sua chave API.
Cadastro grátis