为什么GitHub会将公钥报告为无效? [英] Why might GitHub report a public key as invalid?

查看:396
本文介绍了为什么GitHub会将公钥报告为无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经生成了ssh密钥。

结果是:

 您的身份已保存在/home/rajani/.ssh/id_rsa。 
您的公钥已保存在/home/rajani/.ssh/id_rsa.pub。

密钥是十六进制格式,但是在将它添加到GitHub时,出现像这样的错误:

 密钥无效。 
它必须以'ssh-rsa'或'ssh-dss'开头。
检查你是否复制公钥的一半。

如何正确添加ssh密钥给GitHub?

问题


  1. ssh-keygen 实用程序通常默认为生成RSA密钥,但是您的实现可能会默认为ECDSA,而GCDHub目前不支持。

  2. 如果您确实正在生成RSA密钥,则可能试图粘贴私人密钥,而不是公钥。



解决方案




  1. 通过将 -t 标志传递给 ssh-keygen 强制生成RSA密钥。 '用 .pub 扩展名复制密钥,并且包含整个行。如果您要复制RSA公共密钥,则这将包含 ssh-rsa 前缀。 / h3>

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


    I have generated ssh key.
    The result was:

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

    The key is in hexa decimal format, but while adding it to GitHub, I am getting error like this:

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

    How I should properly add an ssh key to GitHub?

    解决方案

    The Problems

    1. The ssh-keygen utility usually defaults to generating RSA keys, but your implementation may default to ECDSA, which GitHub does not currently support.
    2. If you are truly generating RSA keys, you may be trying to paste your private key to the server, instead of your public key.

    Solutions

    1. Force RSA key generation by passing the -t flag to ssh-keygen.
    2. Make sure you're copying the key with a .pub extension, and that you include the entire line. This will include the ssh-rsa prefix if you're copying an RSA public key.

    Related

    Of course, man 1 ssh-keygen is your friend.

    这篇关于为什么GitHub会将公钥报告为无效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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