[英]Why can I not keep authenticating git with https after having added SSH key to Github?
Whenever I enter some old cloned repository on my local drive, which is still using https, I'm no longer allowed to eg git push: 每当我在仍使用https的本地驱动器上输入一些旧的克隆存储库时,就不再允许执行git push:
Username for 'https://github.com': MYUSERNAME
Password for 'https://MYUSERNAME@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/USER/REPO.git/'
.git/config
is untouched from back when the repository was cloned using https, so the url
in this file is set to https://github.com ...
.git/config
不会被修改,因此该文件中的url
设置为https://github.com ...
I could now change the url in .git/config
to use the SSH keys: url = git@github...
. 我现在可以将
.git/config
的url更改为使用SSH密钥: url = git@github...
But I'd like to keep using https here. 但我想在这里继续使用https。 How can I do that?
我怎样才能做到这一点?
SSH key is for SSH connection and not HTTP(S). SSH密钥用于SSH连接,而不用于HTTP(S)。
If your repository already has a remote repository setup with HTTP, you can easily change it with the command git remote set-url origin git@github.com:USER/REPO.git
如果您的存储库已经具有使用HTTP的远程存储库设置,则可以使用命令
git remote set-url origin git@github.com:USER/REPO.git
轻松更改它。
Turns out this didn't have anything to do with SSH keys being added. 原来,这与添加的SSH密钥没有任何关系。 I also added two-factor authentication (2FA) which was the reason I started having issues.
我还添加了两因素身份验证(2FA),这就是我开始遇到问题的原因。
The solution is to create a token and use that instead of the password when managing a repository via HTTPS: https://help.github.com/articles/https-cloning-errors#provide-access-token-if-2fa-enabled 解决方案是创建一个令牌,并在通过HTTPS管理存储库时使用该令牌代替密码: https : //help.github.com/articles/https-cloning-errors#provide-access-token-if-2fa-enabled
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.