我按照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.

其他回答

从OS X El Capitan(10.11)升级到macOS Sierra(10.12)后重新启动后,这种情况一直发生在我身上。ssh-add解决方案暂时有效,但不会在再次重新启动时继续存在。

永久的解决方案是编辑(或创建)~/。ssh/config,启用UseKeychain选项。

Host *
    UseKeychain yes

相关:自从我更新到Sierra, macOS一直在问我的ssh密码

也许不是最安全的方法来解决这个问题,但不要设置密码短语,这是可选的。如果您不设置密码短语,它将不会请求它。你可以用更改密码

$ 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.

在Windows上对我有效的是(我从repo 1st中克隆了代码):

eval $(ssh-agent)
ssh-add 
git pull 

这时它最后一次向我要密码

积分:溶液是从 https://unix.stackexchange.com/questions/12195/how-to-avoid-being-asked-passphrase-each-time-i-push-to-bitbucket

在mac上, 如果你的SSH密钥每次都需要密码,你想跳过它,那么你可以试试下面,它对我来说很好

Eval "$(ssh-agent -s)" ssh-add -K .ssh/id_rsa 添加这个默认的SSH配置对我有用

主机* AddKeysToAgent是的 UseKeychain是的 IdentityFile ~ / . ssh / id_rsa

似乎您的本地repo没有更新ssh密钥…至少这是我从HTTPS到ssh时遇到的情况。

你远程重置了吗?

git remote set-url origin <ssh url>