ssh密钥github添加仍然询问用户/密码

时间:2019-12-04 10:53:15

标签: git github ssh ssh-keys

我首先为我的github生成了一个密钥。然后将其添加到和ID中。将id_rsa.pub的内容复制到我的github帐户中,并使用以下命令测试连接:

ssh -T git@github.com

此之后:

The authenticity of host 'github.com (***.**.***.*)' can't be established.
RSA key fingerprint is SHA****:************************************.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,***.**.***.' (RSA) to the list of known hosts.
Hi ****! You've successfully authenticated, but GitHub does not provide shell access.

在尝试推送内容之后,它仍然询问我我的用户名和密码,我不知道为什么。

3 个答案:

答案 0 :(得分:3)

您当前的遥控器将使用https协议。这就是为什么它仍然要求输入密码的原因。

使用git remote show origin | grep URL查看源的当前远程URL

如果以https://开头,则会要求输入用户名和密码。

然后通过git remote rm origin

将其删除

然后通过git remote add origin <url>添加ssh url 确保您在此处提供ssh网址,它应该类似于git@github.com..

转到您的github存储库,然后单击绿色克隆按钮,如果它采用https格式,请将其更改为ssh enter image description here

使用Use SSH链接将其更改为SSH

然后您应该会看到ssh网址

enter image description here

答案 1 :(得分:0)

Github不提供SSH访问。您的命令尝试通过ssh连接到github,作为与远程计算机的连接。这不是您所允许的。

您现在可以使用github中的SSH密钥进行克隆存储库,提交等操作。

git clone git@github.com:<project>

使用SSH,您可以使用注册用户对项目进行操作。现在您可以提交,执行拉取请求,...

答案 2 :(得分:0)

在这一点上,我只想在我想将自己的东西推送到github时不输入用户名和密码。我成功了但是有一天我不得不为我的VPS创建另一个ssh密钥和ID,但是我覆盖了它,我不知道我必须为每个文件创建一个ID /密钥。

因此,我删除了known_host,并删除了rsa.pub和rsa的内容,并创建了一个全新的rsa.pub和rsa。