Repository navigation
fix: startup command runs at login in a terminal and keeps the session - #173
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #171 (reported by @Frysuni).
What changed
cd /ended the session at once, andsudo su rootstarted a root shell that printed no prompt, so the connect screen stayed up indefinitely. The TUI,sshub connectand the argvsshub host resolvereports now pass-tand appendexec "$SHELL" -lon 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 withexecstill ends the session with it.sshub exec, broadcast and the other one-shot paths drop the command as before, an ssh_configRemoteCommandis left to ssh, and mosh is unchanged. The ssh log andhost resolvetext show the newline as\n.Authenticated tomarker now counts as an answer, not only PTY output.runs at login, then your shellwhile the field is empty. The README, CHANGELOG (crediting @Frysuni) and openwiki document the behaviour.Nix flake (nix run, nix profile, NixOS)under "Installed via".How tested
a_startup_command_runs_in_a_remote_terminal:ttyprinted "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.cd /gives a prompt in/.shgives a prompt, andexitreturns to the login shell.exec shends the session on exit.sleep 1 &parses.exec sleep 30is revealed by 8 s.cargo fmt --check,cargo clippy --all-targets -D warningsandjust test(1726 + 127 + 127) are green.test_support::current_user();host resolvetext output escapes the newline;Not changed
exec, so its session ends with an error after the command runs.sshub exportstill writes the rawRemoteCommand, 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.