π A simple CLI tool to manage multiple GitHub accounts on your machine.
krakncat (or krakn) helps you generate SSH keys, configure git and SSH for each account, and easily switch between accounts when working with repositories.
- π Generate SSH keys per account with automatic SSH config setup
- π₯ Add multiple GitHub accounts with personalized configuration
- π Manage git user/email settings per project directory
- π Clone repositories using the right SSH key and account
- π― Simple commands with an intuitive CLI interface
Ensure you have Go 1.21+ installed on your system.
Arch Linux:
sudo pacman -S goOther distributions:
- Follow the official Go installation guide
git clone https://github.com/alminisl/krakncat.git
cd krakncat
make dev # Download deps, tidy modules, and buildUsing Go directly:
go mod tidy
go build -o krakn .Using make:
make build # Just build
make install # Build and install to /usr/local/bin
make test # Run tests
make clean # Clean build artifacts# After building
sudo cp krakn /usr/local/bin/
# or use make
make installgit clone https://github.com/alminisl/krakncat.git
cd krakncat
./install-arch.sh # Automated installation scriptThis script will:
- Install Go and other dependencies via pacman
- Build the application
- Optionally install it system-wide
When you run krakncat for the first time, it automatically detects ALL existing configurations and lets you choose what to import:
./krakn list
# π Welcome to krakncat!
# π I found existing git/SSH configuration:
#
# 1. Global Git Config - Name: John Doe - Email: john@example.com (recommended)
# 2. SSH Config (github.com-work) - Username: john-work
# 3. SSH Config (github.com-personal) - Username: john-personal
#
# π« Would you like to migrate any of these accounts to krakncat? [Y/n]:
# π Select accounts to migrate:
# 0. Skip migration
# 1. Global Git Config (recommended)
# 2. SSH Config (github.com-work)
# 3. SSH Config (github.com-personal)
# 4. Migrate all
#
# Enter your choice(s) separated by commas (e.g., 1,3): 1,2Smart Migration Features:
- π Auto-Detection: Finds existing git config AND SSH configurations
- π― Multi-Account: Detects multiple GitHub accounts from SSH config
- β¨ Selective Import: Choose exactly which accounts to migrate
- π SSH Key Matching: Automatically suggests appropriate SSH keys
- π Custom Naming: Rename accounts during migration
- π Zero Setup: Creates complete account configurations instantly
- Go 1.24+
- Git
- SSH (ssh-keygen, ssh-agent)
./krakn generate-key --name personal --email your.email@example.comThis command:
- Creates a new ED25519 SSH key pair
- Saves it as
~/.ssh/id_ed25519_gh_<name> - Optionally adds SSH config to
~/.ssh/config - Displays the public key for you to add to GitHub
- Optionally saves the account configuration for easy switching
./krakn addInteractive command that prompts for:
- Account name (e.g., 'work', 'personal')
- Email address
- GitHub username
- SSH key path (with option to generate if missing)
./krakn list
# or
./krakn lsShows:
- All configured accounts with details
- Current active account (marked with β )
- Current git configuration (local and global)
# Switch globally
./krakn use personal
# Switch for a specific repository
./krakn use work /path/to/repoThis command:
- Updates git
user.nameanduser.emailconfiguration - Works globally or for specific repositories
- Shows which SSH host to use for cloning
π― The most powerful feature! Set up automatic account switching based on directory location.
# Set up automatic config for a directory
./krakn config ~/work/projects work
./krakn config ~/personal/projects personal
# Or configure current directory interactively
cd ~/work/my-project
./krakn configThis uses Git's conditional includes feature to automatically use the right account when you cd into different directories!
# Set global default account
./krakn global personal# Show current conditional includes
./krakn show-includes
# Show only global git config (quick check)
./krakn list --global# Manually trigger migration of existing git/SSH config
./krakn migrate
# Remove an account when no longer needed
./krakn remove old-accountAdvanced Migration Features:
- π Smart Detection: Automatically finds all GitHub configurations (git config + SSH hosts)
- π― Multi-Account Support: Import multiple accounts in one session
- β¨ Selective Migration: Choose exactly which accounts to migrate
- π SSH Key Selection: Pick from existing keys or generate new ones
- π Account Renaming: Customize account names during migration
- π Batch Import: Migrate all detected accounts with one command
Example output:
β
Switched to account 'personal' globally
π€ Name: johndoe
π§ Email: john@example.com
π SSH Host: github.com-personal
π‘ To clone repositories with this account, use:
git clone git@github.com-personal:username/repo.git
When you generate a key, krakncat can automatically add an SSH config entry like this:
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_gh_personalThis allows you to use different SSH keys for different accounts by using the host alias:
git clone git@github.com-personal:username/repo.git| Command | Description |
|---|---|
generate-key |
Generate and configure a new SSH key for any Git provider |
add |
Add a new Git account (GitHub, GitLab, Gitea, or custom) with interactive prompts |
list / ls |
List all configured accounts grouped by provider and current git configuration |
use |
Switch git configuration to use a specific account (globally or per-repo) |
config |
Setup automatic git config for a directory using conditional includes |
global |
Set global git configuration to use a specific account |
show-includes |
Show current conditional includes in global git config |
migrate |
Migrate existing git configuration to krakncat (supports all providers) |
remove |
Remove a Git account configuration |
help |
Show help for any command |
list --global/list -g: Show only global git configurationuse [account] [path]: Switch account globally or for specific repository
--name(required): Unique account name (e.g., 'work', 'personal')--email(required): Email address for the SSH key--help: Show help for the command
account-name(required): Name of the account to switch topath(optional): Repository path for local configuration (omit for global)
-
Generate SSH keys and add accounts:
# Add work account ./krakn generate-key --name work --email work@company.com # Follow prompts to save account configuration # Add personal account ./krakn add # Follow interactive prompts
-
Switch between accounts as needed:
# Switch globally to work account ./krakn use work # Switch just for a specific project ./krakn use personal ~/my-personal-project
-
Add the public keys to your GitHub accounts:
- Copy the displayed public key
- Go to GitHub SSH settings
- Add the key with a descriptive title
-
Clone repositories using the appropriate account:
# For work account git clone git@github.com-work:company/project.git # For personal account git clone git@github.com-personal:username/personal-project.git
-
Set up accounts and directory structure:
# Add accounts (same as above) ./krakn generate-key --name work --email work@company.com ./krakn add # for personal # Set global default ./krakn global personal # Set up automatic switching for work directory ./krakn config ~/work work
-
Now it's completely automatic:
cd ~/work/any-project # Automatically uses work account git config user.email # Shows: work@company.com cd ~/personal/my-project # Automatically uses personal account git config user.email # Shows: personal@gmail.com
Behind the scenes, krakncat modifies your ~/.gitconfig to include:
[user]
name = Personal Name
email = personal@gmail.com
[includeIf "gitdir:~/work/"]
path = ~/work/.gitconfigAnd creates ~/work/.gitconfig:
[user]
name = Work Name
email = work@company.comThis means:
- Default: Personal account everywhere
- In ~/work/: Work account automatically
- No manual switching needed! π
krakncat stores account configurations in ~/.krakncat/config.json. This file contains:
- Account details (name, email, username, SSH key path)
- Current active account
- Account-specific settings
The configuration is automatically created when you add your first account.
krakncat/
βββ main.go # Entry point
βββ go.mod # Go module definition
βββ go.sum # Go module checksums
βββ README.md # This file
βββ cmd/
βββ root.go # Root command definition
βββ krakn.go # generate-key command implementation
βββ add.go # add command implementation
βββ list.go # list command implementation
βββ use.go # use command implementation
βββ directory.go # config command implementation
βββ global.go # global and show-includes commands
βββ migrate.go # migrate command implementation
βββ remove.go # remove command implementation
βββ config.go # Configuration management
π§ The following features are planned for future releases:
- β GitHub, GitLab, Gitea support - Add accounts from multiple Git hosting providers
- β Custom Git hosts - Support for self-hosted Git servers
- β Provider-specific configurations - Automatic SSH config generation per provider
- β Unified account management - Manage all providers through the same interface
clone- Clone repositories using the correct SSH key automatically (provider-aware)edit- Edit account details including switching providersbackup- Backup/restore account configurations with provider infoclean- Remove orphaned conditional includes from .gitconfigproviders- List and manage supported Git hosting providers
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
Error: "found packages cmd and main"
- This occurs when there are duplicate files. Ensure there's no
krakn.goin the root directory. - Solution: Remove any duplicate files and rebuild.
Error: "go: command not found"
- Go is not installed on your system.
- Arch Linux:
sudo pacman -S go - Other distros: Follow the official Go installation guide
Error: Module download issues
- Check your internet connection and Go proxy settings.
- Try:
go env -w GOPROXY=direct
Error: "ssh-keygen: command not found"
- OpenSSH is not installed.
- Arch Linux:
sudo pacman -S openssh
Permission denied accessing SSH files
- Ensure proper permissions on
~/.ssh/directory:chmod 700 ~/.ssh - SSH key files should have
600permissions:chmod 600 ~/.ssh/id_*
Error: "No such file or directory" when generating SSH keys
- This usually means the
.sshdirectory doesn't exist. - krakncat automatically creates it, but if you see this error, manually create it:
mkdir -p ~/.ssh chmod 700 ~/.ssh
SSH key generation fails with "exit status 1"
- Check if the SSH key path directory exists and is writable
- Ensure you have sufficient disk space
- Try generating the key manually first:
ssh-keygen -t ed25519 -f ~/.ssh/test_key
Git config not working
- Check if Git is installed:
git --version - Verify config with:
git config --list
- Run
krakn --helpfor command overview - Run
krakn <command> --helpfor specific command help - Check existing SSH configs:
cat ~/.ssh/config - View current Git config:
git config --global --list
krakncat supports multiple Git hosting providers:
- GitHub (github.com)
- GitLab (gitlab.com)
- Gitea (gitea.com or self-hosted)
- Custom Git hosts (any Git server)
# Add a GitHub account
./krakn add
# π Select Git hosting provider:
# 1. GitHub (github.com)
# 2. GitLab (gitlab.com)
# 3. Gitea (gitea.com)
# 4. Custom/Self-hosted (e.g., git.company.com, code.myorg.io)
# Enter choice (1-4): 1
# Add a GitLab account
./krakn add
# Select option 2 for GitLab
# Add a self-hosted Gitea account
./krakn add
# Select option 4 for custom
# Enter hostname: git.company.com
# Enter display name: Company Gitea
# SSH user [git]: git
# SSH port [22]: 2222
# SSH key management URL: https://git.company.com/user/settings/keyskrakncat automatically generates provider-specific SSH configurations:
# GitHub accounts
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_gh_personal
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_gh_work
# GitLab accounts
Host gitlab.com-freelance
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_ed25519_gl_freelance
# Self-hosted Gitea
Host git.company.com-work
HostName git.company.com
User git
IdentityFile ~/.ssh/id_ed25519_company_work
# Custom port example
Host code.internal.com-dev
HostName code.internal.com
User git
Port 2222
IdentityFile ~/.ssh/id_ed25519_internal_dev
# GitHub
git clone git@github.com-personal:username/repo.git
# GitLab
git clone git@gitlab.com-freelance:username/project.git
# Self-hosted Gitea
git clone git@git.company.com-work:team/internal-tool.git- Automatic key naming: Keys are prefixed with provider (
gh_,gl_,gitea_,custom_) - Provider-specific URLs: Direct links to SSH key management pages
- Custom hostnames: Support for any self-hosted Git server
- Unified management: All providers managed through the same commands
Smart hostname handling:
- Automatic key suffix generation (
git.company.comβcompany) - Support for any domain, subdomain, or IP address
- Custom SSH port configuration
- Flexible SSH user settings
Common custom setups supported:
- Self-hosted GitLab:
gitlab.company.com - Self-hosted Gitea:
git.myorg.io - Bitbucket Server:
bitbucket.enterprise.com:7999 - Azure DevOps Server:
tfs.company.com - Custom Git servers:
code.internal.net
Example custom provider configuration:
./krakn add
# π§ Custom Git Provider Setup
# π Enter hostname: git.company.com
# π Enter display name [git.company.com]: Company Git
# π€ SSH user [git]: git
# π SSH port [22]: 2222
# π SSH key management URL: https://git.company.com/settings/ssh
# π SSH key suffix will be: company
#
# β
Custom provider configuration:
# Name: Company Git
# Hostname: git.company.com
# SSH User: git
# SSH Port: 2222
# Web URL: https://git.company.com/settings/ssh
# Key Suffix: company