I Gave Codex a 24/7 Server. Now It Codes While I Sleep.
Tech With Tim ·2026-06-19 ·2 min read
Summary written by us from the video's transcript. The video, and everything in it, is Tech With Tim's work.
Learn how to set up a 24/7 cloud server for running Codex CLI agents, connect it securely, and control tasks from any device.
Takeaways
- A VPS prevents local interruptions for long‑running Codex agents.
- One‑click Codex deployment on Hostinger simplifies setup and includes required dependencies.
- Use `gh` with a fine‑grained token to let Codex manage GitHub repos securely.
- tmux provides persistent SSH sessions so tasks keep running after disconnection.
- Mobile SSH clients let you trigger and monitor Codex jobs from anywhere.
Why run Codex in the cloud
Running coding agents locally ties progress to your laptop’s power and internet connection. Long‑running jobs (hours or scheduled daily runs) can be interrupted by sleep mode, battery loss, or network outages. A virtual private server (VPS) stays awake, offers a wired internet link, and provides data‑center speeds, making it ideal for uninterrupted agent execution.
Choosing and provisioning a VPS
The tutorial uses Hostinger’s KVM2 plan because of reliability and a partnership discount. After selecting the plan, you choose a region (e.g., Indonesia), enable the one‑click OpenAI Codex deployment, generate a root password, and optionally add a free malware scanner. Once provisioned, the dashboard shows the server IP address for SSH access.
Installing and authenticating Codex CLI
SSH into the VPS with `ssh root@<IP>` using the generated password. Verify that the `codex` command is available; if not, run the curl install script from the Codex docs. After installation, reconnect to refresh the PATH. Sign in via device code: open the provided URL, paste the terminal code, and confirm login. The CLI is now ready for commands like a quick "hello world" test.
Connecting GitHub for repository automation
Create a free GitHub account if needed, then generate a fine‑grained personal access token (read/write or read‑only) with Repository administration, Contents, and Pull requests permissions. On the VPS install the `gh` tool (`apt install gh -y`) and log in with `gh auth login`, supplying the token. A test query to list accessible repos confirms the integration works.
Persisting sessions with tmux
Install tmux (`apt install tmux -1`). Start a named session (`tmux new -s codex`) and run Codex commands inside it. Even if you disconnect SSH, the session stays alive. Reattach later with `tmux ls` to list sessions and `tmux attach -t codex` to resume. This ensures long‑running tasks continue regardless of client connections.
Controlling the VPS from a mobile device
Download an SSH client (e.g., Terminus) on your phone, add a new host with the server IP, username root, and the root password. Connect, then attach to the tmux session (`tmux attach -t codex`). You can now issue Codex commands from the phone; the session remains active even if you switch devices or close the terminal.