1

I've created an SSH key (on PC A) to access my GitHub repo (works correctly). Then I copied this key to PC B. For some reason, I can't access the repo from the PC B even if the public and private keys are the same.

Cloning into 'repo'...
sign_and_send_pubkey: signing failed for RSA "/home/milano/.ssh/github-futilestudio" from agent: agent refused operation
sign_and_send_pubkey: signing failed for RSA "milano@milano-lenovo" from agent: agent refused operation
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What's the reason behind that?

EDIT

Could the reason be the signature at the end of the SSH key?

milano@milano-lenovo

which is obviously a name of the PC A.

Milano
  • 18,048
  • 37
  • 153
  • 353
  • 1
    to debug ssh issues : run `ssh -v [user]@[target host]` (for example : `ssh -v git@github.com`) – LeGEC Jun 12 '21 at 19:48
  • 1
    The key to this error is the text `agent refused operation`. There are multiple possible reasons for this; see https://stackoverflow.com/q/44250002/1256452 for details. Note that, as [VonC suggests](https://stackoverflow.com/a/67955029/1256452), using a *separate key* is often a better idea anyway. You should consider your actual situation and the security implications of separate or shared keys. – torek Jun 13 '21 at 05:46

1 Answers1

2

Could the reason be the signature at the end of the SSH key?

No, that part is ignored.
Do copy, to be sure, the public key as well as the private one.

Or, ideally, generate a new one dedicated to the second machine (since copying private keys is not the best practice)

  • If a ssh -Tv git@github.com does show you the right private key is considered, check for a difference in environment variable (type set in a CMD). In particular, make sure you don't have GIT_SSH set to Windows 10 openSSH.
    Type where ssh to make sure Git is using the same openSSH on both machines.

  • If a ssh -Tv git@github.com does show you the right private key is not considered, check if on your first machine you have a %USERPROFILE%\.ssh\config, which should then be replicated on the second one.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250