Skip to content

Multiple ssh keys

Jiri Hynek edited this page Oct 16, 2018 · 4 revisions

When you are using more than a one repository, Github need you to put an unique ssh public key for each repository. Here are instructions how to do it:

  1. Go to your .ssh folder in home directory
  2. Generate ssh key for each repository you want to use:
ssh-keygen -t rsa -b 4069 -C your_github@email.com -f id_rsa.git.repository_name
  1. Create config file in the .ssh folder (its name is simple config without any file extension)
host repository_name_1.github.com
 HostName github.com
 IdentityFile ~/.ssh/id_rsa.git.repository_name_1
 User git

host repository_name_2.github.com
 HostName github.com
 IdentityFile ~/.ssh/id_rsa.git.repository_name_2
 User git
  1. Deploy your .pub keys to github repository according to the Github instructions: https://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys:
  2. Clone your repository
  • a. Go to the repository on Github
  • b. Select clone or download
  • c. Copy the link
  • d. modify the link from:
git@github.com:User/repository_name.git

to:

git@repository_name.github.com:User/repository_name.git

Clone this wiki locally