Skip to content

Add optional passphrase prompt to SSH key generation#13

Merged
ChangeHow merged 2 commits intodevfrom
copilot/sub-pr-10-another-one
Mar 10, 2026
Merged

Add optional passphrase prompt to SSH key generation#13
ChangeHow merged 2 commits intodevfrom
copilot/sub-pr-10-another-one

Conversation

Copy link

Copilot AI commented Mar 10, 2026

SSH keys were generated unconditionally without a passphrase (-N ""), giving users no choice and creating less secure keys by default.

Changes

  • src/steps/ssh.js — Adds a @clack/prompts password prompt after the email step; blank = no passphrase, non-blank requires ≥8 characters; cancelling aborts the flow
  • src/utils/shell.js — Extends runStream(cmd, opts) to accept an env option forwarded to spawn(), enabling secure env-var injection
  • tests/ssh.test.js — Adds mockPassword and four new cases: blank passphrase, passphrase provided, cancel passphrase, prompt message content

Security note

The passphrase is never interpolated into the shell command string. It is passed as SSH_KEYGEN_PASSPHRASE via spawn's env option and referenced as $SSH_KEYGEN_PASSPHRASE in the command, avoiding shell injection:

await runStream(
  `ssh-keygen -t rsa -b 4096 -C "${email}" -f "${keyFile}" -N "$SSH_KEYGEN_PASSPHRASE"`,
  { env: { ...process.env, SSH_KEYGEN_PASSPHRASE: passphrase } }
);

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: ChangeHow <23733347+ChangeHow@users.noreply.github.com>
Copilot AI changed the title [WIP] Update workflow to add optional passphrase for SSH encryption Add optional passphrase prompt to SSH key generation Mar 10, 2026
@ChangeHow ChangeHow marked this pull request as ready for review March 10, 2026 17:44
@ChangeHow ChangeHow merged commit cb93126 into dev Mar 10, 2026
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.

2 participants