fix(password): don't print secret to a terminal on --password-get#9
Merged
Conversation
--password-get dumped the stored password in plaintext to stdout by default, leaving it in terminal scrollback. sshx already uses the keyring internally and --password-check covers existence, so the only legitimate need for the raw value is handing it to another program. Make --password-get TTY-aware: on an interactive terminal it just confirms the key exists and shows how to pipe it; when stdout is a pipe or file it emits only the raw value (no decoration, no trailing newline) so it can be captured cleanly, e.g. PW=$(sshx --password-get=key) or `... | pbcopy`. The plaintext warning is written to stderr so it never pollutes the value. Update usage text, SKILL.md, READMEs, and the list-passwords hint (now points at --password-check), plus a CHANGELOG Security note. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
--password-get=<key>printed the stored password in plaintext to stdout by default (\nPassword: <value>\n), leaving the secret in terminal scrollback / shoulder-surfing range. That print is largely unnecessary:--password-checkalready answers "does this key exist?" without revealing the value.Password: <value>output wasn't even clean for scripting.Fix
Make
--password-getTTY-aware:PW=$(sshx --password-get=key)orsshx --password-get=key | pbcopy. The plaintext warning goes to stderr so it never pollutes the value.No new flag; backward-compatible for scripts (output is actually cleaner now). The not-found error path is unchanged.
Verification
gofmt/go vetclean;go test ./...passes;golangci-lint(v2) 0 issues.script) run → secret not printed, only "exists" + pipe guidance;password not found, exit 255.Docs
Updated usage help,
skills/sshx/SKILL.md,README.md,README_CN.md, the list-passwords hint (now points at--password-check), and a CHANGELOG### Securitynote.