1

I was using git on my office workstation. Then for the Covid lockdown I started using it on my home PC. Now when I try to clone on my office workstation I get the error: Permission denied (publickey).

It seems like the git configuration I did on my home PC overwrote the key for my office workstation. I need to be able to use both client hosts, so I don't want to do another config on my office and then not be able to use git as the same user on my home PC.

According to this post:

Git - Same User, Different Machine - Clone?

I should be able to just issue git config on both client hosts and both should work, but that's not true based on my experience.

What am I missing?

J Harri
  • 407
  • 2
  • 7
  • 15
  • 2
    You probably have different ssh keys on both machines. I assume you are pushing to github or some online server? You need to add both of your pub keys to the server. – EncryptedWatermelon May 07 '21 at 18:33

1 Answers1

1

The git config user.name/email is only about commit authorship, not authentication.

You should create a key dedicated to your home PC (you can replace ~ with %USERPROFILE% if you are on Windows):

ssh-keygen -P "" -t rsa -f ~/.ssh/homegh

And use a config file: ~/.ssh/config (there, you can keep ~)

Host gh
  Hostname github.com
  User git
  IdentityFile ~/.ssh/homegh

Finally, test if the public key has been properly registered to your account with

ssh -tv gh

And clone your repository:

git clone gh:<me>/<myRepo>
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250