如何验证正确为Git添加的SSH密钥? [英] How to verify SSH keys properly added for Git?

查看:525
本文介绍了如何验证正确为Git添加的SSH密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

验证为git正确添加SSH密钥的命令是什么? ~/.ssh/下有2组键,我们想将它们都添加.我们要做的是在git bash中运行ssh-add -l:

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)

在命令ssh-add中显示的那两组SSH密钥是否已正确添加到git(公共和私有)?

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

我们在部署时会得到permission denied,并希望验证密钥是否已正确添加.

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

推荐答案

  • 您只需要在github帐户下添加公共密钥即可.

    • You need to add only the public keys under your github account.

      • 将远程URL设置为ssh协议(如果尚未设置):
        git remote set-url origin <url>

      • 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
      

    • 如果ssh设置不正确,您将收到一条错误消息.

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

      注意 :
      在第一个操作中,您可能会遇到一个问题,询问您是否要将ssh密钥添加到已知主机.回答是,它不会再次提示.

      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.

      • 验证 github用户是该项目的贡献者.
      • Verify that the github user is a contributer to the project.

      这篇关于如何验证正确为Git添加的SSH密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆