Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
DevOps

Browser IDE with an AI coding agent: code-server on a VPS

Set up code-server on a VPS behind an SSH tunnel or HTTPS, add a terminal coding agent such as Claude Code or OpenCode, and keep its sessions alive with tmux.

CloudSat teamNovember 18, 20266 min read
Abstract illustration of a browser window holding an editor, linked by a beam of light to a distant server rack
On this pageHow the pieces fit

A coding agent works best on a machine that never sleeps, and an editor works best when you can open it from anywhere. code-server combines the two: VS Code running on your server, used from a browser tab, with the agent in its integrated terminal. Close the laptop, open a tablet, and the same session is still there. This guide sets it up on Ubuntu 24.04 or Debian 12 in six steps, with a private and a public way in.

How the pieces fit

  • code-server runs as a systemd service under a normal user and listens on 127.0.0.1:8080 only.
  • Access goes through either an SSH tunnel (private, nothing exposed) or Caddy, which adds HTTPS and a public hostname.
  • The agent (Claude Code, Codex CLI, OpenCode or Aider) runs in the integrated terminal, inside tmux, so it survives closed tabs and dropped connections.

A server with 4 GB of RAM is a comfortable floor for the editor, a couple of language servers and an agent. Large TypeScript or Rust builds want 8 GB or more.

Step 1: create a user for the work

Run the editor and the agent as an unprivileged user, not as root, and do not give that user sudo. Whatever the agent decides to run, it can then only touch that user's files.

sudo adduser dev

Step 2: install code-server

From your admin account, preview the official install script, run it, then start the service for the new user:

curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
curl -fsSL https://code-server.dev/install.sh | sh
sudo systemctl enable --now code-server@dev

The first start writes /home/dev/.config/code-server/config.yaml with a random password:

bind-addr: 127.0.0.1:8080
auth: password
password: a-long-random-string
cert: false

Keep bind-addr on loopback. To store a hash instead of the plain password, generate one on any machine with Node.js using echo -n "your-passphrase" | npx argon2-cli -e, replace the password: line with hashed-password: "<hash>", and run sudo systemctl restart code-server@dev. A hashed password takes precedence over a plain one.

To avoid installing it by hand, pick the code-server app when you deploy on CloudSat and the server arrives with it installed; the access and hardening steps that follow apply either way.

Step 3a: private access through an SSH tunnel

This is the safest option, and the one to start with. From your own computer:

ssh -N -L 8080:127.0.0.1:8080 dev@203.0.113.10

Open http://localhost:8080 in your browser and enter the password. Nothing on the server listens publicly beyond SSH, and you need no domain or certificate.

Step 3b: public HTTPS with Caddy

When you need the editor from devices that cannot run SSH, point a hostname such as code.example.com at the server, then install Caddy from its official repository:

sudo apt install --yes debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
sudo chmod o+r /etc/apt/sources.list.d/caddy-stable.list
sudo apt update && sudo apt install caddy

Replace the contents of /etc/caddy/Caddyfile with:

code.example.com {
    reverse_proxy 127.0.0.1:8080
}

Run sudo systemctl reload caddy. Once the domain resolves to your server and it accepts traffic on ports 80 and 443, Caddy obtains a certificate by itself, and its reverse proxy forwards the WebSocket traffic code-server relies on. Allow only ports 22, 80 and 443 in your firewall; on CloudSat you can enforce that before traffic reaches the server with a cloud firewall.

Step 4: install the agent in the integrated terminal

Open the terminal in code-server (Ctrl + backtick) and install the agent you chose, for example Claude Code:

curl -fsSL https://claude.ai/install.sh | bash
claude --version

The server has no browser for the login step, which trips up most first attempts. Claude Code shows a URL to sign in with: copy it by pressing c, load it in a browser on your own computer, log in, then enter the code you receive at the Paste code here if prompted prompt. Codex CLI has a device flow for the same situation, codex login --device-auth, which shows a link and a one-time code. OpenCode and Aider can use provider API keys that you export in the shell.

Once the agent runs, give it a short instruction file for the repository. The context files guide shows what to write.

Step 5: keep sessions alive with tmux

A browser tab is a fragile home for a long agent run. Start the agent inside tmux, and it keeps running whatever happens to the tab or your connection:

sudo apt install -y tmux
tmux new -s agent
tmux attach -t agent

Use the first command once, start the agent inside the session, and detach with Ctrl+b then d. Later, tmux attach -t agent brings you back to the same screen, from the code-server terminal or from a plain SSH session.

Step 6: extensions

code-server installs extensions from the Open VSX registry. Microsoft's marketplace terms restrict it to Visual Studio products, so a few Microsoft extensions are missing and need open alternatives. Check that the extensions you rely on are published on Open VSX before you move your daily work over.

A working routine

Once everything runs, a few habits keep the editor and the agent from stepping on each other:

  1. Give each task its own worktree. The agent edits a separate checkout on its own branch, while you keep working in the main one.
  2. Split the tmux window. Press Ctrl+b then % to run the agent in one pane and your own shell, for tests and git, in the other.
  3. Review in the Source Control view. code-server shows every file the agent changed as a diff, so you read the work before you commit it.
  4. Push often. The server is a workspace, not a backup. Push branches to your git remote at the end of each session.
git worktree add ../fix-login -b fix-login
cd ../fix-login && claude

When the branch is merged, git worktree remove ../fix-login cleans up the extra checkout.

Security checklist

  • The password is a shell. Anyone who logs in to code-server gets a terminal as the dev user. Use a long passphrase. code-server limits login attempts to two per minute plus twelve per hour, which slows guessing but does not replace a strong secret.
  • Prefer the tunnel. Expose the editor publicly only when you need to. For extra protection, put an identity-aware proxy with two-factor login, such as authentik or Authelia, in front of Caddy.
  • Keep production secrets off the box. The agent reads what that user can read. Store deploy keys and cloud credentials elsewhere.
  • Branches, not main. Let the agent commit to a branch or a separate worktree, and review before merging.
  • Update. Running the install script again upgrades code-server; restart the service afterwards.

FAQ

Why not use VS Code's Remote-SSH instead?

Remote-SSH works well when you have VS Code installed locally. code-server needs only a browser, which makes it usable from a tablet, a borrowed machine or a locked-down work laptop.

Does the agent keep running if I close the tab?

Inside tmux, yes. Without tmux, a long run depends on the browser session, so start anything that takes more than a few minutes inside a tmux session.

Can several people share one code-server?

Each instance belongs to one Unix user and one password. For a team, run one instance per user on different ports, or look at platforms built for multi-user workspaces such as Coder.

Is the SSH tunnel slower than HTTPS?

Not noticeably for editing. The tunnel adds encryption that HTTPS would add anyway, and the round trip to the server is the same.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.