【问题标题】:How can I use my github profile SSH key to modify all my repos?如何使用我的 github 配置文件 SSH 密钥来修改我的所有存储库?
【发布时间】:2021-06-16 21:27:24
【问题描述】:

我在我的 github 配置文件中插入了一个 SSH 密钥,然后我尝试推送一些更改,但我收到了错误:权限被拒绝(公钥)。我尝试了 GitHub Docs 的解决方案,但它对我不起作用,我什至尝试了这个:

eval "$(ssh-agent -s)" && ssh-add ~/.ssh/directorytokey

如果我在 GitHub 个人资料中设置了 SSH 密钥,如何使用 SSH 修改我的存储库?

【问题讨论】:

  • 您的 repo 遥控器是否设置为通过 sshhttps 进行身份验证?
  • 你需要使用文件名来给key,而不仅仅是目录名。运行 ssh-add 后,ssh-add -l 应该会列出您可用的密钥。

标签: git github ssh


【解决方案1】:

正如评论,GitHub documentation 确实说明了将 private SSH 密钥(不是其父文件夹)添加到 ssh-agent

# start the ssh-agent in the background
$ eval `ssh-agent -s`
> Agent pid 59566
$ ssh-add ~/.ssh/id_ed25519

话虽如此,您可以:

  • 从一个没有密码保护的私钥开始,用于测试

  • 检查密钥是否被正确检测/使用

      ssh -Tv git@github.com
      # or, for a custom key filename:
      ssh -Tv -i /path/to/my/private_key git@github.com
    

您应该会看到一条欢迎消息(“嗨,...”)

【讨论】:

    猜你喜欢
    • 2021-09-07
    • 1970-01-01
    • 2022-06-18
    • 1970-01-01
    • 2017-09-15
    • 1970-01-01
    • 2021-05-21
    • 1970-01-01
    相关资源
    最近更新 更多