2

I would like to push back the results from a build to github and I therefore use the Git publisher plugin. However, when I try to add the SSH public key from Cloudbees as a Deploy Key on Github then Github tells me: 'Key already in use' since it is also part of another repository.

I would like to know why I cannot use the same public key for multiple independent repositories?

[update] The answers so far indicate that the question is unclear. Cloudbees generates a key pair and uses this on github, I've not found a way to create an alternate pair, so I am stuck with one pair.

I've added the public key to repo A so Cloudbees can pull from repo A. However, I want to use the same build to push to repo B. So it seems logical to add the same (my personal Cloudbees key) to to repo B so cloudbees can push to repo B as well.

However, on Github only a single repo can be using the deploy key:

A deploy key is an SSH key that is stored on the server and grants access to a single repo on GitHub. This key is attached directly to the repo instead of to a user account.

So it is clear that the the public key cannot be attached to more than one repo. However, I can't think of a reason why this is the case?

Anybody?

Peter Kriens
  • 15,196
  • 1
  • 37
  • 55
  • Possible duplicate of [Github, (Error: Key already in use)](http://stackoverflow.com/questions/21160774/github-error-key-already-in-use) – kenorb Jan 08 '16 at 22:56

2 Answers2

1

You need to set your ssh key for user, not repository, so you can use it for multiple github repositories. github don't allow using same key on multiple locations

nicolas de loof
  • 2,593
  • 1
  • 13
  • 11
0

Because the key is used to identify the user. It's like you would only use a password to identify the user: if two users have the same password, how do you know which is which?

A key is supposed to be unique to a user.

You can, however, generate multiple keys on the same machine and configure git/ssh to use a specific key instead of the default ~/.ssh/id_rsa.pub (or other id_*.pub key).

Sergiu Dumitriu
  • 11,455
  • 3
  • 39
  • 62
  • A public key is password AND id, that is the beauty of PKI, so you cannot have another id with the same key. I cannot find a way for Cloudbees to generate another key, nor do I understand why this is required for a deploy key ... – Peter Kriens Jan 08 '13 at 08:56