本文翻译自:SSH Key - Still asking for password and passphrase
I've been somewhat 'putting up' with Github always asking for my username and password when I clone a repository. 当我克隆存储库时,我一直在“忍受”Github总是询问我的用户名和密码。 I want to bypass this step because it is an annoyance within my workflow. 我想绕过这一步,因为这是我工作流程中的一个烦恼。
I tried setting up an SSH key (which I successfully did) using this guide. 我尝试使用本指南设置SSH密钥(我成功完成了)。 https://help.github.com/articles/generating-ssh-keys and I was successful. https://help.github.com/articles/generating-ssh-keys我成功了。
My problem is that I am still asked for my github password and passphrase when cloning a repository (using SSH). 我的问题是,在克隆存储库时(使用SSH),我仍然被要求输入我的github密码和密码。 My understanding was that after I set up this SSH key, I would no longer have to do that. 我的理解是,在设置了这个SSH密钥后,我不再需要这样做了。
I am a little unsure what to ask, so I will just state my goal. 我有点不确定要问什么,所以我只是陈述我的目标。
I want to be able to clone repositories without having to put in my Github information all the time . 我希望能够克隆存储库而无需一直输入我的Github信息 。
What am I missing with my SSH key? 我的SSH密钥丢失了什么? If anyone can provide some guidance or resources I would appreciate it, because I've always felt a little lost when it came to SSH authentication in GitHub. 如果有人可以提供一些指导或资源,我会很感激,因为在GitHub中进行SSH身份验证时,我总是感到有些失落。
From my knowledge, this is a command that tests if things are working properly, here are the output from my console: 据我所知,这是一个测试事情是否正常工作的命令,这是我控制台的输出:
~ $ ssh -T [email protected]
Saving password to keychain failed
Enter passphrase for key '/Users/MYNAME/.ssh/id_rsa':
Hi MYNAME! You've successfully authenticated, but GitHub does not provide shell access.
When I input my password, should that fail first? 当我输入密码时,首先应该失败吗? Then, when I enter my passphrase, it passes. 然后,当我输入我的密码时,它会通过。
参考:https://stackoom.com/question/1QVmo/SSH密钥-仍然要求输入密码和密码
If you work with HTTPs
urls, it'll always ask for your username / password. 如果您使用HTTPs
网址,它将始终询问您的用户名/密码。
If you're correctly using SSH
when cloning / setting remotes. 如果您在克隆/设置遥控器时正确使用SSH
。 Then make sure you have a ssh-agent to remember your password. 然后确保你有一个ssh-agent来记住你的密码。 That way, you'll only enter your passphrase once by terminal session. 这样,您只需通过终端会话输入一次密码。
If it is still too annoying, then simply set a ssh-key without passphrase. 如果它仍然太烦人,那么只需设置一个没有密码短语的ssh-key。
尝试使用ssh-agent
因为它在那里解释: https : //help.github.com/articles/working-with-ssh-key-passphrases
There may be times in which you don't want the passphrase stored in the keychain, but don't want to have to enter the passphrase over and over again. 有时您可能不希望密码链中存储密码,但不希望一遍又一遍地输入密码。
You can do that like this: 你可以这样做:
ssh-add ~/.ssh/id_rsa
This will ask you for the passphrase, enter it and it will not ask again until you restart. 这将要求您输入密码,输入密码,直到重新启动它才会再次询问。
As @dennis points out in the comments, to persist the passphrase through restarts by storing it in your keychain, you can use the -K
option ( -k
for Ubuntu) when adding the identity like this: 正如@dennis在评论中指出的那样,要通过将密码存储在钥匙串中来重新启动密码,您可以在添加如下身份时使用-K
选项( -k
用于Ubuntu):
ssh-add -K ~/.ssh/id_rsa
Once again, this will ask you for the passphrase, enter it and this time it will never ask again for this identity. 再次,这将要求您输入密码,输入密码,这次它永远不会再询问此身份。
如果您使用ssh url for git,当提示输入ssh的密码时,将用户名设置为“ git ”,将密码作为系统的登录密码
I already had set a passphrase but for some reason it wouldn't recognize it anymore. 我已经设置了一个密码,但由于某种原因它不再能识别它。 So I just added the identity file to my keychain again using ssh-add -K
and it stopped asking for my password. 所以我刚刚使用ssh-add -K
将身份文件添加到我的钥匙串中,并且它停止询问我的密码。