无法通过ssh连接到github
我已经创建了密钥并将公钥放入我的github帐户。 然后,在无法通过ssh连接到github,github,ssh,public-key,Github,Ssh,Public Key,我已经创建了密钥并将公钥放入我的github帐户。 然后,在~/.ssh中,我创建了以下配置文件: Host github HostName git@github.com IdentityFile ~/.ssh/id_rsa2.pub 当我使用ssh github时 ssh: Could not resolve hostname git@github.com: nodename nor servname provided, or not known 当我做ssh-T时git@gith
~/.ssh
中,我创建了以下配置文件:
Host github
HostName git@github.com
IdentityFile ~/.ssh/id_rsa2.pub
当我使用ssh github时
ssh: Could not resolve hostname git@github.com: nodename nor servname provided, or not known
当我做ssh-T时git@github.com
Permission denied (publickey).
我做错了什么?
我在github帐户中输入的公钥表示“从未使用过”
提前感谢问题是,您正在尝试使用公钥进行身份验证。当使用ssh-keygen生成时,私钥为id_-rsa2,而公钥为id_-rsa2.pub,至少在默认情况下是这样 默认情况下,ssh使用id_rsa进行标识,因此您必须使用:
ssh -i ~/.ssh/id_rsa2 -T git@github.com
ssh配置应如下所示:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa2
Host
值很重要,因为这是您必须使用的配置。现在可以使用ssh github.com
。如果不更改Host
行,则需要使用ssh-github
,但这可能会破坏其他工具
或者,您可以使用ssh代理。在这种情况下,您不需要创建配置,只需将密钥添加到ssh代理,并将ssh添加到github
ssh-add ~/.ssh/id_rsa2
ssh -T git@github.com
问题是,您正在尝试使用公钥进行身份验证。当使用ssh-keygen生成时,私钥为id_-rsa2,而公钥为id_-rsa2.pub,至少在默认情况下是这样 默认情况下,ssh使用id_rsa进行标识,因此您必须使用:
ssh -i ~/.ssh/id_rsa2 -T git@github.com
ssh配置应如下所示:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa2
Host
值很重要,因为这是您必须使用的配置。现在可以使用ssh github.com
。如果不更改Host
行,则需要使用ssh-github
,但这可能会破坏其他工具
或者,您可以使用ssh代理。在这种情况下,您不需要创建配置,只需将密钥添加到ssh代理,并将ssh添加到github
ssh-add ~/.ssh/id_rsa2
ssh -T git@github.com