0

Sorry if this is not the right stackexchange.

I have used Git with Github and that works well.

I now want to use Git with my own website which is on a live site. My host provided me with a private SSH key specifically for my domain. The key was generated via a Git add-on for cPanel.

How can I add this second key, and then how does Git know which key to use?

I'm totally noob to this but I've been Googling for hours about this.

Eoin
  • 1,413
  • 2
  • 17
  • 32
  • Are you asking how to add a key to github, or how to connect to a git repo which resides on a web server? – Sam Dufel Jun 07 '16 at 21:43
  • I'll edit the question – Eoin Jun 07 '16 at 21:44
  • Does that make it clearer? I want to connect to a git repro on a web server, but I also at times will want to connect to Github. I already set up Github so that part works. I need to know how to add a different set up, and switch between the two. – Eoin Jun 07 '16 at 21:45
  • *“My host provided me with an SSH key”* – Did your host give you a *private* key which you should use to communicate with your server? That’s a big red flag, do not accept that. Private keys should *never* be shared. – poke Jun 08 '16 at 22:29
  • The host gave me a private key yes. It's individual for my domain name. Have updated the question in case others think the same. Cheers for the advice. – Eoin Jun 09 '16 at 19:55

1 Answers1

0

You can do this quite easily. If you add the new key to your .ssh/ folder, and ssh-add your new key. The following link explains this process for two different github repositories, but you should be able to adapt for your case.

https://gist.github.com/jexchan/2351996

Jeremy
  • 104
  • 3
  • 12
  • Thanks. These are the types of articles I've read. I guess my question is.... where is ~/.ssh/ any folder I find with /ssh/ doesn't seem to have a key stored in it, but I must have stored one somewhere to use Github right? – Eoin Jun 09 '16 at 19:58
  • What platform are you on? OS X? Linux? Windows? – Jeremy Jun 09 '16 at 21:46
  • Windows does some funky stuff, and your git client / shell will determine the location of .ssh. See these two threads: http://serverfault.com/questions/194567/how-do-i-tell-git-for-windows-where-to-find-my-private-rsa-key and http://stackoverflow.com/questions/31813080/windows-10-ssh-keys . Either you or your client must have made one though if you are pushing to your github repositories without ever needing a password. Check Github.com>Settings>SSH and GPG keys to confirm that you are authenticating through an RSA key pair. – Jeremy Jun 11 '16 at 19:44
  • 1
    Thanks I'll try those links, that seems much closer to what I need. Finally someone understands my question :) That's the trouble when you don't know what you're doing, you don't know the right question to ask! – Eoin Jun 13 '16 at 11:22