Jason
Jason

Reputation: 3806

How to setup Github SSH key on second computer

I've got a Github account setup on one computer. I would like to also access my Github account on a second machine using the same SSH key I used for the first computer. How do I import the SSH private key into the new computers user profile?

cp ~/other_comp_github_key ~/.ssh/github

The above command did not do the job in the git bash console on Windows.

Upvotes: 24

Views: 33279

Answers (4)

Maureen Josephine
Maureen Josephine

Reputation: 516

I had the same issue, simply create a new SSH Key in the other computer since its not advisable sharing the same SSH Keys across different computers.

Follow these sets of instructions on Github,I found them pretty much direct and easy to follow.

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

Upvotes: 2

rjv
rjv

Reputation: 6776

The copying of the private key will work, iff the permissions to the ssh files copied are correct, i.e. readable for the user who uses the keys, something like 555 will do. Also, since github allows multiple ssh keys to be used with same account, you can create a new keypair and add it to your account.

Upvotes: 2

Matt Ball
Matt Ball

Reputation: 359966

Argh! No!

Do. Not. Share. Private. Keys.

Make a new keypair on the second computer.

Upvotes: 34

sarnold
sarnold

Reputation: 104080

It'd be best to create a new private key if github allows you to have several associated with your account. (Sharing private keys among machines is very much like sharing passwords on multiple accounts.) But not all services allow multiple keys, so...

You don't specify that you copied the private portion of the key; make sure you copy the private portion.

You don't specify that you configured the ~/.ssh/config block to use the ~/.ssh/github key for the github.com host. Make sure you add a new block to your ~/.ssh/config file just like block on the machine you stole the key from.

host github.com
    IdentityFile ~/.ssh/github

(I don't know that the host is github.com -- if you use a different hostname, then use that.)

Upvotes: 13

Related Questions