无法通过SSH推送到GitLab存储库 [英] Cannot push into GitLab repository via ssh

查看:137
本文介绍了无法通过SSH推送到GitLab存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了GitLab并将其存储库放入其中.

I set up GitLab and put my repository into it.

我按如下所示制作了ssh密钥,并将公共密钥放入了我的GitLab配置文件.看来还可以.

I made ssh key as follows and put public key to my GitLab profile. It seems ok.

ssh-keygen -t rsa -C "$your_email"

我可以通过ssh克隆我的存储库.但是我不能按如下方式通过ssh将其插入.

I can clone my repository via ssh. But I cannot push into it via ssh as follows.

root@192.168.141.136's password:
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 337 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: GitLab: No such user or key
To ssh://root@192.168.141.136/var/opt/gitlab/git-data/repositories/root/reponame.g
it
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://root@192.168.141.136/var/opt/gitlab/gi
t-data/repositories/root/reponame.git'

我检查了GitHub并查看了源代码,很明显没有找到我的用户或ssh密钥. 但这很奇怪,因为我清楚地设置了它们两者.

I checked GitHub and looked into source code and it is clear that my user or ssh key was not found. But it is strange because I clearly set both of them.

        actor = if params[:key_id]
                  Key.find_by(id: params[:key_id])
                elsif params[:user_id]
                  User.find_by(id: params[:user_id])
                end

        unless actor
          return Gitlab::GitAccessStatus.new(false, 'No such user or key')
        end

推荐答案

我误解了整个故事.

Linux用户和GitLab用户完全无关.

Linux users and GitLab users are completely unrelated.

如果我想在GitLab中使用user_auser_buser_c,我要做的就是在GitLab中添加这些用户,每个用户都必须创建ssh密钥并在GitLab中进行设置.

If I would like to user user_a, user_b, and user_c in GitLab, all I have to do is to add these users in GitLab and each user have to create ssh key and set it in GitLab.

然后,如果reponemae.git是公共存储库,则它们所有人都可以通过ssh进行克隆,如下所示.

And then all of them can clone via ssh as follows if reponemae.git is public repository.

git clone ssh://git@192.168.141.136://root/reponame.git

git clone ssh://git@192.168.141.136://root/reponame.git

这篇关于无法通过SSH推送到GitLab存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆