简体   繁体   English

设置git和ssh并使用ssh-agent在Windows上使用msysgit存储密码

[英]Setting up git and ssh and using ssh-agent to store password with msysgit on Windows

Ok, this is a pretty specific question, but I had some challenges figuring it out so I figured I would share my experience so if anyone else runs into the same problems, they can fix it a little faster. 好吧,这是一个非常具体的问题,但我遇到了一些挑战,所以我想我会分享我的经验,所以如果其他人遇到同样的问题,他们可以更快地解决它。

Goal: use ssh-agent and msysgit to -as securely as possible- store ssh key password to prevent having to type it for every git command involving remote repository 目标:尽可能安全地使用ssh-agent和msysgit存储ssh密钥密码,以防止必须为涉及远程存储库的每个git命令键入它

1) Create a .bashrc file in the user directory (default windows C:\\Users\\UserName\\ ) 1)在用户目录中创建一个.bashrc文件(默认窗口C:\\Users\\UserName\\
NOTES: if you think you can just right click in the directory in Windows Explorer and create a file called .bashrc you (and me) are sadly mistaken, you'll get an error from Explorer preventing you from creating a file without a name. 注意:如果您认为您可以右键单击Windows资源管理器中的目录并创建一个名为.bashrc的文件,您(和我)很遗憾,您将从资源管理器中收到错误,阻止您创建没有名称的文件。 So, I did this from my git bash by executing echo 'blah' >> .bashrc just so I could get the file to edit in notepad to put the required code in it. 所以,我通过执行echo 'blah' >> .bashrc从我的git bash做到这一点,这样我就可以在记事本中编辑文件以将所需的代码放入其中。

2) Edit .bashrc in a text editor and put the code found here: https://help.github.com/articles/working-with-ssh-key-passphrases#platform-windows under "Auto-launching ssh-agent on msysgit" 2)在文本编辑器中编辑.bashrc并将代码放在此处: https//help.github.com/articles/working-with-ssh-key-passphrases#platform-windows “自动启动ssh-agent on” msysgit”

3) restart bash. 3)重启bash。

TROUBLE SHOOTING: ps will show all running processes. 故障排除: ps将显示所有正在运行的进程。 I found that when I was testing this out, it wasn't prompting me to put in my password when bash was started. 我发现当我测试它时,它并没有提示我在bash启动时输入我的密码。 When I executed ps I noticed many ssh-agents running. 当我执行ps我注意到许多ssh-agent正在运行。 After killing them all, I was able to restart git bash and everything worked. 杀死他们后,我能够重启git bash,一切正常。 Identifying this problem took me the longest. 识别这个问题花了我最长的时间。

What about to include pass in git repo-url: 如何包含传入git repo-url:

git clone http://username:password@example.com/git/Project.git .

It's not very safe solution, but works :) 这不是非常安全的解决方案,但有效:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM