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

查看:36
本文介绍了无法通过 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天全站免登陆