最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】git代码上传gitee仓库报错:remote You do not have permission to push to the repository via HTTPS

Git crifan 1436浏览 0评论
折腾:
【未解决】把本地已有仓库上传到Gitee码云的git仓库
期间,去上传本地代码到远端,自己的新建的gitee仓库,结果报错:
➜  xxx git:(master) git push -u origin master
remote: You do not have permission to push to the repository via HTTPS
fatal: Authentication failed for '
https://gitee.com/xxxxxx/xxx.git/
'
看来要去清空之前保存的git的用户和密码?
You do not have permission to push to the repository via HTTPS
git报错 You do not have permission to push to the responsitory_AndrewNeo-CSDN博客
说是SSH公钥的事情
SSH 公钥设置 – 码云 Gitee.com
https://gitee.com/help/articles/4191
SSH公钥 – 码云 Gitee.com
https://gitee.com/profile/sshkeys
SSH公钥
使用SSH公钥可以让你在你的电脑和码云通讯的时候使用安全连接(Git的Remote要使用SSH地址)


您当前的SSH公钥数: 0


你还没有添加任何SSH公钥

git推代码报错You do not have permission to push to the repository via HTTPS_Calla_Lj的博客-CSDN博客
GIT上传下载报错:[You do not have permission to pull from the repository]的解决方案!_GIT_任聪聪的博客-CSDN博客
git推代码报错”you do not have permission to push to the repository via HTTPS” – 台部落
git – Error when pushing to master – Stack Overflow
Git Push Error: insufficient permission for adding an object to repository database – Stack Overflow
去mac中,创建ssh密钥
SSH 公钥设置 – 码云 Gitee.com
https://gitee.com/help/articles/4191
公钥管理 – 码云 Gitee.com
https://gitee.com/help/categories/38
生成/添加SSH公钥 – 码云 Gitee.com
https://gitee.com/help/articles/4181
➜  ~ ssh-keygen -t rsa -C "xxx"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/crifan/.ssh/id_rsa):
/Users/crifan/.ssh/id_rsa already exists.
Overwrite (y/n)? n
发现之前已有,所以无需无需重新生成
去看看之前的:
➜  ~ cat /Users/crifan/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA0JdRHdYxaJqexNX5HaPCoxvSCyB8ew2DoThP5sAPWsiAuL2E
。。。
3NjHFKGs2+CHEUMW+X3Ld8lTdcPUjNoBufEOH4TrqKV+OHN6KqlrXg==
-----END RSA PRIVATE KEY-----
然后把这部分内容,拷贝过去:
结果点击 确定 去保存时,红色:
意思出错了。
参考:
生成/添加SSH公钥 – 码云 Gitee.com
https://gitee.com/help/articles/4181#article-header0
原来是自己搞错了,不是
/Users/crifan/.ssh/id_rsa
而是:
/Users/crifan/.ssh/id_rsa.pub
➜  ~ cat /Users/crifan/.ssh/id_rsa.pub
ssh-rsa AAAAB3N...PtX [email protected]
所以去粘贴过去id_rsa.pub
然后去保存
还要输入密码:
自己都忘记密码了。。
试了几次,结果找对密码了,可以添加了:
另外找到自己之前的:
【已解决】生成SSH公钥私钥和用私钥登陆远程服务器 – 在路上
再回去试试:
git push -u origin master
即可正常继续操作。
【总结】
此处,上传代码给自己的gitee仓库,已确保有权限,结果报错:
remote: You do not have permission to push to the repository via HTTPS
fatal: Authentication failed for
原因:
Gitee中,通过https的url上传代码,需要开启SSH秘钥。
去后台设置和添加SSH秘钥,再去push即可。
总体逻辑和步骤:
(1)mac中自己本地创建id_rsa.pub
ssh-keygen -t rsa -C "[email protected]"
3次回车。
其中需要输入密码: 可输入你的密码,也可以留空不用密码
生成:
~/.ssh/id_rsa.pub
(2)把id_rsa.pub的内容拷贝粘贴,加到Gitee的SSH公钥
登录Gitee->设置-》安全设置-》SSH公钥 -》 填写标题,粘贴id_rsa.pub的文本内容进入-》地确定 即可。
详见官网资料:
SSH 公钥设置 – 码云 Gitee.com
https://gitee.com/help/articles/4191#article-header0
公钥管理 – 码云 Gitee.com
https://gitee.com/help/categories/38
生成/添加SSH公钥 – 码云 Gitee.com
https://gitee.com/help/articles/4181#article-header0
另外:
对于github,也是有SSH公钥的设置的
SSH and GPG keys
以后有需要再去添加。

转载请注明:在路上 » 【已解决】git代码上传gitee仓库报错:remote You do not have permission to push to the repository via HTTPS

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.162 seconds, using 22.19MB memory