Skip to content

fix: startup command runs at login in a terminal and keeps the session - #173

Merged
Petyok merged 3 commits into
developmentfrom
fix/171-startup-command
Oct 27, 2026
Merged

Petyok merged 3 commits into
developmentfrom
fix/171-startup-command

Conversation

@Petyok

@Petyok Petyok commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Closes #171 (reported by @Frysuni).

What changed

  • fix: the startup command runs at login, in a terminal. A host's startup command reached ssh as its remote command, which replaces the login shell and gets no remote terminal: cd / ended the session at once, and sudo su root started a root shell that printed no prompt, so the connect screen stayed up indefinitely. The TUI, sshub connect and the argv sshub host resolve reports now pass -t and append exec "$SHELL" -l on a new line (keep_login_shell, src/app/util.rs). The command runs at login and the session goes on in the login shell; a command starting with exec still ends the session with it. sshub exec, broadcast and the other one-shot paths drop the command as before, an ssh_config RemoteCommand is left to ssh, and mosh is unchanged. The ssh log and host resolve text show the newline as \n.
  • fix(session): an authenticated session that prints nothing is revealed. Past the 6 s reveal timeout, ssh's Authenticated to marker now counts as an answer, not only PTY output.
  • The host form shows runs at login, then your shell while the field is empty. The README, CHANGELOG (crediting @Frysuni) and openwiki document the behaviour.
  • docs: the bug report template offers Nix flake (nix run, nix profile, NixOS) under "Installed via".

How tested

  • Three oracle tests against a real tempdir sshd, each confirmed to fail with its fix reverted:
    • a_startup_command_runs_in_a_remote_terminal: tty printed "not a tty" before the fix.
    • a_startup_command_leaves_the_login_shell: the session ended with "success" before the fix.
    • an_authenticated_session_that_prints_nothing_still_reveals: the session stayed on the connect screen before the fix.
  • The TUI binary was driven against a local sshd:
    • cd / gives a prompt in /.
    • sh gives a prompt, and exit returns to the login shell.
    • exec sh ends the session on exit.
    • sleep 1 & parses.
    • exec sleep 30 is revealed by 8 s.
    • The maintainer checked on a real host with sudo.
  • cargo fmt --check, cargo clippy --all-targets -D warnings and just test (1726 + 127 + 127) are green.
  • Adversarial review by 3 critics. The verified findings are fixed:
    • the test username comes from test_support::current_user();
    • the host resolve text output escapes the newline;
    • the docs note the ssh-only scope.

Not changed

  • An account whose login shell is rbash cannot exec, so its session ends with an error after the command runs.
  • sshub export still writes the raw RemoteCommand, so plain ssh with the exported config keeps the old "replaces the shell" behaviour.

Written by Claude Opus 5.5 (Oh My Pi) on behalf of the maintainer.

petruha added 3 commits October 27, 2026 12:11
A host's startup command reached ssh as its remote command, which runs
in place of the login shell and without a remote terminal: `cd /` ended
the session at once, and `sudo su root` started a root shell that
printed no prompt, so the connect screen stayed up for good.

Interactive sessions (the TUI, `sshub connect` and the argv `sshub host
resolve` reports) now pass -t and append `exec "$SHELL" -l` on a new
line, so the command runs at login and the session goes on in the login
shell. A command that starts with `exec` still ends the session with it.
`sshub exec`, broadcast and the other one-shot paths drop the command as
before, and an ssh_config RemoteCommand is left to ssh.
Past the reveal timeout the connect screen gave way only to PTY output,
so a startup command that prints nothing kept an authenticated session
behind it for good. ssh's "Authenticated to" marker now counts as an
answer too.
@Petyok
Petyok merged commit 85f83bc into development Oct 27, 2026
4 checks passed
@Petyok
Petyok deleted the fix/171-startup-command branch October 27, 2026 08:17
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