> The full list of articles is in [llms.txt](https://docs.f3cloud.com/llms.txt). Every page has a Markdown version: add .md to its address. This page as Markdown: [https://docs.f3cloud.com/en/software-setup/claude-code-on-vps.md](https://docs.f3cloud.com/en/software-setup/claude-code-on-vps.md).

# Claude Code on a VPS – installation, login and working through the app

How to install Claude Code on a VPS, log in to your account on a server without a browser and control the session from your computer or phone in the Claude app with Remote Control.

**Claude Code** is Anthropic's AI coding assistant that runs in the terminal. On a server it writes and edits code, runs commands and helps configure software. With **Remote Control**, you can drive a session on the server from the Claude app on your computer or phone.

### What you need

| What     | Requirements                                                                       |
| -------- | ---------------------------------------------------------------------------------- |
| Server   | Ubuntu 22.04, 24.04 or Debian 12 with at least 4 GB of RAM – the **DE-RZ9-2** plan fits |
| Account  | Claude Pro, Max, Team or Enterprise. The free plan does not include Claude Code    |
| Computer | A browser for logging in and the Claude app on a PC or phone for Remote Control    |
| Access   | SSH to the server – see the [Termius article](https://docs.f3cloud.com/en/vps/termius-connection.md)        |

### Step 1. Preparing the server

Connect to the server as root, install git and tmux, and create a separate user. Running Claude Code as root is unnecessary and unsafe.

```bash
apt update && apt install -y git tmux
adduser dev
```

From now on, work as this user – switch with `su - dev` or connect straight away as `ssh dev@IP-address`.

<details>

<summary>Should the user get sudo rights</summary>

If Claude Code needs to install packages or change system settings, add the user to the sudo group with `usermod -aG sudo dev`. Each such command still requires your confirmation and password. If Claude only works with code in the home directory, it is better not to grant sudo.

</details>

### Step 2. Installing Claude Code

Run the official installer as the `dev` user:

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

Check the installation:

```bash
claude --version
claude doctor
```

If the system says `claude: command not found`, log in to the server again or run `source ~/.profile`. Node.js is not required, and Claude Code installs updates by itself in the background.

### Step 3. Logging in

The server has no browser, so you log in through your computer. Choose the method that suits you.

#### Browser on your PC

We recommend this method, because only with it does control from the app (Remote Control) work. You need a computer with a browser and an open SSH connection to the server.

1. **Start Claude Code.** Connect to the server as the `dev` user, type `claude` and press Enter.
2. **Answer the first questions.** On the first run, Claude Code offers to choose a colour theme. Pick any with the arrow keys and press Enter. If screens with explanations appear, just press Enter.
3. **Choose how to log in.** Pick the first option in the list – logging in with a Claude account with a subscription (Claude account with subscription) – and press Enter.
4. **Copy the link.** The server cannot open a browser, so Claude Code shows a long link. Press the `c` key and the link is copied. If that does not work, select the whole link with the mouse (it may take several lines) and copy it.
5. **Open the link on your computer.** Paste it into the browser's address bar, log in to your Claude account and confirm access with the Authorize button.
6. **Copy the code.** After you confirm, the browser shows a code. Copy it with the button next to the code.
7. **Paste the code on the server.** Go back to the server window, where you will see the line “Paste code here if prompted”. Paste the code (in Termius with a right click, in other programs with `Ctrl+Shift+V` or `Cmd+V`) and press Enter.
8. **Done.** You will see `Login successful`. Press Enter and Claude Code opens. If it asks whether you trust the files in this folder, choose “Yes, proceed”.

> **Tip.**
>
> The code works only once. If you get an error or a lot of time has passed since you logged in, type `/login` in Claude Code and repeat steps 3–8.

#### Token from Claude Code on your PC

If Claude Code is already installed on your computer, you can issue a long-lived token (valid for about a year).

1. On your **computer**, run `claude setup-token`, confirm access in the browser and copy the token.
2. On the **server**, save the token in the shell settings:

```bash
echo 'export CLAUDE_CODE_OAUTH_TOKEN=your-token' >> ~/.bashrc && source ~/.bashrc
```

> **Warning.**
>
> With this token, Claude Code answers requests but **cannot start Remote Control**. If you plan to work through the app, log in through the browser.

#### API key

For Anthropic Console billing, create a key at [platform.claude.com](https://platform.claude.com) and save it on the server:

```bash
echo 'export ANTHROPIC_API_KEY=your-key' >> ~/.bashrc && source ~/.bashrc
```

> **Warning.**
>
> Remote Control is not available with an API key – it only works with a Claude subscription.

### Step 4. Working in the terminal

Go to the project directory and start Claude Code:

```bash
mkdir -p ~/project && cd ~/project
claude
```

Describe the task in plain words, for example “create a simple Flask site and run it on port 5000”. Claude Code asks for permission before changing files and running commands.

| Command             | What it does                                      |
| ------------------- | ------------------------------------------------- |
| `claude`            | A new session in the current directory            |
| `claude --continue` | Continue the last session                         |
| `claude --resume`   | Pick a session from a list                        |
| `/remote-control`   | Open the current session for control from the app |
| `Shift+Tab`         | Switch the permission mode                        |
| `/exit`             | Leave the session                                 |

### Step 5. Working through the app (Remote Control)

Remote Control keeps the session on the server, and you write to it from the Claude app on your computer or phone. To keep the session alive when SSH disconnects, run it in tmux.

**1.** Create a tmux window and start Remote Control in the project directory:

```bash
tmux new -s claude
cd ~/project && claude remote-control --name "My server"
```

On the first run, confirm enabling the feature by typing `y`.

**2.** Detach from the tmux window with `Ctrl+B`, then `D`. The session keeps running even if you close SSH.

**3.** Connect to the session in one of these ways:

* in the **Claude app** on your computer or phone, open the Code section and choose the “My server” session – a running session has a green indicator;
* scan the **QR code** with your phone – to show it, go back to tmux and press the space bar;
* open the `https://claude.ai/code/...` link that Claude Code prints in the terminal in a browser.

You can return to the tmux window with `tmux attach -t claude`.

<details>

<summary>How it works and what to know</summary>

* **No ports need to be opened.** The server connects to Anthropic over HTTPS itself, and there are no incoming connections.
* **A subscription is required.** Remote Control works when you log in with a Claude Pro, Max, Team or Enterprise account. In Team and Enterprise, the organisation owner must enable the feature first.
* **Sessions can be continued.** After stopping, a session can be resumed with `claude remote-control --continue`.
* **A session that is already open** can be switched to Remote Control with `/remote-control` right inside Claude Code.

</details>

> **Note.**
>
> **You cannot yet connect to the server over SSH directly from the Claude app on your PC.** Such connections are currently in beta and only available to enterprise customers working through the Amazon, Google and Microsoft cloud platforms. With a regular subscription, use Remote Control from this step.

### Security

* **A separate user** – do not run Claude Code as root.
* **No `--dangerously-skip-permissions` flag** on a working server – with it, Claude Code can change or delete any of the user's files without asking. This mode only suits disposable containers.
* **Plan mode** – if you want to see the plan of action first, switch to it with `Shift+Tab`.
* **Login data** is stored in `~/.claude/.credentials.json`. Do not give outsiders access to the user Claude Code runs as.
* **SSH keys** – set up key-based login and disable password login using our [server protection guide](https://docs.f3cloud.com/en/client-area/protect-vps-from-unauthorised-access.md).

### If something does not work

| Symptom                                | What to do                                                                         |
| -------------------------------------- | ---------------------------------------------------------------------------------- |
| `claude: command not found`            | Log in to the server again or run `source ~/.profile`                              |
| The browser does not open on the server | This is normal – copy the link with `c` and open it on your computer              |
| Remote Control does not start          | Log in through the browser with `/login` – the feature does not work with a token or an API key |
| The session disappeared after SSH disconnected | Run Claude Code inside tmux, as in step 5                                  |
| Slow work or not enough memory         | Claude Code needs at least 4 GB of RAM – choose DE-RZ9-2 or higher                 |
