Git总是要求我提供ssh-key密码 [英] Git always asks for my ssh-key passphrase

查看:51
本文介绍了Git总是要求我提供ssh-key密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 git 时出现问题.

当我使用命令 git pull origin my_branch git fetch git push origin my_branch 时,git总是要求输入密码作为密钥.我不明白为什么会这样?

When I use the command git pull origin my_branch or git fetch or git push origin my_branch, git always asks for my passphrase for key. I don't understand why this occurs?

有人可以解释一下为什么以及如何避免每次输入密码短语.

Can someone please explain why and how to avoid entering the passphrase each time.

$ git fetch
Enter passphrase for key '/home/khanhpn/.ssh/id_rsa':

推荐答案

就像Nasreddine所说,这是因为您的密钥已用密码短语加密,以防止他人读取它.

Like Nasreddine says, it's because your key is encrypted with a passphrase to prevent others from reading it.

使用密码短语的最便捷方法是使用 ssh-agent 以启动身份验证代理(在后台运行):

The most convenient way of using passphrased keys is by using ssh-agent to start an authentication agent (which runs in the background):

$ eval "$(ssh-agent)"
Agent pid 44304

...,然后使用 ssh-add 向代理注册您的密钥,以便将其自动用于后续的SSH连接:

...and then using ssh-add to register your key with the agent so that it's used automatically for subsequent SSH connections:

$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/khanhpn/.ssh/id_rsa:

在运行 ssh-add 时,系统会要求您输入密码,但是在 ssh-agent 运行时,您无需再次输入密码.

You'll be asked to enter your passphrase when you run ssh-add, but you won't need to do so again while ssh-agent is running.

您可以在GitHub上 中找到更多信息.另请注意,每次登录时都必须执行此操作,因此您可能想将 eval"$(ssh-agent)" 步骤添加到 .profile 脚本.

You can find more information on GitHub. Also note that you'll have to do this every time you log in, so you might like to add the eval "$(ssh-agent)" step to your .profile script.

这篇关于Git总是要求我提供ssh-key密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆