DevOps

Running Claude Code on Remote Servers: The Complete Setup Guide

Set up AI-powered development on your VPS, cloud instance, or remote workstation.

Your Machine
Remote Server

Why Run Claude Code Remotely?

Running Claude Code on a remote server offers several advantages:

  • Persistent sessions: Keep Claude running even when your laptop is closed
  • More resources: Use a powerful server for large codebases
  • Access from anywhere: Connect from any device, any location
  • Team collaboration: Share sessions across team members
  • Production environment: Develop directly where code will run

Prerequisites

  • A remote server (VPS, EC2, DigitalOcean droplet, etc.)
  • SSH access to the server
  • Node.js 18+ installed on the server
  • An Anthropic API key

Step 1: Install Claude Code on the Server

SSH into your server and install Claude Code:

# SSH to your server

ssh user@your-server.com

# Install Claude Code globally

npm install -g @anthropic-ai/claude-code

Step 2: Set Up Your API Key

Configure your Anthropic API key as an environment variable:

# Add to ~/.bashrc or ~/.zshrc

echo 'export ANTHROPIC_API_KEY="your-key-here"' >> ~/.bashrc

source ~/.bashrc

Security Note: Never commit your API key to version control. Use environment variables or a secrets manager.

Step 3: Use tmux for Persistent Sessions

Use tmux to keep Claude running even after you disconnect:

# Start a new tmux session

tmux new -s claude

# Start Claude Code

cd /path/to/your/project

claude

# Detach with Ctrl+B, then D

# Reattach later with:

tmux attach -t claude

Step 4: Set Up Bridge Terminal for Mobile Access

Install Bridge Terminal to control your remote session from your phone:

# Install Bridge Terminal on the server

curl -fsSL https://www.bridge-terminal.com/install.sh | sh

# Run Claude through the bridge

bridge-terminal

# Scan the QR code with the mobile app

Now you can monitor your remote Claude session from anywhere - get notifications when Claude needs input, approve changes on your phone, and never miss a critical moment.

Advanced: Headless Background Mode

For fully automated workflows, you can run Claude Code as a background service:

# Create a systemd service (Linux)

sudo nano /etc/systemd/system/bridge-terminal.service

# Service content:

[Unit]

Description=Bridge Terminal Service

After=network.target

[Service]

User=youruser

WorkingDirectory=/path/to/project

ExecStart=/usr/local/bin/bridge-terminal

Restart=always

[Install]

WantedBy=multi-user.target

Security Best Practices

  • Use SSH keys: Disable password authentication
  • Firewall rules: Only expose necessary ports
  • Keep software updated: Regularly update Node.js and system packages
  • Use secrets management: Consider HashiCorp Vault or AWS Secrets Manager
  • Monitor access: Check logs for unauthorized access attempts

Troubleshooting

Connection drops: Use tmux or screen to persist sessions.
API rate limits: Add delays between large operations.
Permission issues: Ensure proper file permissions in your project directory.

Control Remote Sessions from Your Phone

Install Bridge Terminal and never lose connection to your remote development.

Download Bridge Terminal Free
CB

Bridge Terminal Team

AI Development Tools

Related Articles