Overview

I built sshwitch because dealing with multiple Git accounts on one computer is annoying. If you have a work account and a personal account you usually have to mess with your ssh config file or change your remote URLs. While power users might be comfortable in the terminal, many developers, including seasoned iOS devs still find manual ~/.ssh/config management error-prone and tedious.

sshwitch solves this by using a built in Git feature. It links a specific SSH key directly to a specific repository. This means it only affects that one project and leaves your global settings alone.

Key Features

  • Key Generation to create new SSH keys easily
  • Repository Linking to bind an SSH key directly to a repository without touching global settings
  • Diagnostics to run checks and make sure your SSH setup and file permissions are correct

Technical Details

I wrote this tool using Swift. It requires macOS 14 or later.

The core idea is very simple. When you link a key sshwitch runs a command inside your target repository to set the ssh command. It tells Git to use exactly that private key and to ignore other identities. The setting lives inside the local git config of that specific folder so it never messes up your other projects.

Commands

The tool has a few simple commands. gen creates a new key. link binds a key to your current repository. unlink removes the binding. list shows all your keys. doctor checks for common SSH problems.

Why I Built It

I got tired of constantly checking if I was using the right SSH key before pushing code. Writing complex config blocks manually felt unnecessary when Git already has a built in way to handle it. I wanted a fast native tool to handle the setup so I could just focus on writing code.