moebrowne / git-profile

Simple script to instruct Git to use certain SSH keys with certain repos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting The SSH Key Git Uses

This script adds awareness to Git about which SSH key should be used when pushing to remotes over SSH.

Use

  1. Run the setup-alias.sh
  2. Open the config of repository you want to set the key path of: repoName/.git/config
  3. Add the following to it, replacing $HOME/.ssh/key-name with your key path
[SSH]
    keypath = $HOME/.ssh/key-name

You can now push and pull as normal but Git will use the key you have specified

How It Works

All that happens is the alias looks for the config variable SSH.keypath and if found exports the value of the config entry to an environment variable named GIT_SSH_COMMAND. Git uses this when it does anything SSH related and will make use of the key you configured.

Requirements

Git v2.3 or above

About

Simple script to instruct Git to use certain SSH keys with certain repos

License:GNU General Public License v3.0


Languages

Language:Shell 100.0%