git-sshkey is a Rust CLI that binds one SSH identity from your active ssh-agent to a single Git repository.
It solves two common problems:
- SSH identity exhaustion when your agent has multiple keys loaded
- Preserving global SSH binary/path behavior while applying a local repo override
- Native Git-style subcommand workflow (
git sshkey ...) - Interactive identity picker from
ssh-add -L - Local-only
core.sshCommandbinding - Inherits global SSH binary path when available
- One-command auth probe against
origin - Safe clear/revert flow
Install from local source (recommended):
cargo install --path .This installs git-sshkey into Cargo's bin directory (usually ~/.cargo/bin), which should be on your PATH.
If you prefer manual build/copy:
cargo build --release
cp ./target/release/git-sshkey /usr/local/bin/git-sshkeyThen Git resolves:
git sshkey <subcommand>Update to latest local changes:
cargo install --path . --forceUninstall:
cargo uninstall git-sshkeygit sshkey- show helpgit sshkey status- show inherited SSH binary and local overridegit sshkey list- list identities currently inssh-agentgit sshkey pick- interactively select an identity and bind it locallygit sshkey test- run silent auth probe viagit ls-remote --exit-code origin HEADgit sshkey clear- remove localcore.sshCommandoverride
- Reads available identities from
ssh-add -L - Lets you choose one key via interactive prompt
- Stores selected public key at:
~/.ssh/git-sshkey/{comment}.pubwhen comment is unique~/.ssh/git-sshkey/{comment}-{short_hash}.pubonly on name collision~/.ssh/git-sshkey/key-{short_hash}.pubwhen comment is empty
- Builds merged command:
"{inherited_ssh_binary}" -i "{pub_path}" -o IdentitiesOnly=yes
- Writes repository-local config:
git config --local core.sshCommand "{merged_command}"
- Rust toolchain (for building)
- Git
- OpenSSH client (
ssh,ssh-add) - Running
ssh-agentwith identities loaded
MIT. See LICENSE.