8000 GitHub - samyou/sshgit: CLI to setup multiple GitHub SSH accounts · GitHub 7FFF
[go: up one dir, main page]

Skip to content

samyou/sshgit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sshgit

CLI to manage multiple GitHub SSH accounts on one machine and wire repos to the right identity.

Published on npm as @samyou/sshgit.

Install

npm install -g @samyou/sshgit

Requires Node.js 18+.

Quick Start

sshgit init
sshgit account add --provider github --account work --email you@company.com

After sshgit account add, copy the .pub key to GitHub (before sshgit account test or sshgit repo use):

sshgit account copy-pub github-work

Then paste it into GitHub at Settings -> SSH and GPG keys: https://github.com/settings/keys

Rewire remote origin url (optional)

sshgit repo use github-work

Example usage

# show all configured account aliases
sshgit account list

# add a GitHub account
sshgit account add --provider github --account personal --email you@example.com --git-name "Your Name"

# test one specific alias
sshgit account test github-personal

# copy one account's public key to clipboard
sshgit account copy-pub github-personal

# wire the current repo to an alias
sshgit repo use github-work

# repo wiring example (origin -> alias host)
git remote add origin git@github.com:samyou/sshgit.git
sshgit repo use github-work
git remote get-url origin
# git@github-work:samyou/sshgit.git

# remove an alias and its key files
sshgit account remove --alias github-personal --delete-key

Dev / Build

# run from source
bun run dev -- --help

# typecheck
bun run typecheck

# bundle CLI for publishing
bun run build
./dist/sshgit.js --help

Optional local install:

mkdir -p "$HOME/.local/bin"
cp ./dist/sshgit.js "$HOME/.local/bin/sshgit"
chmod +x "$HOME/.local/bin/sshgit"

Then use:

sshgit --help

Commands

Run from source:

bun run dev -- <command>

Run compiled binary:

./dist/sshgit.js <command>

Initialize managed files and SSH include:

bun run dev -- init

Add an account (creates key, updates ~/.ssh/sshgit_config, stores metadata):

bun run dev -- account add \
  --provider github \
  --account work \
  --email you@company.com \
  --git-name "Your Name"

List accounts:

bun run dev -- account list

Test SSH auth:

bun run dev -- account test
# or
bun run dev -- account test github-work

Copy public key to clipboard:

bun run dev -- account copy-pub github-work
# if only one account exists, alias is optional
bun run dev -- account copy-pub

Use an account in the current repo (rewrites remote + sets local git identity):

bun run dev -- repo use github-work

Example flow for repo use:

# start with a normal GitHub SSH remote
git remote add origin git@github.com:samyou/sshgit.git

# rewrite origin to your sshgit alias host
bun run dev -- repo use github-work

# origin is now wired to the alias host
git remote get-url origin
# git@github-work:samyou/sshgit.git

Remove an account:

bun run dev -- account remove --alias github-work
# optionally also delete key files
bun run dev -- account remove --alias github-work --delete-key

Notes

  • Generated keys default to ~/.ssh/id_ed25519_<provider>_<account>.
  • Managed SSH config lives in ~/.ssh/sshgit_config and is included from ~/.ssh/config.
  • After account add, run sshgit account copy-pub <alias> and paste the key into your provider settings page.

License

MIT

About

CLI to setup multiple GitHub SSH accounts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

0