SSH Configuration for Multiple GIT Users

wordpress featured image

Config file settings

addkeystoagent yes
Host github.com
  Hostname github.com
  Identityfile ~/.ssh/defaultuser_private_key
Host github.com-username1
  Hostname github.com
  Identityfile ~/.ssh/username_1_private_key
Host github.com-username2
  Hostname github.com
  Identityfile ~/.ssh/username_2_private_key

The first Host section is if you want to have a default user setting. Can be removed if you want to explicitly set the username for individual git repositories.

Git remote settings for repo

git remote set-url origin git@github.com-username1:repo_owner_username/repo_name.git

Leave a Reply

Your email address will not be published. Required fields are marked *