Skip to content

feat(box): land interactive SSH/login shells in /workspace#124

Merged
madarco merged 1 commit into
nightlyfrom
ssh-login-start-in-workspace
Jun 27, 2026
Merged

feat(box): land interactive SSH/login shells in /workspace#124
madarco merged 1 commit into
nightlyfrom
ssh-login-start-in-workspace

Conversation

@madarco

@madarco madarco commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Problem

Adding a box as a remote host (Codex app, VS Code Remote-SSH, or plain ssh <box>) opened the session in /home/vscode instead of the project at /workspace, forcing the user to navigate there every time.

SSH config has no start-directory directive. The only client-side option — RemoteCommand cd /workspace && exec $SHELL -l — would break the shared agentbox Host block for scp/sftp (agentbox open sshfs) and VS Code's remote bootstrap (agentbox code). So the fix is server-side.

Change

Make interactive login shells cd /workspace via the existing /etc/profile.d/agentbox.sh shim every box already installs:

case $- in
  *i*)
    if [ "$PWD" = "$HOME" ] && [ -d /workspace ]; then
      cd /workspace
    fi
    ;;
esac

Guarded so it's safe:

  • interactive-only (case $- in *i*) → scp/sftp and ssh box <cmd> are untouched
  • only when at $HOME → never overrides a caller-chosen dir (agentbox's own tmux -c /workspace stays a no-op)
  • -d /workspace → never cd into a missing dir

Applied to all provider login-shell shims for consistency: hetzner (install-box.sh), vercel (provision.sh), e2b (build-template.sh), and the canonical docker Dockerfile.box (regenerated runtime copy follows on build).

E2E results (live Hetzner)

Re-baked the Hetzner snapshot with the updated install-box.sh, created a real box (sshdir), and verified against the live VPS:

# Check Result
1 Interactive login shell (Codex-app / VS Code Remote-SSH / plain ssh sshdir) Lands in /workspace — prompt vscode@...:/workspace$, pwd -> /workspace
2 Non-interactive ssh sshdir pwd Stays in /home/vscode — guard skips ($- = hBc, no i)
3 scp file sshdir:/workspace/ (sftp subsystem) Succeeds; file read back

Box destroyed and Hetzner VPS/firewall/SSH-alias cleanup confirmed (no orphans). Also syntax-checked the generated shim under both bash -n and sh -n.

https://claude.ai/code/session_01An9tT8HqjQoGKKVWuYg4bb


Note

Low Risk
Shell startup-only change with explicit interactive and PWD guards; no auth or application logic touched. Effect is limited to new image/template bakes until providers are refreshed.

Overview
Interactive login shells now cd /workspace when the session still starts in $HOME, so Remote-SSH, Codex remote hosts, and plain ssh <box> open in the project tree instead of /home/vscode.

The behavior is added to the existing /etc/profile.d/agentbox.sh shim across docker, hetzner, vercel, and e2b bake/install paths. Guards keep it interactive-only (case $- in *i*)), require PWD = $HOME, and [ -d /workspace ] so scp/sftp, ssh box <cmd>, and callers that already pick a working directory are unchanged.

Existing boxes need a re-bake/rebuild of the base image or template for the shim update to apply.

Reviewed by Cursor Bugbot for commit e8c64f4. Configure here.

Adding a box as a remote host (Codex app, VS Code Remote-SSH, plain
`ssh <box>`) opened the session in /home/vscode instead of the project at
/workspace. SSH config has no start-directory directive, and the only
client-side option (RemoteCommand) would break scp/sftp and VS Code's
remote bootstrap on the same shared alias. So fix it server-side: make
interactive login shells cd into /workspace via the existing
/etc/profile.d/agentbox.sh shim every box installs.

Guarded to interactive shells only (scp/sftp and `ssh box <cmd>` untouched)
and only when still at $HOME (never overrides a caller-chosen dir, e.g.
agentbox's own tmux `-c /workspace`). Applied to all provider shims for
consistency: hetzner, vercel, e2b, and the canonical docker Dockerfile.box.

Claude-Session: https://claude.ai/code/session_01An9tT8HqjQoGKKVWuYg4bb
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
agentbox-web Skipped Skipped Jun 27, 2026 2:48pm

Request Review

@madarco madarco merged commit b17399a into nightly Jun 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant