Skip to content

Instantly share code, notes, and snippets.

@tonycaputome
Created May 28, 2020 09:43
Show Gist options
  • Save tonycaputome/67d8ef7218510d69acf477e7ebdc5842 to your computer and use it in GitHub Desktop.
Save tonycaputome/67d8ef7218510d69acf477e7ebdc5842 to your computer and use it in GitHub Desktop.
git ssh multiple keys

Setup an enviroment to allow multiple ssh keys

Create a SSH key

Create a new SSH key

Add the new key to your GitHub/BitBucket account

Change your git project configuration

  • Open .git/config file to see your GIT configuration in your project folder
  • Make sure the project is using the SSH as url parameter. Ex. git@github.com:USER/PROJECT.git
  • Add before the host your alias name. Ex. git@office.github.com:USER/PROJECT.git

Change your SSH config file

  • Open ~/.ssh/config file to create/edit your custom SSH configuration
  • Add these lines
# GITHUB
Host YOURALIS.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/YOURKEYNAME

# BITBUCKET
Host YOURALIS.bitbucket.org
    HostName bitbucket.org
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/YOURKEYNAME

Lelle - License

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment