无法在任何存储库上推到github



这很奇怪,但是我不能将任何存储库(和新的)提交给github。我已将SSH-KEY上传到GitHub。

demas@demas-home:~/dotfiles$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.

嗨,demas!您已经成功验证了,但是GitHub不提供外壳访问。

现在,我创建了一个新的存储库,并尝试将第一个提交推向GitHub:

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/demas/netrunner.git
git push -u origin master

,但Github询问我的用户名和密码。为什么?

,即使我输入了我的用户名和密码,我都会收到错误:

demas@demas-home:~/netrunner$ git push -u origin master
Username for 'https://github.com': demas
Password for 'https://demas@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/demas/netrunner.git/'

如果重要的话,我使用两因素身份验证。

问题在此行中

git remote add origin https://github.com/demas/netrunner.git

git在尝试通过HTTP协议访问服务器时不会使用您的SSH键(据我所知,在这种情况下,基本的HTTP auth使用了)。使用SSH Access(URL看起来像git@github.com:用户名/reponame.git)

解决此问题的最简单方法是使用ssh url克隆git repo进入新目录并在那里工作。

最新更新