Git一直要求我输入ssh密钥的密码短语。

831
我按照github教程创建了密钥,将其注册到了github,并尝试显式地使用ssh-agent——但每次我尝试pull或push时,git仍然会要求我输入密码。原因是什么?

相关:https://dev59.com/f2Uq5IYBdhLWcg3wJM9A - Jeff
24个回答

0

我不知道是否有人需要不同的东西,但这对我帮助很大 https://dev59.com/C2w15IYBdhLWcg3wuuCn#6445525

对我来说,在每次重启时,我必须运行ssh-add --apple-use-keychain 来加载凭据,所以我将此命令添加到堆栈溢出的答案中,现在它已经解决了


0
也许不是最安全的修复方式,但简单地不设置密码短语也行,这是可选的。如果你不设置密码短语,它就不会要求输入。你可以通过以下方式更改密码短语:
$ 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.

0

为了跳过密码短语,我们可以创建没有密码短语的密钥))) 但如果这不是一个可行的方法 对于Windows,我使用ssh-agent,您可以在其中添加私钥并从.ssh文件夹中删除。如何设置ssh-agent:

# Check the current status of ssh-agent:
Get-Service | ?{$_.Name -like '*ssh-agent*'} | select -Property Name, StartType, Status

# Start the Service:
Start-Service ssh-agent

# Add your key as before:
ssh-add <path to the key>

ssh-agent 可以与 C:\Windows\System32\OpenSSH\ssh.exe 协同工作,因此我们可以通过创建环境变量来为 git 设置该 ssh.exe:

GIT_SSH: C:\Windows\System32\OpenSSH\ssh.exe

这将适用于Git和Bash。

此外,我们还可以为TortoiseGit设置此路径:设置>网络>SSH>SSH客户端


0

这个来自GitHub文档的命令对我很有帮助:

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

我不认为这会起作用。仅仅更换一个新密码并不能帮助太多,而且空密码是不被推荐的。 - Baju

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接