使用gitee托管项目遇到的问题

背景

前几篇已经系统了解了git的常用命令,那我现在就来实际与托管平台操作一番

一番配置回顾经过

这里使用gitee平台进行在线代码托管。git add 、git commit一切正常,但是git push 的时候就异常了,提示如下:

Access deined: [31mDeployKey does not support push code[0m
Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

或者

Access deined: DeployKey does not support push code
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

我一看到key,以为自己配置错了。因为我这里是配置了多个key,具体的配置如下:

  • 生成多个ssh 公钥

$ ssh-keygen -t rsa -C ‘xxxxx@company.com’ -f ~/.ssh/gitee_id_rsa

  • 配置使用多个ssh公钥
    在~/.ssh目录下新建config文件,并添加配置信息,
# gitee
Host gitee.com
   HostName gitee.com
   PreferredAuthentications publickey
   IdentityFile ~/.ssh/gitee_id_rsa

这里最后一行就指定了访问主机名为‘gitee.com’,与其建立安全连接时使用到的身份验证文件,即我们通常说私钥。

  • 验证可以连接成功

ssh -T git@gitee.com

成功的话,会给你返回信息如下:

Hi zhangfengxia (DeployKey)! You've successfully authenticated, but GITEE.COM does not provide shell access.
Note: Perhaps the current use is DeployKey.
Note: DeployKey only supports pull/fetch operations

具体细节点击了解更多

回顾流程正常,开始百度寻求解法

其实看看具体的报错,人家也提示说了,DeployKey only supports pull/fetch operations, 那么了解一下git中的key吧,有两种:

  • deploy key
    只读的,不能push,属于某个项目,在需要部署的项目的setting中设置
  • SSH key
    可读可写。属于所有项目,即全局的。在profile的 setting中设置

这样我就明白了,我配置的时delpoy key,那我就直接删除原来的针对某个项目配置的key删除,重新配置了一下我的ssh key。。。。。草率了

这两个key的作用,我的了解是,托管平台嘛,在创建项目时也让你选择了是私有还是public,既然我选择的是public,那么就支持所有人来pull代码,但是我不能随随便便让别人改我的,是不是,这时候这两个key的配置的区别和作用就出来啦

写在最后

。。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值