Claude Code — Remote SSH Connection Setup (Windows)
Claude Code — Remote SSH Connection Setup (Windows)
Prerequisites
- Claude Code desktop app installed on Windows
- Target machine running Linux/macOS on your LAN
- OpenSSH client installed on Windows (built-in since Windows 10 1809)
- Network access between the two machines
Step 1 — Verify OpenSSH is installed on Windows
Open PowerShell as Administrator and run:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Client*'
If the state shows NotPresent, install it:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Step 2 — Fix "Host denied (verification failed)"
This error means SSH cannot verify the remote machine's host key.
Option A — Remove stale host key (most common fix)
# Replace 192.168.1.x with your remote machine's IP
ssh-keygen -R 172.17.1.x
Then test the connection manually to accept the new key:
ssh root@172.17.1.x
# Type "yes" when prompted about the host fingerprint
Option B — Edit known_hosts manually
Open the file:
notepad C:\Users\YourUsername\.ssh\known_hosts
Find and delete the line containing your remote machine's IP or hostname, then save.
Option C — First-time connection (no prior key)
Just connect once manually and accept the fingerprint:
ssh root@172.17.1.x
# Answer "yes" at the prompt
Step 3 — Generate an SSH key pair (skip if you already have one)
# Check for an existing key first
dir C:\Users\YourUsername\.ssh\id_ed25519
# If no key exists, generate one
ssh-keygen -t ed25519 -C "your_email@example.com"
# Press Enter to accept the default path
# Set a passphrase or leave it blank
Step 4 — Copy your public key to the remote machine
From Windows PowerShell:
# Replace user and IP with your values
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh root@172.17.1.x "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
If that fails, do it manually:
- Print your public key:
type C:\Users\YourUsername\.ssh\id_ed25519.pub - Copy the output.
- SSH into the remote machine with a password:
ssh root@172.17.1.x - On the remote machine:
mkdir -p ~/.ssh echo "PASTE_YOUR_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys chmod 700 ~/.ssh
Test passwordless login:
ssh root@172.17.1.x
# Should log in without a password prompt
Step 5 — Install Claude Code on the remote machine
Claude Code must be installed on the remote machine for remote development to work.
# On the remote Linux machine
npm install -g @anthropic-ai/claude-code
Verify:
claude --version
Step 6 — Add SSH config entry (recommended)
This makes connections easier and is required by Claude Code's remote feature.
Open or create C:\Users\YourUsername\.ssh\config in a text editor:
notepad C:\Users\YourUsername\.ssh\config
Add an entry:
Host myserver
HostName 172.17.1.x
User your_username
IdentityFile ~/.ssh/id_ed25519
ServerAliveInterval 60
ServerAliveCountMax 3
Test it:
ssh myserver
Step 7 — Connect from Claude Code (Windows app)
Method A — Via the GUI
- Open the Claude Code desktop app.
- Click the remote connection icon (or go to File → Connect to Remote).
- Enter the SSH connection string:
Or if you set up a config alias in Step 6:ssh://root@172.17.1.xssh://myserver - Select the remote working directory you want to open.
- Click Connect.
Method B — Via the terminal inside Claude Code
Open the integrated terminal in Claude Code and run:
# Navigate to a remote project
claude --remote ssh://root@172.17.1.x /path/to/project
Method C — Launch from PowerShell
claude --remote ssh://myserver /home/user/myproject
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
Host denied (verification failed) |
Stale or missing host key | Run ssh-keygen -R <ip> then reconnect |
Permission denied (publickey) |
Key not on remote | Repeat Step 4 |
Connection refused |
SSH not running on remote | sudo systemctl start ssh on remote |
Connection timed out |
Firewall or wrong IP | Check firewall, verify IP with ip addr on remote |
claude: command not found on remote |
Claude Code not installed | Repeat Step 5 |
Quick Reference
# Remove stale host key
ssh-keygen -R 192.168.1.x
# Test SSH connection
ssh user@192.168.1.x
# Test SSH config alias
ssh myserver
# Copy public key to remote
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh user@192.168.1.x "cat >> ~/.ssh/authorized_keys"
# Connect Claude Code to remote
claude --remote ssh://myserver /home/user/project
File Locations
| File | Path |
|---|---|
| SSH private key | C:\Users\YourUsername\.ssh\id_ed25519 |
| SSH public key | C:\Users\YourUsername\.ssh\id_ed25519.pub |
| Known hosts | C:\Users\YourUsername\.ssh\known_hosts |
| SSH config | C:\Users\YourUsername\.ssh\config |
No comments to display
No comments to display