Shoji Urashita
Shoji Urashita

Reputation: 886

Cannot push into GitLab repository via ssh

I set up GitLab and put my repository into it.

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

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

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

[email protected]'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://[email protected]/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://[email protected]/var/opt/gitlab/gi
t-data/repositories/root/reponame.git'

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

Upvotes: 1

Views: 4745

Answers (1)

Shoji Urashita
Shoji Urashita

Reputation: 886

I misunderstood the whole story.

Linux users and GitLab users are completely unrelated.

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.

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

git clone ssh://[email protected]://root/reponame.git

Upvotes: 1

Related Questions