Skip to content

Latest commit

 

History

History
105 lines (65 loc) · 3.41 KB

File metadata and controls

105 lines (65 loc) · 3.41 KB

Cursor with this devcontainer (GitHub Codespaces)

Use a GitHub Codespace for this repo, then attach Cursor with Remote - SSH using the GitHub CLI (gh codespace ssh). Authentication is handled by GitHub and gh.

The devcontainer includes the sshd feature so Codespaces SSH works as documented by GitHub.

After the Codespace starts, run task setup REPO=org/repo PR=123 to bootstrap a codecollection. See the README for full details.

Further reading


1. sshd in devcontainer.json

"ghcr.io/devcontainers/features/sshd:1": {
    "version": "latest"
}

Rebuild the devcontainer after changing features.


2. GitHub CLI

Install GitHub CLI (gh). If gh codespace ssh misbehaves, update to a recent gh release.


3. List codespaces and open a shell

gh codespace list

gh codespace ssh -c YOUR_CODESPACE_NAME --

Use your codespace name from the list. Shell user is runwhen.


4. SSH config for Cursor

gh codespace ssh -c YOUR_CODESPACE_NAME --config >> ~/.ssh/codespaces

Edit the new Host block:

  • Remove IdentityFile …/codespaces.auto
  • In ProxyCommand, remove -i …/codespaces.auto; keep gh cs ssh … --stdio -- (end with -- only)

Example:

Host cs.YOUR_CODESPACE_NAME.remote-updates
  User runwhen
  ProxyCommand ... gh cs ssh -c YOUR_CODESPACE_NAME --stdio -- -i ~/.ssh/codespaces.auto
  IdentityFile ~/.ssh/codespaces.auto
  ...

After editing, ProxyCommand should end with --stdio -- and there should be no IdentityFile for codespaces.auto.

Bulk cleanup example:

sed -i.bak \
  -e 's|IdentityFile .*/\.ssh/codespaces\.auto||g' \
  -e 's|-i .*/\.ssh/codespaces\.auto||g' \
  ~/.ssh/codespaces

In Cursor: Remote-SSH: Connect to Host… → select that host → Open Folder/workspaces/codecollection-devtools (the devcontainer workspace root). After task setup, the codecollection/ symlink gives you direct access to codebundles.


5. Troubleshooting

  • Run gh codespace ssh -c YOUR_CODESPACE_NAME -- again if the connection or auth state seems off.
  • SSH permission errors should not occur — the image and postCreateCommand set /home/runwhen (755), .ssh (700), and authorized_keys (600) automatically.

6. Codespace lifecycle

Stop or delete codespaces in GitHub when you no longer need them.


7. Local Docker and direct SSH (optional)

The sshd feature listens on port 2222 inside the container by default. This repo’s devcontainer.json forwards 3000 (logs) only; local workflows typically use Dev Containers: Reopen in Container. For SSH from the host, publish port 2222 and follow the feature docs (for example key-based login).


Related