我git有时使用时遇到了问题.
当我使用命令git pull origin my_branch或git fetch或时git push origin my_branch,git总是要求密码短语.我不明白为什么?
我希望有人可以解释原因和避免每次输入密码的方法.
$ git fetch
Enter passphrase for key '/home/khanhpn/.ssh/id_rsa':
Run Code Online (Sandbox Code Playgroud)
Wil*_*den 55
就像Nasreddine所说,这是因为你的密钥是用密码加密的,以防止其他人阅读它.
使用密码密钥的最方便方法是使用ssh-agent启动身份验证代理(在后台运行):
$ eval "$(ssh-agent)"
Agent pid 44304
Run Code Online (Sandbox Code Playgroud)
...然后使用ssh-add向代理注册密钥,以便它自动用于后续SSH连接:
$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/khanhpn/.ssh/id_rsa:
Run Code Online (Sandbox Code Playgroud)
当您运行时ssh-add,系统会要求您输入密码,但在运行时不需要再次输入密码ssh-agent.
您可以在GitHub上找到更多信息.另请注意,每次登录时都必须执行此操作,因此您可能希望将eval "$(ssh-agent)"步骤添加到.profile脚本中.
Nas*_*ine 10
这是因为您的私有SSH密钥使用密码保护.您可以使用此命令将其删除(不推荐使用,因为任何人都可以复制您的密钥并使用它来访问您的存储库/帐户):
$ ssh-keygen -p
Enter file in which the key is (/path/to/your/.ssh/key):
Run Code Online (Sandbox Code Playgroud)
在此处提示时输入您当前的密码:
Enter old passphrase:
Key has comment 'rsa w/o comment'
Run Code Online (Sandbox Code Playgroud)
如果要在此处提示时删除密码,请留空:
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
Run Code Online (Sandbox Code Playgroud)