You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updated the instructions for creating a Personal Access Token (PAT) for GitHub, emphasizing repo-scoped access and clarifying the importance of not using main SSH keys. Adjusted the section on SSH key generation to focus on PAT usage instead.
Copy file name to clipboardExpand all lines: docs/wsl-claude-sandbox.md
+89-31Lines changed: 89 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Isolated WSL Sandbox for Claude Code
2
2
3
-
A WSL2 Ubuntu instance configured for running `claude --dangerously-skip-permissions` with meaningful isolation from the Windows host: separate filesystem, no Windows PATH inheritance, read-only access to Windows files, no LAN reachability, sandbox-only SSH credentials.
3
+
A WSL2 Ubuntu instance configured for running `claude --dangerously-skip-permissions` with meaningful isolation from the Windows host: separate filesystem, no Windows PATH inheritance, read-only access to Windows files, no LAN reachability, sandbox-only repo credentials.
4
4
5
5
This manual covers the happy path only. Adapt commands to your own usernames, paths, and project repos.
6
6
@@ -21,13 +21,15 @@ Why: keeps the sandbox separate from your main dev environment, so a misbehaving
21
21
1. Download the Ubuntu 24.04 WSL image from <https://releases.ubuntu.com/noble/> — pick the file ending in `.wsl`.
# .NET SDK (Ubuntu 24.04 ships .NET in its own repos — no Microsoft repo needed)
171
173
sudo apt install -y dotnet-sdk-8.0
172
174
dotnet --version
173
175
176
+
# GitHub CLI (needed for PR workflows from the sandbox)
177
+
sudo apt install -y gh
178
+
gh --version
179
+
174
180
# Claude Code (Anthropic's official installer)
175
181
curl -fsSL https://claude.ai/install.sh | bash
176
182
claude --version
@@ -180,40 +186,89 @@ First run of `claude` will walk you through authentication via browser.
180
186
181
187
---
182
188
183
-
## Step 6: Generate a sandbox-only SSH key and clone
189
+
## Step 6: Create a repo-scoped PAT and clone
190
+
191
+
Why: don't give the sandbox access to your whole GitHub account. A fine-grained Personal Access Token scoped to a single repo means a compromised sandbox can only damage that one repo — every other repo on your account is invisible to it. This single token handles both git operations (clone, fetch, push over HTTPS) **and**`gh` CLI operations (PR create, comment) — no separate SSH key needed.
192
+
193
+
### 6a. Generate the PAT on GitHub
194
+
195
+
In your browser, go to <https://github.com/settings/personal-access-tokens/new> and fill in:
Should fail with `403 - Write access to repository not granted` or `Repository not found`. That failure is the proof your isolation is working — clean up with `rm -rf /tmp/test`.
265
+
266
+
Note: cloning a *public* repo will still succeed (anyone on the internet can clone public repos, with or without auth). The real test of isolation is whether private repos are reachable.
267
+
268
+
### 6f. Token rotation
269
+
270
+
The PAT expires on the date you chose. When that day comes, GitHub will email you. To renew: generate a new PAT at the same URL with the same settings, then edit the `GH_TOKEN` line in `~/.bashrc` and `source ~/.bashrc`. Under a minute's work.
271
+
217
272
---
218
273
219
274
## Step 7: Connect VS Code
@@ -226,7 +281,7 @@ Why: VS Code's WSL extension installs a server inside the sandbox and connects t
226
281
4.`File → Open Folder` → `/home/<username>/projects/<repo>` → Open.
227
282
5. When prompted, install the **C# Dev Kit** (Microsoft) **into WSL: Ubuntu-Claude**, not locally.
228
283
229
-
The integrated terminal (`Ctrl+\``) runs inside the sandbox. Confirm by checking the prompt shows your sandbox hostname.
284
+
The integrated terminal (`Ctrl+``) runs inside the sandbox. Confirm by checking the prompt shows your sandbox hostname.
230
285
231
286
---
232
287
@@ -236,29 +291,32 @@ Why: rollback insurance. If Claude trashes the instance later, restore from a sn
Note: snapshots include `~/.bashrc` with the PAT in it. Treat the tar files as sensitive — anyone who can read them gets the token (scoped to your one repo, but still). Don't sync them to cloud storage, share them, or check them into version control.
314
+
257
315
---
258
316
259
317
## Step 9: Run Claude
260
318
261
-
```bash
319
+
```
262
320
cd ~/projects/<repo>
263
321
claude --dangerously-skip-permissions
264
322
```
@@ -267,7 +325,7 @@ claude --dangerously-skip-permissions
267
325
268
326
## Operational notes
269
327
270
-
**Don't put real credentials in this sandbox.** No AWS/Azure/GCP CLI logins, no production API keys, no SSH keys from your main account. The SSH key created here should be sandbox-only.
328
+
**Don't add other credentials to this sandbox.** No AWS/Azure/GCP CLI logins, no production API keys, no SSH keys, no `gh auth login` (which would replace your scoped PAT with an account-wide OAuth token). The PAT created in step 6 should be the *only* credential.
271
329
272
330
**Don't `cd` into mounted Windows directories for project work.** Files at `/mnt/c/...` are read-only and slow over 9P. Keep work in `~/projects/`.
0 commit comments