npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gitsshcli

v1.0.0

Published

A cross-platform CLI tool for managing Git configurations and SSH keys across multiple project directories

Readme


🎯 The Problem

Managing multiple Git identities (personal, work, freelance) on the same machine is painful:

  • Forgetting to change user.email leads to commits with the wrong identity
  • Setting up SSH keys for each account is tedious and error-prone
  • Remembering which SSH key to use for which repository is confusing

✨ The Solution

Git SSH CLI automates everything in one command. It:

  • 🔑 Generates unique SSH keys for each identity
  • 📄 Configures Git to automatically use the correct identity based on project directory
  • 🔧 Sets up SSH config for seamless multi-account access

📦 Installation

Prerequisites

  • Node.js >= 14.0.0
  • ssh-keygen (pre-installed on macOS, Linux, and Windows 10+)

Install via npm

npm install -g gitsshcli

Install from Source

git clone https://github.com/madhusudansinghrathore/gitsshcli.git
cd gitsshcli
npm install
npm link

Verify Installation

gitssh --version
# Output: 1.0.0

gitssh --help

🚀 Quick Start

# Run the setup wizard
gitssh setup

# Follow the prompts to add your profiles
# That's it! Your Git and SSH configs are ready

📖 Commands

gitssh setup

Interactive wizard to configure Git profiles and generate SSH keys.

What it does:

  1. Collects profile information - Prompts for identity details
  2. Generates SSH keys - Creates ED25519 keys for secure authentication
  3. Updates SSH config - Adds host aliases for multi-account access
  4. Configures Git - Sets up automatic identity switching based on directory

Usage:

gitssh setup

Interactive Prompts:

The wizard prompts for:

| Prompt | Description | Example | |--------|-------------|---------| | Display Identifier | Short name for this profile (used in filenames) | personal, work, freelance | | Full Name | Your name for Git commits | John Doe | | Email | Email address for this identity | [email protected] | | Full Directory Path | Root directory for projects using this identity | ~/work/personal | | Default Branch | Default branch name for new repositories | main, master, development |

Example Session:

🔧 Git SSH CLI Setup

This wizard will help you set up Git configurations and SSH keys for multiple profiles.

📝 Profile 1

? Display Identifier: personal
? Full Name: John Doe
? Email: [email protected]
? Full Directory Path: ~/work/personal
? Default Branch: main

✓ Added profile: personal

? Do you want to add another profile? Yes

📝 Profile 2

? Display Identifier: work
? Full Name: John Doe
? Email: [email protected]  
? Full Directory Path: ~/work/company
? Default Branch: main

✓ Added profile: work

? Do you want to add another profile? No

📋 Profiles to set up:

  1. personal
     Name: John Doe
     Email: [email protected]
     Directory: ~/work/personal
     Branch: main

  2. work
     Name: John Doe
     Email: [email protected]
     Directory: ~/work/company
     Branch: main

? Ready to set up 2 profile(s). This will generate SSH keys and update Git configs. Continue? Yes

Output:

After successful setup:

🔑 Generating SSH keys...

  Generating key for personal...
  ✓ Generated: ~/.ssh/personal
  Generating key for work...
  ✓ Generated: ~/.ssh/work

📄 Updating SSH config...

  ✓ Updated ~/.ssh/config

📄 Updating Git config...

  ✓ Updated ~/.gitconfig with includeIf blocks

📄 Creating profile Git configs...

  ✓ Created ~/.gitconfig-personal
  ✓ Created ~/.gitconfig-work

✅ Setup Complete!

📋 Add these public keys to your GitHub accounts:

personal ([email protected]):
────────────────────────────────────────────────────────────
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... [email protected]
────────────────────────────────────────────────────────────

work ([email protected]):
────────────────────────────────────────────────────────────
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... [email protected]
────────────────────────────────────────────────────────────

📖 Usage Instructions:

  When cloning repos, use the profile-specific host:
    git clone [email protected]:username/repo.git
    git clone [email protected]:username/repo.git

  To test SSH connection:
    ssh -T [email protected]
    ssh -T [email protected]

📁 Generated Files

After running gitssh setup, the following files are created/updated:

SSH Keys

| File | Description | |------|-------------| | ~/.ssh/<identifier> | Private SSH key (keep secret!) | | ~/.ssh/<identifier>.pub | Public SSH key (add to GitHub) |

SSH Config (~/.ssh/config)

# personal GitHub account
Host github.com-personal
    HostName github.com
    User git
    IdentityFile ~/.ssh/personal
    IdentitiesOnly yes

# work GitHub account  
Host github.com-work
    HostName github.com
    User git
    IdentityFile ~/.ssh/work
    IdentitiesOnly yes

Git Config (~/.gitconfig)

[includeIf "gitdir:~/work/personal/"]
    path = ~/.gitconfig-personal

[includeIf "gitdir:~/work/company/"]
    path = ~/.gitconfig-work

Profile Git Configs

~/.gitconfig-personal:

[user]
    name = John Doe
    email = [email protected]

[init]
    defaultBranch = main

~/.gitconfig-work:

[user]
    name = John Doe
    email = [email protected]

[init]
    defaultBranch = main

🔧 How It Works

Automatic Identity Switching

Git's includeIf directive automatically loads different configurations based on the repository's location:

~/work/
├── personal/          ← Uses ~/.gitconfig-personal
│   ├── my-blog/
│   └── side-project/
└── company/           ← Uses ~/.gitconfig-work
    ├── main-app/
    └── internal-tool/

SSH Host Aliases

Instead of using github.com directly, use profile-specific hosts:

# Instead of:
git clone [email protected]:username/repo.git

# Use:
git clone [email protected]:username/repo.git
# or
git clone [email protected]:username/repo.git

This tells SSH which key to use for authentication.


📝 Post-Setup Steps

1. Add SSH Keys to GitHub

For each profile, add the public key to the corresponding GitHub account:

  1. Copy the public key from the setup output (or run cat ~/.ssh/<identifier>.pub)
  2. Go to GitHub → SettingsSSH and GPG keys
  3. Click New SSH key
  4. Paste the key and save

2. Test SSH Connections

ssh -T [email protected]
# Hi username! You've successfully authenticated...

ssh -T [email protected]
# Hi username! You've successfully authenticated...

3. Clone Repositories

Use the profile-specific host when cloning:

# Personal projects
cd ~/work/personal
git clone [email protected]:myusername/my-repo.git

# Work projects
cd ~/work/company
git clone [email protected]:company/project.git

4. Update Existing Repositories

For existing repos, update the remote URL:

cd ~/work/personal/existing-repo
git remote set-url origin [email protected]:username/repo.git

❓ FAQ

Can I add more profiles later?

Yes! Just run gitssh setup again. New profiles will be appended to existing configurations.

What if I already have SSH keys?

If a key with the same name exists, the tool will skip generation and reuse the existing key.

Does this work with GitLab/Bitbucket?

Currently configured for GitHub, but you can manually edit ~/.ssh/config to add other providers:

Host gitlab.com-personal
    HostName gitlab.com
    User git
    IdentityFile ~/.ssh/personal
    IdentitiesOnly yes

How do I remove a profile?

Manually remove the relevant sections from:

  • ~/.ssh/config
  • ~/.gitconfig
  • Delete ~/.gitconfig-<identifier>
  • Optionally delete ~/.ssh/<identifier> and ~/.ssh/<identifier>.pub

🛠️ Development

# Clone the repository
git clone https://github.com/madhusudansinghrathore/gitsshcli.git
cd gitsshcli

# Install dependencies
npm install

# Link for local development
npm link

# Run the CLI
gitssh --help

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


⭐ Show Your Support

If this project helped you, please give it a ⭐ on GitHub!