Claude Code guide · Chapter 7 of 10
Claude Code over SSH, in Docker and on your own server
Claude Code can work on another machine of yours, such as a server or a virtual machine, while you steer it from the desktop app or your terminal. Over SSH, the app installs it on the remote machine by itself; in Docker, a dev container keeps everything Claude runs inside the container. Here are both paths, what the machine needs and how to set it up without opening holes.

Chapter 7 of 10 · See all
What does it mean to use Claude Code over SSH?
Using Claude Code over SSH means putting it to work on another machine of yours (a server, a cloud virtual machine or a more powerful computer) while you steer it from the desktop app or from the terminal on your laptop. Claude Code runs on that machine: it reads its files, runs commands there and reaches the internet from there. Your laptop is only the screen.
- SSH
- The protocol for an encrypted connection to another machine, so you can work on it as if you were sitting in front of it. You usually sign in with an SSH key instead of a password.
- Claude Code SSH session
- A session of the Claude desktop app that runs on a remote machine. The app installs Claude Code there the first time you connect.
- Dev container
- A Docker container defined in the repository itself (the
.devcontainer/devcontainer.jsonfile), the same for the whole team. What Claude runs stays inside the container.
This is the third of the places where Claude Code can live. If you are not sure which one fits you, the chapter Where Claude Code runs compares them. And if you want a machine you don’t have to maintain, Anthropic’s cloud is covered in Claude Code on the web.
Claude Code over SSH and in Docker: 6 quick answers
The most common questions, with short answers. Everything was checked in the official docs on November 18, 2026.
- What is it for? For working on code that lives on another machine: a cloud VM, a server with more memory or a GPU, or a setup with dependencies you don’t want on your laptop.
- How do you connect? In the desktop app, in the environment selector, with New environment and the SSH tab. You can also SSH in from your terminal and install Claude Code there like on any computer.
- Which machines work? Linux, macOS or Windows, with an x86_64 or arm64 processor, an SSH server with SFTP and internet access. The app installs Claude Code by itself the first time.
- Does it keep working if I close my laptop? In a desktop app SSH session, the task keeps running on the remote machine even if your computer sleeps. One catch: with a Claude account, the task’s sign-in can expire while you are disconnected.
- What about Docker? With a dev container, the commands Claude runs stay inside the container, and your project files show up in your repository. Anthropic publishes an official “feature” to install it.
- How much does it cost? The same as Claude Code on your computer: a paid Claude plan, starting with Pro at $20 a month, or $17 a month billed annually ($200 up front), plus applicable tax. If the remote machine comes from a cloud provider, you pay for it separately.
When working on another machine makes sense
Claude Code on your own computer is the simplest option, and Anthropic’s cloud is the most convenient one. SSH makes sense in three cases:
| Situation | Why SSH |
|---|---|
| The code lives on a server or a VM | No need to copy it to your laptop: Claude works where the code is |
| You need more power | A machine with more memory, more CPUs or a GPU than Anthropic’s cloud, which has about 4 CPUs and 16 GB of RAM |
| The project needs something that only exists there | A test database, an internal network or tools you don’t want on your computer |
If none of these apply, keep it simple: install it on your computer with How to install Claude Code or use the cloud.
How to connect Claude Code to a machine over SSH
There are two ways. The desktop app is the most comfortable: you see the changes, comment on lines and the app takes care of installing Claude Code. The terminal is the classic way: you log in to the machine and use Claude Code as you would on your computer.
- Open the environment selector. Before you start a session, open the selector under the prompt box and choose New environment.
- Add the connection. On the SSH tab, open the Host list and choose Add SSH connection…. Fill in a name, the SSH host (
user@hostnameor a host from your~/.ssh/config), the port if it isn't 22, the key if you don't use your SSH config or agent, and the folder for new worktrees (Worktree folder). - Pick the folder and create the environment. Select the project folder on the remote machine and click Create environment. The machine and folder are saved for future sessions.
- Type your task. The first time, the app installs Claude Code on the machine. After that, permission modes, connectors, plugins and MCP servers all work.
- Log in to the machine.
ssh user@hostname, as usual. - Install Claude Code there. On Linux or macOS,
curl -fsSL https://claude.ai/install.sh | bash, just like on your computer. Check it withclaude --version. - Sign in. Type
claudein the project folder. If no browser opens, copy the sign-in link the terminal shows, open it on your computer and paste the code it gives you. - Keep it alive. If you close the SSH connection, the session stops. Start it inside
tmuxorscreenso it keeps going, and if you want to steer it from your phone, add Remote Control (see the mobile chapter).
What the remote machine needs
The docs list five requirements for a Linux or macOS machine:
- An x86_64 or arm64 processor and the Claude Code system requirements. On Linux, glibc 2.17 or later, or musl (for example, Alpine with its packages).
- An SSH server with SFTP. Check it with
sftpfrom your computer: if you get thesftp>prompt, you’re fine. - An install folder that can run programs. The app installs a helper and Claude Code in
~/.claude/remote/, so that folder can’t be on a disk mounted withnoexec. Plan for about 1 GB per user. - A regular shell (Bash, Zsh or
sh). - Internet access from the machine, because Claude Code makes its requests from there. If the machine uses a proxy or its own certificate, set it in
~/.claude/settings.jsonon that machine, not in your.bashrc.
If the server limits SSH sessions to one (MaxSessions 1), update the app or raise that limit: the app opens several connections.
The first time: check the server’s host key
The first time you connect, the app asks whether you trust the machine and shows its fingerprint. Don’t accept without looking. Ask whoever runs the server for the fingerprint, or get it yourself on the machine with ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub, and compare. If it doesn’t match or you can’t check it, don’t connect: someone could be sitting in the middle of the connection.
If you disconnect: what happens to the task
In a desktop app SSH session, Claude Code runs on the remote machine under a helper process, so it doesn’t need your connection to keep going. If your laptop sleeps, you lose the network or you close the app, the task keeps running until it finishes, needs something from you or hits one of its limits. The work stays on the remote machine, and you continue with a message when you come back.
There is one important catch: if you sign in to the app with your Claude account, the app refreshes the task’s sign-in only while it is open and connected. Once you disconnect, that sign-in can expire, sometimes within minutes, and the task stops. For something that has to run all night, the docs say to keep your computer awake, with the app open and signed in. If it has to keep going with your computer off, use a cloud session.
The terminal works the other way around: if you close the SSH connection without tmux or screen, the session ends.
Claude Code in Docker: dev containers
A development container (dev container) defines, inside the repository, an identical and isolated environment for everyone who works on the project. With Claude Code inside, the commands it runs execute in the container and not on your computer, while the changes to your project files show up in your repository. It works with editors that support the Dev Containers standard, such as VS Code, GitHub Codespaces, JetBrains IDEs and Cursor.
To add it, Anthropic publishes an official “feature”. This is the example from the docs, in .devcontainer/devcontainer.json:
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}
}
}
Then rebuild the container (in VS Code, Dev Containers: Rebuild Container), open a terminal inside it and type claude to sign in. The :1.0 pins the install script, not the Claude Code version, which updates itself.
Three things worth knowing:
- Every rebuild wipes the sign-in. To avoid doing it again, mount a volume at
~/.claudeand set theCLAUDE_CONFIG_DIRvariable to that same path, as the docs explain. - You can limit outbound internet access. Anthropic’s reference container ships with a firewall (
init-firewall.sh) that only lets traffic out to allowed domains. It isn’t required, but it is the piece that really isolates the container. - Skipping permissions is possible, not free. Inside the container, with a non-root user, you can use
–dangerously-skip-permissionsto work without prompts. The docs warn that, this way, the container does not stop a malicious project from taking whatever is inside, including your Claude Code credentials. Only use it with trusted repositories and limited outbound access. If you want fewer prompts without removing the protection, Auto mode is an alternative.
Self-hosted environments, for companies
There is a fourth option, for organizations only. Self-hosted environments make Claude Code cloud sessions run inside the company’s network, on its own machines, instead of on Anthropic’s. Developers start them the same way, from claude.ai/code, the mobile app or claude –cloud, and the company provides the runners that execute them, like in a CI system.
As of November 18, 2026, it is in public beta for Team and Enterprise plans and is turned off by default. If you work on your own and want to use a machine of yours that is always on, the docs recommend something else: Remote Control, which is also available on Pro, Max and Ultra.
Security: SSH keys, containers and what can leak
Working on another machine changes where the risk is. It doesn’t remove it. What I would watch:
- One SSH key per use. Create a key just for this connection (for example,
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_test) and don’t reuse the one that opens production. If something goes wrong, you revoke it without touching anything else. - A user with only the permissions it needs on the remote machine, not root. What Claude can do there is what that user can do.
- Don’t put your secrets in the container. The docs say not to mount
~/.sshor cloud credential files inside the container, and to use repository-scoped or short-lived tokens. - Watch what it reads. Claude Code on your server also reads web pages, issues and documents. If it also has your keys and can send data out, it combines what the security chapter calls the lethal trifecta.
- Be careful with ports. The app’s helper doesn’t open any port, but Claude Code and what it starts (a dev server, an MCP server) can. To see your site, forward the port to your computer with
ssh -Linstead of opening it to the internet. - Check the server’s fingerprint the first time, as described above.
Common mistakes
- Accepting the server’s fingerprint without checking it. That is exactly the moment someone could be in the middle.
- Using your production key so Claude can work on a test server.
- Expecting the task to run all night in an SSH session with your Claude account and the app closed. The sign-in can expire and the task stops.
- Setting the proxy in
.bashrc. In a desktop app SSH session, Claude Code doesn’t read those variables: they go in~/.claude/settings.jsonon the remote machine. - A
noexecfolder in the user’s home directory on the server. The install fails. - Closing the terminal’s SSH connection without
tmuxorscreen. The session ends. - Rebuilding the container and signing in again every time. Mount the volume at
~/.claudewithCLAUDE_CONFIG_DIR. - Skipping permissions in a container with open internet access. If you remove the prompts, limit outbound traffic first.
- Creating the PR from the app without preparing the machine. In an SSH session, the branch is pushed and the PR is created from the remote machine: install
gitandghthere, and check thatgit pushworks and thatgh auth statussays you are signed in.
What I would keep in mind
SSH is the option for when the code already lives on another machine or you need more power. For almost everything else, I would start with my own computer or with Anthropic’s cloud, where there is nothing to maintain.
If I set it up, I would do it like this:
- A machine for Claude, not the production one. A test server or a VM I can delete and create again.
- Its own SSH key and its own user, with only what they need.
- The project in a dev container, with limited outbound access, if I’m going to let it work without prompts.
- Long tasks in the cloud, which don’t depend on my app staying open.
And one rule that applies on any machine: anything that can’t be undone (publishing, deleting, deploying) gets my approval first.
FAQ
How do you use Claude Code over SSH?
In the Claude desktop app, open the environment selector, choose New environment and the SSH tab, and add the connection with the host, port, key and worktree folder. Then pick the project folder on the remote machine and type your task: the app installs Claude Code there the first time. You can also SSH in from your terminal and install Claude Code on the machine like on any computer.
What does a server need to run Claude Code?
According to the docs, a Linux or macOS machine with an x86_64 or arm64 processor, an SSH server that offers SFTP, a home folder that is not mounted with noexec (with about 1 GB free), a shell such as Bash or Zsh, and internet access, because Claude Code makes its requests from there. It can also be Windows.
Does the task keep running if I close my laptop?
In a desktop app SSH session, yes: Claude Code runs on the remote machine and keeps going even if your computer sleeps or you close the app. But if you signed in with your Claude account, the task's sign-in can expire while you are disconnected, and then it stops. For something that has to run with your computer off, use a cloud session.
How do you install Claude Code in Docker?
With a dev container: add the ghcr.io/anthropics/devcontainer-features/claude-code feature to the .devcontainer/devcontainer.json file in the repository, rebuild the container and type claude in a terminal inside it to sign in. It works with VS Code, GitHub Codespaces, JetBrains IDEs and Cursor.
Is it safe to use --dangerously-skip-permissions in a container?
It lowers the risk but doesn't remove it. The docs warn that, with that option, the container doesn't stop a malicious project from taking what is inside, including your Claude Code credentials. Only use it with trusted repositories, a non-root user and limited outbound access, and don't mount your SSH keys or cloud credentials inside.
What are Claude Code self-hosted environments?
A way for Claude Code cloud sessions to run on a company's own machines, inside its network, instead of on Anthropic's. As of November 18, 2026, they are in public beta for Team and Enterprise plans and are off by default. For one person with a machine that is always on, the docs recommend Remote Control.
Can I use my ~/.ssh/config?
Yes. On macOS and Linux the desktop app connects with your computer's OpenSSH client, so you can type the name of a Host from your ~/.ssh/config, with its user, key or ProxyJump. On Windows too, if you meet the app and OpenSSH version requirements in the docs.
Sources
- Claude Code Docs, Use Claude Code Desktop: SSH sessions (accessed Nov 18, 2026)
- Claude Code Docs, Development containers (accessed Nov 18, 2026)
- Claude Code Docs, Self-hosted environments (accessed Nov 18, 2026)
- Claude Code Docs, Troubleshoot installation (accessed Nov 18, 2026)
- Claude Code Docs, Remote Control: limitations (accessed Nov 18, 2026)
- Anthropic, Claude Code Dev Container Feature (GitHub)
- Claude, Plans and pricing (accessed Nov 18, 2026)