【问题标题】:Why might GitHub report a public key as invalid? [closed]为什么 GitHub 会报告公钥无效? [关闭]
【发布时间】:2012-06-09 11:38:28
【问题描述】:

我已经生成了 ssh 密钥。
结果是:

Your identification has been saved in /home/rajani/.ssh/id_rsa.
Your public key has been saved in /home/rajani/.ssh/id_rsa.pub.

密钥是十六进制格式,但在将其添加到 GitHub 时,我收到如下错误:

Key is invalid. 
It must begin with 'ssh-rsa' or 'ssh-dss'. 
Check that you're copying the public half of the key .

我应该如何正确地将 ssh 密钥添加到 GitHub?

【问题讨论】:

  • 您可以通过将确切的错误消息格式化为引号来改进您的问题。
  • @CodeGnome 错误消息已格式化,并为您的答案 +1。
  • 生成 ssh 密钥后,在终端上执行: pbcopy

标签: github ssh-keys


【解决方案1】:

你应该添加“hexa decimal part”并将“ssh-rsa”放在前面,这样就可以了。

【讨论】:

    【解决方案2】:

    问题

    1. ssh-keygen 实用程序通常默认生成 RSA 密钥,但您的实现可能默认使用 GitHub 目前不支持的 ECDSA。
    2. 如果您真正生成 RSA 密钥,您可能会尝试将您的私钥而不是您的公钥粘贴到服务器。

    解决方案

    1. 通过将 -t 标志传递给 ssh-keygen 来强制生成 RSA 密钥。
    2. 确保您复制的密钥带有 .pub 扩展名,并且包含 整个 行。如果您要复制 RSA 公钥,这将包括 ssh-rsa 前缀。

    相关

    当然,man 1 ssh-keygen 是你的朋友。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-27
      • 1970-01-01
      • 1970-01-01
      • 2012-05-15
      • 2013-04-16
      • 2015-08-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多