2

I have this legacy server with CentOS release 6.6 (Final), w/ git version git version 1.7.1

I need to pull on it different Github projects. Access to server is shared by multiple persons via a common auth system.

Taken into account that the above env cannot be changed or upgraded.

I have the following issue. I have already connected successfully to a git repo and deal with it by defining a Deploykey, the unique I have actually defined in:

  /home/dev-user/.ssh/id_rsa.pub

Now I've tried to add the same deploy key to manage a different github repo. But github 's giving me an error , key is already in use.

So I'm thinking to create multiple id_rsa_reponame.pub ssh keys to pull (mainly) my github repo to this server.

Can this be considered a best practice in this case? Id yes...How can I create different named public keys to use as deploy key on github repo?

Any other way to solve this is welcome.

Thanks

UPDATE

I've tested the following from another development machine. In this machine I already had a

 /home/username/id_rsa.pub

Already defined as deploy key on a github repo and working correctly.

Then I issued the command:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

When prompted I gave a different name to the key like:

 /home/username/id_rsa_mytest.pub

Then I copied the content of this file and set as deploy key for another repo.

I tried to git clone:

  git clone [email protected]:githubAccount/myrepo.it

But got:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

I believe that local machine is not trying automatically all my pub keys to connect to github via ssh.

How can I achieve that?

4
  • Add the key in your personal settings (the menu with your profile picture in the upper right), not in the repository settings. If it is in your personal settings you can use it for all your repositories Commented May 8, 2019 at 11:27
  • @GeraldSchneider I think this isnt Ideal since any developer accessing to the legacy server via dev-user will be able to pull push via my github account. Is it?
    – koalaok
    Commented May 8, 2019 at 11:34
  • True. Then you will need different deploy keys. But I don't understand what you are asking in this case ... the first thing ssh-keygen asks you when you start it is the filename where it should store the key. Commented May 8, 2019 at 11:41
  • Ok. But I'm not sure If having multiple id_rsa_name.pub in my server .ssh dir might affect some previous configuration based on the default id_rsa.pub All the public key defined there will be active and equally available? Is the some circumstance that creating a new .pub file might create some issue?
    – koalaok
    Commented May 8, 2019 at 12:51

1 Answer 1

1

I have found the solution for what I was looking for; thanks to this resource:

https://medium.com/@dustinfarris/managing-multiple-github-deploy-keys-on-a-single-server-f81f8f23e473

One point which is not so straightforward/clear in the post. The line:

 Host github-repo2

In config file

  ~/.ssh/config

is like a custom name to be used subsequently when issuing the command :

 git clone github-repo2:yourgithubuser/repo2

Actually the “Host” term is not so friendly to make you understand his function in the configuration.(It is a reference as username @ hostname using the specific identity file)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .