An interactive CLI that guides you through creating or reusing an SSH key and connecting it to GitHub in a 7-step workflow. Supports macOS and Linux with clipboard integration.
Requirements:
- Node.js >= 20
Install globally:
npm install -g gh-ssh
Run without installing:
npx gh-ssh
Run interactive setup:
gh-ssh
Show help/version:
gh-ssh --helpgh-ssh --version
Provide options up front:
gh-ssh --email you@example.comgh-ssh --type ed25519gh-ssh --key-name id_github_workgh-ssh --update-configgh-ssh --skip-configgh-ssh --uploadgh-ssh --skip-uploadgh-ssh --key-title "My MacBook (work)"
Options:
-h, --help-v, --version--email <email>GitHub email for key comment--type <ed25519|rsa>Key type (default: ed25519)--key-name <name>Key filename in ~/.ssh (default: id_ed25519 or id_rsa)--update-configUpdate ~/.ssh/config with the selected key--skip-configSkip updating ~/.ssh/config--uploadUpload the public key to GitHub via gh (errors if not possible)--skip-uploadSkip uploading via gh and show the manual flow--key-title <title>Title to use when uploading via gh
- Detect existing public keys in ~/.ssh and optionally reuse one.
- Generate a new key pair if needed (ed25519 by default, rsa 4096 fallback).
- Start ssh-agent if it is not already running.
- Add the selected key to ssh-agent.
- Optionally update ~/.ssh/config (with an optional GitHub host alias).
- Copy the public key to clipboard (macOS/Linux) or print it to the terminal, then add it at GitHub Settings.
- Prompt to verify with
ssh -T git@github.com(or your alias).
- macOS: full workflow, clipboard uses
pbcopy. - Linux: full workflow, clipboard uses
wl-copy,xclip, orxsel(if available). - Requires
ssh-keygen,ssh-agent, andssh-addto be available in PATH.
- Install dependencies:
npm install - Run locally (TypeScript):
npm run dev - Type check:
npm run typecheck - Build CLI:
npm run build - Run built CLI:
npm start
npm run dev -- --helpnpm run dev -- --versionnpm run dev -- --email test@example.com --type ed25519
We use Conventional Commit–style PR titles and squash merges to drive automated versioning and changelogs. Always use a semantic PR title and squash-merge so the PR title becomes the commit message used for releases.
Examples:
feat: add support for multiple GitHub hostsfix: handle missing ssh-agentfeat!: change default key type(breaking change)chore: update dev dependencies(no release)