访问远程存储库时,如何使Git不询问我密码? [英] How to make Git not ask me for password when accessing remote repositories?
问题描述
我一直在寻找一些不同的SO帖子和其他论坛,以获取有关如何防止git在与远程存储库进行交互时不断要求输入密码的解释,但是我所了解的就是我需要创建ssh键.
I've been looking at a few different SO posts and other forums for an explanation of how to prevent git from constantly asking for my password whenever I interact with my remote repository, but all I understood was that I need to create ssh key.
推荐答案
如果您想使私钥更加安全,可以使用密码短语对其进行加密.实际上,您可以 使用ssh-agent
为终端/控制台会话存储一次密码,因此您不必一直保持输入密码 .
If you want to make your private key more secure, a passphrase is used to encrypt it. You can actually use ssh-agent
to store your passphrase once for a terminal/console session, so you don't have to keep entering it all the time.
您将需要使用eval `ssh-agent -s`
启动代理,使用ssh-add输入您的私钥密码,然后使用ssh-agent -k
杀死代理.它甚至带有超时ssh-add -t <timeout>
,其中<timeout>
可能类似于X小时的Xh
,X分钟的Xm
等等.
You'll need to use eval `ssh-agent -s`
to start the agent, ssh-add to enter your passphrase for your private key, and then ssh-agent -k
to kill the agent when you're done. It even comes with a timeout, ssh-add -t <timeout>
, where <timeout>
can be something like Xh
for X hours, Xm
for X minutes, and so on.
ssh-agent
在msysGit和Cygwin上可用.我不确定它在Unix/Linux/* nix系统和Apple OSX等其他平台上的可用性.
ssh-agent
is available on msysGit and Cygwin. I'm not sure about its availability on other platforms like Unix/Linux/*nix systems and Apple OSX.
您可以从此Stack Overflow答案,以及在网上四处搜寻以获取指示.
You can read more about ssh-agent
usage from this Stack Overflow answer and this Stack Overflow answer, as well as googling around for instructions online.
这篇关于访问远程存储库时,如何使Git不询问我密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!