A fun and interactive terminal tool for quickly switching between Git SSH keys on Unix systems.
- 🎮 Interactive menu mode - navigate with arrow keys, no typing needed!
- 🎨 Beautiful terminal UI - colorful interface with emojis and visual feedback
- 🔄 Easy key switching - switch between SSH keys instantly
- 🏷️ Alias support - create memorable aliases for your keys (e.g., "work", "personal")
- 🔑 Key creation wizard - guided setup for creating new SSH keys
- 📋 Key overview - see all available keys with their fingerprints and aliases
- ⚡ Fast and lightweight - pure bash, no dependencies
- 🔒 Automatic configuration - updates SSH config for GitHub, GitLab, and Bitbucket
- 🔙 Backwards compatible - supports both interactive and CLI modes
- 🍎 macOS compatible - works with Bash 3.2+ (default on macOS)
Coming soon
# Download the script
curl -O https://raw.githubusercontent.com/YOUR_USERNAME/git-switch/main/git-switch
# Make it executable
chmod +x git-switch
# Move to your PATH
sudo mv git-switch /usr/local/bin/
# Or for user-only installation:
mkdir -p ~/.local/bin
mv git-switch ~/.local/bin/
# Add ~/.local/bin to your PATH if not already therecurl -O https://raw.githubusercontent.com/YOUR_USERNAME/git-switch/main/install.sh
chmod +x install.sh
./install.shSimply run:
git-switchYou'll see a beautiful menu:
╔══════════════════════════════════════╗
║ 🔑 GIT-SWITCH 🔑 ║
║ SSH Key Switcher for Git ║
╚══════════════════════════════════════╝
Current key: id_personal_ed25519
What would you like to do?
▶ Switch SSH Key
Create Alias
Create New Key
Exit
Use ↑/↓ arrows to navigate, Enter to select, q to quit
Navigation:
↑/↓- Move selection up/downEnter- Select optionEscorb- Go back to previous menuq- Quit anytime
From the main menu, select "Switch SSH Key" to see all your keys:
Select a key to switch to:
★ id_personal_ed25519 (personal)
▶ id_work_ed25519 (work)
id_client_rsa (client)
↑/↓: Navigate | Enter: Select | Esc/b: Back
- Keys marked with
★are currently active - Aliases shown in parentheses (yellow text)
- Navigate with arrow keys and press Enter to switch
Give your keys memorable names:
- Select "Create Alias" from main menu
- Choose a key from the list
- Enter an alias name (e.g., "work", "personal", "client-acme")
Now you can quickly switch using: git-switch work
The wizard guides you through creating a new SSH key:
- Select "Create New Key" from main menu
- Choose key type:
- ed25519 (recommended) - Modern, secure, fast
- RSA 4096 - Traditional, widely compatible
- Enter a name for your key (e.g., "work", "personal")
- Enter your email address
- Set a passphrase (recommended for security)
The wizard will:
- ✅ Create the key with proper settings
- ✅ Display your public key
- ✅ Show where to add it (GitHub, GitLab, Bitbucket)
- ✅ Offer to switch to it immediately
Example output:
✓ Key created successfully!
Key details:
Private key: ~/.ssh/id_work_ed25519
Public key: ~/.ssh/id_work_ed25519.pub
Your public key (add this to GitHub/GitLab/Bitbucket):
────────────────────────────────────────
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... you@example.com
────────────────────────────────────────
Next steps:
1. Copy the public key above
2. Add it to your Git hosting service:
• GitHub: Settings → SSH and GPG keys → New SSH key
• GitLab: Preferences → SSH Keys
• Bitbucket: Personal settings → SSH keys
Would you like to switch to this key now? [Y/n]:
For quick operations without entering interactive mode:
git-switch listgit-switch id_ed25519
# or using an alias
git-switch workgit-switch alias work id_work_ed25519
git-switch alias personal id_personal_rsagit-switch unalias workgit-switch help# Interactive mode: Create keys and aliases
$ git-switch
# Create keys for each client
→ Create New Key
Name: client-acme
Email: you@acme-corp.com
# Create aliases
→ Create Alias
Key: id_client-acme_ed25519
Alias: acme
# Quick switching from CLI
$ git-switch acme
✓ Switched to key: id_client-acme_ed25519
$ git clone git@github.com:acme-corp/project.git
# Uses the correct SSH key automatically!# Set up your keys once
$ git-switch alias work id_work_ed25519
$ git-switch alias personal id_personal_ed25519
# Morning: Switch to work
$ git-switch work
✓ Switched to key: id_work_ed25519
# Work on company repos
$ git clone git@github.com:company/backend.git
# Evening: Switch to personal
$ git-switch personal
✓ Switched to key: id_personal_ed25519
# Work on personal projects
$ git clone git@github.com:myusername/side-project.git# New team member doesn't have SSH keys yet
$ git-switch
# Walk through the wizard
→ Create New Key
Type: ed25519 [recommended]
Name: work
Email: newdev@company.com
# Key is created, public key shown
# Copy/paste to GitHub
# Ready to clone repos!
✓ Switched to key: id_work_ed25519git-switch works by updating your SSH configuration file (~/.ssh/config) to specify which key should be used for Git operations. It automatically configures:
- GitHub (github.com)
- GitLab (gitlab.com)
- Bitbucket (bitbucket.org)
- Aliases: Stored in
~/.ssh/git-switch-config - SSH Config: Modified in
~/.ssh/config(backups created as~/.ssh/config.backup)
When you switch keys, git-switch adds/updates entries in your SSH config:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_work_ed25519
IdentitiesOnly yes
This tells SSH which key to use when connecting to Git hosts.
- Unix-like operating system (Linux, macOS, BSD, WSL)
- Bash 3.2 or later (default on macOS and most Linux distros)
- SSH keys in
~/.sshdirectory ssh-keygen(usually pre-installed)
Make sure you have SSH keys in ~/.ssh/. Create one with:
ssh-keygen -t ed25519 -C "your_email@example.com"Or use the built-in key creation wizard: git-switch → Create New Key
- Make sure your public key is added to your Git hosting service
- Test the connection:
ssh -T git@github.com - Verify the correct key is active:
git-switch list
Ensure the installation directory is in your PATH:
echo $PATHIf ~/.local/bin isn't listed, add to ~/.bashrc or ~/.zshrc:
export PATH="$PATH:$HOME/.local/bin"If arrow keys don't work in interactive mode:
- Make sure you're in a proper terminal (not piped input)
- Try using
git-switch listfor non-interactive mode - Check that your terminal supports ANSI escape sequences
Ensure your keys follow the standard naming convention:
- Private key:
~/.ssh/id_keyname - Public key:
~/.ssh/id_keyname.pub
Or any name with a .pub extension for the public key.
Edit the update_ssh_config() function in the script to add or remove Git hosts.
By default, git-switch looks in ~/.ssh. To use a different directory, modify the SSH_DIR variable in the script.
Contributions are welcome! Here's how you can help:
- Report bugs - Open an issue describing the problem
- Suggest features - Share your ideas for improvements
- Submit PRs - Fix bugs or add features
- Improve docs - Help make the documentation clearer
MIT License - see LICENSE file for details.
Created for developers who juggle multiple Git accounts and want a simple, beautiful way to manage their SSH keys.
- GitHub: https://github.com/alexlobaza/git-switch
- Issues: https://github.com/alexlobaza/git-switch/issues
- Releases: https://github.com/alexlobaza/git-switch/releases
If you find this tool useful, please consider:
- ⭐ Starring the repo on GitHub
- 🐛 Reporting bugs or requesting features
- 📢 Sharing it with others who might find it useful
- 💬 Letting me know how you're using it!
Made with ❤️ for developers who work with multiple Git accounts