Search code examples
githubgoogle-compute-enginessh-keys

Create new SSH keys w/ new server, or use existing key?


In the myhome/.ssh/ directory are local SSH keys for my personal GitHub account, the directory has the id_rsa and id_rsa.pub files that allow me to authenticate with GitHub.

I am setting up a server (compute engine on GCP), and this server needs these keys because it needs to authenticate to my GitHub to pull a repo. Should I either:

  1. transfer over / SCP the currently-existing id_rsa, `id_rsa.pub that I have locally onto the server, and use those on the server.
  2. create a brand new SSH key from on the server, and use this key. Add it to my GitHub profile.
  3. it doesn't matter, either (1) or (2) is fine.
  4. or something else?

(2) seems like the right approach, but we are not certain.


Solution

  • Indeed option 2. As a best practice, you should not share the same private key.

    Go ahead and generate a new SSH key following the docs: https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh