记住WSL中的git passphrase [英] Remember git passphrase in WSL

查看:156
本文介绍了记住WSL中的git passphrase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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:

  1. 第一次使用ssh键运行远程git命令时,git会提示我输入密码
  2. 随后没有提示,包括在新的终端窗口中(我使用ConEmu)
  3. 关闭所有控制台窗口后,返回到#1

我尝试过的事情:

  • 使用eval $(ssh-agent),后跟ssh-add;它会记住该密码,但是如果我将其放在~/.bash_profile中,那么它将提示我输入每个新的控制台窗口,并且打开很多-很多我没有使用git in.
  • git config --global credential.helper设置为cachestore
  • 一切此处
  • 使用bash.exewsl.exe使git-credentials-manager.exe正常工作
  • using eval $(ssh-agent), followed by ssh-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 to cache or store
  • everything here
  • using bash.exe and wsl.exe to get git-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屋!

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