我按照github教程中的指示创建了密钥,在github上注册了它们,并尝试显式地使用ssh-agent -然而,每当我尝试进行拉或推操作时,git仍然会继续询问我的密码。

原因可能是什么?


当前回答

如果你没有使用GitBash并且在Windows上-你需要使用这个命令启动你的ssh-agent

start-ssh-agent.cmd

如果您的ssh代理没有设置,您可以以管理员身份打开PowerShell并将其设置为手动模式

Get-Service -Name ssh-agent | Set-Service -StartupType Manual

其他回答

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

你远程重置了吗?

git remote set-url origin <ssh url>

一旦你启动了SSH代理,使用:

eval $(ssh-agent)

做:

To add your private key to it: ssh-add This will ask you your passphrase just once, and then you should be allowed to push, provided that you uploaded the public key to Github. To add and save your key permanently on macOS: ssh-add -K This will persist it after you close and re-open it by storing it in user's keychain. If you see a warning about deprecated flags, try the new variant: ssh-add --apple-use-keychain To add and save your key permanently on Ubuntu (or equivalent): ssh-add ~/.ssh/id_rsa

以前-K标志用于添加键,但现在:

ssh-add --apple-use-keychain

-K和-A标志已弃用,已被替换 用苹果使用钥匙链和苹果装载钥匙链 分别标记。


稍后编辑:您可能需要添加ssh-add——apple-load-keychain -q到您的.bash_profile或.bashrc或.zshrc或等效文件。

听起来您可能在SSH-Agent本身遇到了问题。我会试着排除故障。

1)你做SSH -add添加你的密钥到SSH?

2)你是否在使用之间关闭终端窗口,因为如果你关闭了窗口,当你重新打开它时,你将不得不再次输入密码。

使用SSH而不是HTTPS更新原始远程的url;

git remote set-url origin "SSH URL COPIED FROM GIT REPO."

这对我很管用。