Open a shell in a running LXC container (ssh + pct enter) #2

Merged
Duckboot merged 3 commits from feat/lxc-shell into main 2026-11-02 20:44:00 +01:00
Owner

What

Press t on a running LXC container to open an interactive shell in it. The TUI suspends and runs ssh -t root@<node> pct enter <vmid>. Typing exit brings you back to the table, which then reloads.

cv4pve-cli 2.4.0 has no shell, console or exec command for LXC, and the Proxmox API has no LXC exec, so this goes through SSH instead. It needs key-based root SSH to the PVE node. Design: the "LXC shell" section of docs/plans/guest-tui-mvp.md.

Notable points

  • VMs, stopped containers and busy guests get a warning instead of a shell.
  • The terminal is reset (ESC c) right before ssh, so the container shell starts on a clean screen.
  • Only exit code 255 (ssh itself failed) is reported as an error. Any other code is just the last status of the container's shell.
  • An OSError from ssh is caught inside suspend(). Textual 8.2.8's suspend() has no try/finally, so an exception escaping it would leave the app suspended.

Verification

  • 115 tests pass; ssh and suspend are mocked.
  • ruff check and ruff format --check report no issues.
  • betterleaks found no secrets.
  • Read-only SSH check: pct status 104 over BatchMode returned status: running.
  • Tested interactively by the user on CT 104: the screen was clean and exit returned to the table.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

## What Press `t` on a running LXC container to open an interactive shell in it. The TUI suspends and runs `ssh -t root@<node> pct enter <vmid>`. Typing `exit` brings you back to the table, which then reloads. `cv4pve-cli` 2.4.0 has no shell, console or exec command for LXC, and the Proxmox API has no LXC exec, so this goes through SSH instead. It needs key-based root SSH to the PVE node. Design: the "LXC shell" section of `docs/plans/guest-tui-mvp.md`. ## Notable points - VMs, stopped containers and busy guests get a warning instead of a shell. - The terminal is reset (`ESC c`) right before ssh, so the container shell starts on a clean screen. - Only exit code 255 (ssh itself failed) is reported as an error. Any other code is just the last status of the container's shell. - An `OSError` from ssh is caught inside `suspend()`. Textual 8.2.8's `suspend()` has no try/finally, so an exception escaping it would leave the app suspended. ## Verification - 115 tests pass; ssh and `suspend` are mocked. - `ruff check` and `ruff format --check` report no issues. - `betterleaks` found no secrets. - Read-only SSH check: `pct status 104` over BatchMode returned `status: running`. - Tested interactively by the user on CT 104: the screen was clean and `exit` returned to the table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Duckboot added 3 commits 2026-11-02 20:43:52 +01:00
Press t on a running container to suspend the TUI and run
`ssh -t root@<node> pct enter <vmid>`. cv4pve-cli has no shell or exec
for LXC, so this goes around it and needs key-based root SSH to the
PVE node.

- VMs, stopped containers and busy guests get a warning instead.
- Only exit code 255 (ssh failed) is reported as an error. Other codes
  are the last status of the container's shell.
- OSError is caught inside suspend(). Textual's suspend() has no
  try/finally, so an exception escaping it would leave the app
  suspended.
- The guest table reloads when the shell returns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write ESC c, the sequence `reset` sends, inside suspend() right before
ssh. The container shell then starts on a clean screen with no
leftover TUI terminal modes. It runs locally, so the container does
not need `reset` installed and `pct enter` is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Duckboot merged commit 70bcb9e7b7 into main 2026-11-02 20:44:00 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Duckboot/cv4pve-cli-tui#2