I am trying to connect to Github from a server running Jenkins.

To do this, I'm copying my public key from another server, into the authorized_keys on the new server.

All I'm getting is the following error:

git ls-remote -h [email protected]:Company/client.git HEAD
Warning: Permanently added the RSA host key for IP address 'xxx.xxx.xxx.xxx' to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

All I did was this:

  1. Go into the .ssh directory on the user account I want, on the old server

  2. Copy the public key, in id_rsa.pub.

  3. Log into the new server, go into /root/.ssh, and put that key into "authorized_keys"

  4. Attempt the above command.

What am I doing wrong? My suspicion is that I'm not copying the key to the correct location, and that in actuality I want to have the entire id_rsa.pub as well as the private key up there, and I'm actually trying to copy a user setting - but I'm not quite sure.

How do I access github from this new server?

1 Answer 1


In order to connect to github you need the private key on the new server. You could copy the private key to the new machine but I would advise you to not do this. Instead generate a new pair of ssh keys and add the public key to your Github account under https://github.com/settings/ssh.

Please read about public/private key systems because from your question you seem to lack some basic understanding.

You must log in to answer this question.

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