如何防止每次在 Windows 上使用 Git Bash 时都必须输入解密私钥的密码?如何防止、密码、都必须、Git

2023-09-06 22:31:56 作者:原来。爱早已离去

我有一个从 git 私有存储库下载的自动构建服务.问题是当它试图克隆存储库时,它需要提供密码,因为它不会被记住;所以因为没有人工交互,所以它永远等待密码.如何强制它从 id_rsa.pub 中记住?

I've an automatic building service which download from a git private repository. The problem is that when it tries to clone repository it need to provide the password, because it is not remembered; so because there is no human interaction, it waits forever the password. How can I force it to remember from id_rsa.pub?

推荐答案

对于 Windows 用户,请注意,这是我设置 Git Bash 环境以在我开始时登录一次的方式它了.我编辑我的 ~/.bashrc 文件:

For Windows users, just a note that this is how I set up the Git Bash environment to log me in once when I start it up. I edit my ~/.bashrc file:

eval `ssh-agent`
ssh-add

所以当我启动 Git Bash 时,它看起来像:

So when I start Git Bash, it looks like:

Welcome to Git (version 1.7.8-preview20111206)
(etc)
Agent pid 3376
Enter passphrase for /c/Users/starmonkey/.ssh/id_dsa:
Identity added: /c/Users/starmonkey/.ssh/id_dsa (/c/Users/starmonkey/.ssh/id_dsa)

现在我可以 ssh 到其他服务器,而无需每次都登录.

And now I can ssh to other servers without logging in every time.