0

I've generated an SSH key pair to log to my remote server. I've also added that same public key in GitHub. So from my own machine, I have SSH access to GitHub:

Hi hdodov! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.

This means I can clone private repositories in my GitHub account on my local machine.


Since I use the same key to authenticate to both GitHub and my server, is it possible to use that same key to clone a repo on the server, while SSH-ed to it? If I try that, I get:

git@github.com: Permission denied (publickey).

And this makes sense, because I have no private key on the remote server - it's on my local machine. But since I've used that key connect to the server in the first place, I've proven my possession of it, so shouldn't I be able to just pull from the repo?

Yes, I can just copy my private key to the server, but transferring it over the internet sounds like a bad idea to me. Or perhaps using the same key for authentication at multiple places is the bigger issue in the first place? Should I just have separate keys?

dodov
  • 141
  • 4

1 Answers1

1

What you are looking for probably is:

  1. Running ssh authentication agent (ssh-agent) on your ssh client machine;
  2. And forwarding ssh agent connection to the server (-A commandline or ForwardAgent config file option).

This way you will be able to use the keys you have locally on host on the server without physically copying them there.

Tomek
  • 3,390
  • 1
  • 16
  • 10
  • That did it! Also, [this article on GitHub](https://developer.github.com/v3/guides/using-ssh-agent-forwarding/) is a good resource for setting it up. – dodov Apr 06 '20 at 13:05