Skip to content

ssh: host editor and keychain passwords - #2

Merged
ForeverInLaw merged 180 commits into
mainfrom
feat/ssh-hosts
Dec 4, 2026
Merged

ForeverInLaw merged 180 commits into
mainfrom
feat/ssh-hosts

Conversation

@ForeverInLaw

@ForeverInLaw ForeverInLaw commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

SSH hosts could only be added by editing config.toml, passwords had to be typed into the terminal on every connection, and there was no port forwarding or file browser.

  • Host editor: a dialog to add, edit, duplicate and delete hosts, groups in the sidebar, and editing ~/.ssh/config hosts without touching the file. A host named after an alias connects through that alias.
  • Passwords: RedShell is the askpass program of the ssh it starts. Passwords, key passphrases, new host keys and one-time codes are asked in RedShell's own dialogs, and passwords and passphrases can be remembered in the OS keychain (Windows Credential Manager, macOS Keychain, Secret Service). A saved password only ever goes to the host it belongs to, and a rejected one is never retried in the background.
  • Install Key on Server: works like ssh-copy-id.
  • Port forwards: local, remote and SOCKS forwards run as background tunnels with their state shown, and a crash takes them down on Linux and Windows. Also agent forwarding and a startup command per host.
  • Browse Files: an SFTP browser over the system OpenSSH, with download, upload, rename, delete and Terminal Here.

…lias

A RedShell host whose name matches an alias from ~/.ssh/config now runs
`ssh <alias>` with the fields set in RedShell passed on top (-p, -l,
-o HostName=), so the alias keeps its IdentityFile, ProxyJump and other
options. Hosts only listed in ~/.ssh/config still pass nothing.
The sidebar's "+" and empty-state hint, and the new Add SSH Host and
Edit SSH Host commands, open a host editor with every [[ssh.hosts]]
field, inline errors, Delete, Save and Save & Connect.

ssh_hosts is the one place hosts are checked, saved, renamed and
deleted. A host only in ~/.ssh/config is saved as an entry of the same
name holding just the fields the user changed; one that overrides an
alias can be reset to the file.
RedShell will be the program ssh runs for passwords, passphrases and host
key confirmations (SSH_ASKPASS with SSH_ASKPASS_REQUIRE=force). This adds
the wire protocol between the helper and the app, the helper client, the
classification of real OpenSSH prompt texts and parsing of ssh -V to tell
clients that honour SSH_ASKPASS_REQUIRE (8.4+) from older ones.
SshProfile carries an optional askpass broker. Batch runs (listings, kills,
uploads) get its environment in background mode and replace BatchMode with
NumberOfPasswordPrompts=1; without a stored password they also turn password
logins off, and they never try keyboard-interactive, so polling never shows
a server an empty password. How a run ended goes back to the broker, so a
stored password the host refused is not sent again. The tmux control attach
is user-initiated and asks interactively, with time for the user to answer.
Without askpass, or with ssh older than 8.4, every command is as before.
A SecretStore over keyring-core with the native stores (Windows Credential
Manager, the macOS keychain, the Secret Service through zbus), opened on first
use; without a keychain nothing is remembered. Secrets reads through a cache,
tracks passwords a host refused, and moves or deletes a host's password when
the host is renamed or deleted. An in-memory store serves the tests.
ssh started with RedShell as SSH_ASKPASS runs it as a helper, which main now
handles before anything else starts. The helper asks the broker, a loopback
listener that issues a 128-bit token per ssh process naming the host it was
pointed at and whether the user may be asked. A pure Policy decides: a stored
password goes only to a prompt naming that user and host (never to a ProxyJump
hop), a passphrase to a prompt naming its key, each at most once per process;
a repeat means it was refused and marks it stale. Background tokens never ask;
interactive ones send the question to the UI as an AskpassEvent with a
responder and a remember flag, and withdraw it when ssh goes away.

An integration test runs the built executable from a path with spaces as the
helper for ssh-keygen opening an encrypted key.
AppState owns the keychain (Secrets) and starts the broker with RedShell's own
executable as the helper. SSH hosts get the broker while ssh.askpass is on, and
changing the ssh settings now rebuilds them. A tab running ssh to a configured
host (an SSH tab, or a tmux or screen session on one) gets the askpass
environment at spawn time, so restored tabs never carry a stale token; local
shells never get it. Until the dialogs exist, questions for the user are
cancelled.
A keychain read can block on an unlock prompt. The policy now names the
account first and decides with the secret looked up between the two steps,
and the secrets cache is not held during the read, so issuing a token for a
new tab on the UI thread never waits for the keychain.
@codeant-ai

codeant-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #9a789 Incremental review completed d2ce10d Dec 04, 2026 · 14:20 14:21
✅  #641ff Reviewed your PR 7e2ccac Dec 04, 2026 · 12:40 12:53

@codeant-ai

codeant-ai Bot commented Dec 4, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@socket-security

socket-security Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedapple-native-keyring-store@​1.0.310010093100100
Addedkeyring-core@​1.1.010010093100100
Addedrussh-sftp@​4.0.010010093100100
Addedwindows-native-keyring-store@​1.1.010010093100100
Addedzbus-secret-service-keyring-store@​1.0.110010093100100

View full report

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Dec 4, 2026
@codeant-ai

codeant-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Nitpicks

5 code suggestions

1. Path::display() replaces non-UTF-8 path bytes, so saving a host with such an identity path writes a different key-file path and breaks authentication.

Logic error · crates/redshell-app/src/ssh_hosts.rs:114


2. BATCH_TIMEOUT only covers wait_until; a child or proxy that keeps stderr open after ssh exits leaves this join blocked indefinitely, including on successful runs.

Possible bug · crates/redshell-remote/src/mux.rs:453


3. The advertised shortcut is Alt+E, but this also fires with Shift held, so Alt+Shift+E unexpectedly opens the editor.

Incorrect condition logic · crates/redshell-app/src/picker.rs:222


4. SSH_ASKPASS_PROMPT=confirm is used for unknown-host-key prompts, so this return classifies them as generic Confirm and omits the parsed fingerprint fields.

Incorrect condition logic · crates/redshell-remote/src/askpass.rs:266


5. Native hit-testing treats the bullet line’s byte offset as a password offset, so clicks after the first character place the caret incorrectly.

Logic error · crates/redshell-ui/src/components/text_input.rs:437


2 Impeccable Design Review (Beta) nitpicks

1. Give the edit control a hit area at least 24 by 24 CSS pixels.

Ui · crates/redshell-app/src/picker.rs:352


2. Expose host duplication through a keyboard-operable command or host-picker action, rather than only through the sidebar’s right-click menu.

Ui · crates/redshell-app/src/sidebar.rs:327

Comment thread crates/redshell-app/src/main.rs Outdated
cx.spawn(async move |_| {
while let Some(event) = events.next().await {
if let AskpassEvent::Request(request) = event {
request.cancel();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom agent: Impeccable Design Review (Beta)

Suggestion: Route incoming SSH requests to a dialog that can collect or confirm an answer, reserving cancellation for an explicit user dismissal.

Severity Level: Major ⚠️ · 🏷️ Ui

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** crates/redshell-app/src/main.rs
**Line:** 67:67
**Comment:**
	*Ui: Route incoming SSH requests to a dialog that can collect or confirm an answer, reserving cancellation for an explicit user dismissal.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread docs/CONFIG.md
Comment on lines +205 to +207
With `askpass` on, RedShell is the program ssh asks for passwords, key passphrases and new host
keys (`SSH_ASKPASS`), so it can fill in what it remembers and ask in its own dialog instead of the
terminal. Secrets you choose to remember are kept in the operating system's keychain, never in

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The app currently cancels every askpass request until dialogs exist, so SSH connections fail at password, passphrase, and host-key prompts instead of showing this dialog.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Comment mismatch

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** docs/CONFIG.md
**Line:** 205:207
**Comment:**
	*Comment Mismatch: The app currently cancels every askpass request until dialogs exist, so SSH connections fail at password, passphrase, and host-key prompts instead of showing this dialog.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread crates/redshell-app/src/host_editor.rs Outdated
/// Saves the host, or shows what is wrong and focuses the first such field.
fn save(&mut self, connect: bool, window: &mut Window, cx: &mut Context<Self>) {
let form = self.form(cx);
match ssh_hosts::save(cx, &self.book, &self.source, &form) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: self.book is a snapshot from when this dialog opened. If another window saves the same name first, this stale check still passes and both hosts are saved under one name.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Race condition

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** crates/redshell-app/src/host_editor.rs
**Line:** 172:172
**Comment:**
	*Race Condition: `self.book` is a snapshot from when this dialog opened. If another window saves the same name first, this stale check still passes and both hosts are saved under one name.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Merge the duplicated SSH hosts paragraphs and the pre- and post-hardening
notes into one guide ordered from install to resource use. Add the .deb,
tarball and source installs, the per-user systemd unit, and RedShell
Remote on the phone. The proxy samples drop trusted_proxies, which the
server assumes for a TLS proxy on loopback, and the guide now says that a
restart or package upgrade ends every session.
Turn Unreleased into 0.0.3 with a lead paragraph and an upgrading note
(ssh.askpass on by default, hosts named after a ~/.ssh/config alias,
the new key order in config.toml). Fixes of features new in this release
fold into their Added entries, the server's hardening reads as what
ships, and the stray duplicated askpass line is gone.
Split the long SSH paragraph, rewrite the RedShell Remote paragraph as
connected prose, list Answer in terminal with the desktop's approval
buttons, move the update check back beside the desktop installers, and
refresh the project layout. The Russian summary mentions the SSH tools
and the server.
The [server] table now says what public_url does (pairing links, passkeys,
HSTS) and when loopback proxies are trusted, as REMOTE.md does.
Document ssh.ssh_config_path and tidy two merged paragraphs.
The server section predated passkeys, pairing, re-authentication, push,
the hosts API and the request guards. Pane ratios are saved with a tab's
layout now, and the terminal crate depends on the theme crate.
The askpass default, alias connections and key order move into Changed as
well as the upgrading note, which now says aliases need import_ssh_config.
The [server] section, the hosts API, trusted loopback proxies and the
pairing address check get their entries back.
Adding or removing a passkey, passkey-only on or off, approving a pairing
and signing out another browser or device answer reauth_required unless
the user re-authenticated in the last five minutes. The HTTP layer now
asks for that in one place: it opens "Confirm it's you" (a passkey, or
the password unless the account is passkey-only), and sends the change
once more when the user confirmed. Closing it counts as a cancel, which
the screens don't report as a failure. Adding a passkey asks first when
the last re-authentication has lapsed, before the ceremony starts.
@codeant-ai

codeant-ai Bot commented Dec 4, 2026

Copy link
Copy Markdown

Skipping CodeAnt AI review — this PR changes more than 100 files, which usually means a migration, codemod, or vendored drop. Line-level review on diffs this large produces duplicate findings on the same rewrite pattern and drowns out anything that actually matters.

If you still want a review, comment @codeant-ai : review. For better signal, consider splitting the PR into smaller chunks.

@ForeverInLaw
ForeverInLaw merged commit 3dd89d4 into main Dec 4, 2026
24 checks passed
@ForeverInLaw
ForeverInLaw deleted the feat/ssh-hosts branch December 4, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant