1

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.

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'

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
Shoji Urashita
  • 826
  • 2
  • 11
  • 22
  • Are you sure about using the root for ssh url? Usually, it should be 'git': `ssh://git@192.168.141.136/var/opt/gitlab/git-data/repositories/root/reponame.git` – VonC Feb 20 '15 at 07:54
  • Yes, there is only root user now. I know it is not preferred, but I am just testing now. Now I changed it to git instead of root, but it still fails. I found that if I used http, not ssh it worked fine. h ttp://192.168.141.136/root/repository.git But I am going to open this repository to my project members, so I cannot use http. I would like to ssh. – Shoji Urashita Feb 20 '15 at 08:17
  • I am quite not sure why git@git.myserver.com:repositories/mygroup/proj1.git is default style. I know user "git" is created while installing GitLab, but I think each user would like to clone, push and pull by his own linux account, not user "git". – Shoji Urashita Feb 20 '15 at 10:06
  • I am really confused. In Linux server, there is a user "git" created while installing GitLab. User "git" home directory seems to be /var/opt/gitlab. I have /var/opt/gitlab/.ssh/authorized_keys and its content seems to be correct. Does GitLab user "Administrator" is Linux user "git" ? – Shoji Urashita Feb 20 '15 at 10:31
  • The git user that GitLab uses, has almost no environment and no path information, etc when you ssh into them. This is on purpose, to try and lock down the account. This user does have access to your git repositoires, but not the gitlab code itself, or much of anything else on the system. The url you probably want to be using is git@192.168.141.136:root/reponame.git GitLab will determine the rest of the filesystem path for you. – twk3 Feb 20 '15 at 19:17
  • If there are user_a, user_b and user_c in linux home and if they would like to use same public git repository. I used to set them up ssh privileges, and ask them to use like ssh://user_a@192.168.141.136:/var/lib/git/reponame.git before. If I installed GitLab, do all of them use ssh://git@192.168.141.136:/root/reponame.git ? Suppose that root/reponame.git is a public repository. Do all of them use same ssh account(git) and same passoword for ssh? – Shoji Urashita Feb 21 '15 at 03:31

1 Answers1

1

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://git@192.168.141.136://root/reponame.git

Alex Antonov
  • 14,134
  • 7
  • 65
  • 142
Shoji Urashita
  • 826
  • 2
  • 11
  • 22