2

Exists there any way to define for each cloned repo the path of which SSH key pair it should use?

Paris
  • 6,323
  • 7
  • 31
  • 49

1 Answers1

2

Yes, you need to define a ~/.ssh/config file, in which you can declare different ssh names, with a custom full path name for the public/private key to use.

Host AHostName -- name you will use for the ssh address
User gituser
Hostname SSH IP address 
Port 1234 -- use this if you need custom ports
IdentityFile "path to your private ssh key"

From there, the ssh url of the repo can be:

AHostName:myrepo

See also:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I think what you wrote defines a different ssh key for each host. I mean suppose that I have different repos on GitHub and each one of these should have a different ssh key pair – Paris Oct 01 '12 at 07:02
  • @Paris: that works for the same Host too: simply give "`Host`" a different name (it can be any name you want), even though "`Hostname`" will be `github.com` every time. That is exactly what is illustrated by my last link in the answer: http://stackoverflow.com/questions/12066895/how-to-work-on-personal-github-repo-from-office-computer-whose-ssh-key-is-alread/12066973#12066973 – VonC Oct 01 '12 at 07:08