How to Run Claude Code 24/7 on a VPS

Simon Scrapesgo watch the original →

Move your Claude Code agent from a local laptop to a persistent VPS to ensure agentic workflows continue running even when your machine is offline, accessible from any device via SSH.

The Case for Persistent Agentic Infrastructure

Running Claude Code on a local machine is limited by the machine's power state; closing the lid or losing connectivity halts all active agentic tasks. By migrating to a Virtual Private Server (VPS), the agent gains a persistent environment that remains online 24/7. This setup allows for scheduled jobs, continuous file monitoring, and remote accessibility from any device, effectively turning the VPS into an "always-on" agentic operating system.

Establishing Secure Remote Access

The core mechanism for this setup is SSH (Secure Shell). By generating an ED25519 key pair, the user creates an encrypted bridge between their local machine and the remote server. This replaces password-based authentication with a more secure key-based system. The process involves generating the keys locally, uploading the public key to the VPS provider, and configuring a local SSH config file to simplify future connections to a single command.

Provisioning and Server Configuration

While manual VPS management is possible, using a service like Allesio (or similar providers) simplifies the process by handling backups, monitoring, and initial provisioning. Once the Ubuntu server is deployed, the user connects via VS Code’s Remote-SSH extension. This allows the developer to treat the remote server's file system as if it were local, enabling seamless editing and terminal access directly within the VS Code interface.

Environment Setup and Deployment

To maintain security and best practices, the tutorial advises against running agents as the root user. A new user account is created with appropriate permissions. Once the environment is ready, Claude Code is installed via the terminal, and the user authenticates their subscription. Finally, existing GitHub repositories containing agentic context, skills, or workflows are cloned onto the server, allowing the agent to operate on the same file structure it would have used locally.

Key Takeaways

  • Persistence: Moving agents to a VPS prevents workflow interruptions caused by local machine sleep or network drops.
  • Security: Use SSH key pairs (ED25519) rather than passwords for server access.
  • Workflow: VS Code’s Remote-SSH extension provides a near-native experience for managing remote files and terminals.
  • Best Practice: Always create a non-root user for running agentic tasks to isolate permissions and improve security.
  • Portability: This architecture is provider-agnostic; the same file structure can be moved to other services or tools (like Codeium) if requirements change.
  • #tutorial
  • #dev-tooling
  • #ai

summary by google/gemini-3.1-flash-lite. probably wrong about something. check the source.