How to verify SSH keys properly added for Git?

2019-08-22 03:40发布

What's the command to verify SSH keys are properly added for git? There are 2 sets of keys under our ~/.ssh/ and we want to add both of them. What we did was to run ssh-add -l in git bash:

$ ssh-add -l
2048 28:1b:b8:b2:a8:f1:9b:bb:b5:85:21:d5:d8:0b:00:b2 /c/Users/myuser/.ssh/bb_rsa (RSA)
2048 3d:31:e8:f7:f5:cd:dd:c7:0b:84:16:66:23:95:af:05 /c/Users/myuser/.ssh/id_rsa (RSA)

Are those 2 sets of SSH keys shown in command ssh-add properly added for git(both public and private)?

We are getting permission denied when deploying and would like to verify that the keys are added properly.

标签: git ssh
1条回答
仙女界的扛把子
2楼-- · 2019-08-22 04:20
  • You need to add only the public keys under your github account.

    • Set the remote url to ssh protocol if its not set already:
      git remote set-url origin <url>

    • Try to do any remote operation like:

      git fetch --all --prune
      git pull
      

If the ssh is not set correctly you will get an error message.

Note:
On the first operation you might get a question asking you if you wish to add the ssh key to the known hosts. Answer with yes and it will not prompt again.

If you keep getting the Permission denied error?

  • Verify that the github user is a contributer to the project.
查看更多
登录 后发表回答