我按照github教程中的指示创建了密钥,在github上注册了它们,并尝试显式地使用ssh-agent -然而,每当我尝试进行拉或推操作时,git仍然会继续询问我的密码。
原因可能是什么?
我按照github教程中的指示创建了密钥,在github上注册了它们,并尝试显式地使用ssh-agent -然而,每当我尝试进行拉或推操作时,git仍然会继续询问我的密码。
原因可能是什么?
当前回答
也许不是最安全的方法来解决这个问题,但不要设置密码短语,这是可选的。如果您不设置密码短语,它将不会请求它。你可以用更改密码
$ ssh-keygen -p -f ~/.ssh/id_ed25519
> Enter old passphrase: [Type old passphrase]
> Key has comment 'your_email@example.com'
> Enter new passphrase (empty for no passphrase): [Type new passphrase]
> Enter same passphrase again: [Repeat the new passphrase]
> Your identification has been saved with the new passphrase.
其他回答
我也有类似的问题,但其他答案并没有解决我的问题。我想我应该继续发布这篇文章,以防有人像我一样有一个奇怪的设置。
结果发现我有多个密钥,而Git首先使用了错误的密钥。它会提示我输入密码,然后我输入它,然后Git会使用另一个可以工作的密钥(我不需要在这个密钥上输入密码)。
我刚刚删除了它用来提示我输入密码的密钥,现在它工作了!
上面没有提到的另一个可能的解决方案是使用以下命令检查您的遥控器:
git remote -v
如果远程服务器不是以git启动,而是以https启动,您可能希望按照下面的示例将其更改为git。
git remote -v // origin is https://github.com/user/myrepo.git
git remote set-url origin git@github.com:user/myrepo.git
git remote -v // check if remote is changed
也许不是最安全的方法来解决这个问题,但不要设置密码短语,这是可选的。如果您不设置密码短语,它将不会请求它。你可以用更改密码
$ ssh-keygen -p -f ~/.ssh/id_ed25519
> Enter old passphrase: [Type old passphrase]
> Key has comment 'your_email@example.com'
> Enter new passphrase (empty for no passphrase): [Type new passphrase]
> Enter same passphrase again: [Repeat the new passphrase]
> Your identification has been saved with the new passphrase.
似乎您的本地repo没有更新ssh密钥…至少这是我从HTTPS到ssh时遇到的情况。
你远程重置了吗?
git remote set-url origin <ssh url>
如果上面的解决方案不适合我,需要检查的一件事是您实际上也有公钥(通常是id_rsa.pub)。不这样做很不寻常,但这就是我的原因。
从私钥创建公钥:
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub