记住WSL中的git passphrase [英] Remember git passphrase in WSL
问题描述
我使用WSL运行Windows 10.我在一台计算机上具有所需的行为,但是无法在其他计算机上复制.这是我的追求:
I run Windows 10 with WSL. I have the desired behaviour on one computer, but cannot replicate elsewhere. Here's what I'm after:
- 第一次使用ssh键运行远程git命令时,git会提示我输入密码
- 随后没有提示,包括在新的终端窗口中(我使用ConEmu)
- 关闭所有控制台窗口后,返回到#1
我尝试过的事情:
- 使用
eval $(ssh-agent)
,后跟ssh-add
;它会记住该密码,但是如果我将其放在~/.bash_profile
中,那么它将提示我输入每个新的控制台窗口,并且打开很多-很多我没有使用git in. - 将
git config --global credential.helper
设置为cache
或store
- 一切此处
- 使用
bash.exe
和wsl.exe
使git-credentials-manager.exe
正常工作
- using
eval $(ssh-agent)
, followed byssh-add
; it will remember the passphrase, but if I put it in my~/.bash_profile
then it prompts me for every new console window, and I open a lot - many of which I'm not using git in. - setting
git config --global credential.helper
tocache
orstore
- everything here
- using
bash.exe
andwsl.exe
to getgit-credentials-manager.exe
to work
这是我在~/.gitconfig
中添加的内容的一个示例:
[credential]
helper = "/mnt/c/Program\\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"
Here's an example of what I've put in my ~/.gitconfig
:
[credential]
helper = "/mnt/c/Program\\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"
我已经从此处安装了git credential manager
,并具有还尝试了主要的Git For Windows安装作为替代方法.
I've installed the git credential manager
from here and have also tried the main Git For Windows installation as an alternative.
我如何鼓励它记住我的密码?
How can I encourage it to remember my passphrase?
推荐答案
我找到了答案!
首先,通过将eval $(ssh-agent)
添加到.bash_profile
中,确保您一直在运行ssh-agent
.
First, make sure you have ssh-agent
running all the time by adding eval $(ssh-agent)
to your .bash_profile
.
然后将AddKeysToAgent yes
添加到您的ssh配置中:
Then add AddKeysToAgent yes
to your ssh config:
touch ~/.ssh/config
chmod 600 ~/.ssh/config
echo "AddKeysToAgent yes" >> ~/.ssh/config
第一次执行ssh时,系统会提示您,但密码会自动添加到ssh-agent
中,因此您无需再次输入密码即可结束会话并开始新的会话.
You'll get prompted when you first do some ssh, but the passphrase will be automatically added to the ssh-agent
so you won't have to type it again until you end your session and start a new one.
这篇关于记住WSL中的git passphrase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!