7
votes

I've installed GitLab on an Ubuntu Server. Everything seems to work fine except I can't push/pull/clone to/from the server.

When I push I get the general error message:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I've tried everything from hours of googling, but I can't seem to locate a problem.

sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

Runs fine, OK across the board!

I can SSH into [email protected] I get:

PTY allocation request failed on channel 0
Welcome to GitLab, Anonymous!

When I do:

ssh [email protected] "ls /location/of/git/dir"

I get:

Not allowed command

The website is running, when I create a repository on the site it appears in /home/git/repository/

But I still can't push to it.

I followed this guide:

https://github.com/gitlabhq/gitlabhq/blob/5-0-stable/doc/install/installation.md

and this guide to get it running on apache:

http://shanetully.com/2012/08/running-gitlab-from-a-subdirectory-on-apache/

6
Did you add your ssh public key to gitlab? If it is recognizing you as anonymous, I would assume anonymous doesn't have read/write/create access to any repos.jeremy
Yeah, I did. I'dont know if it's not supposed to say anonymous, but I don't get a password check when I do it.Joakim Engstrom
Wish I could help more, your running a newer version of gitlab than me and they switched from gitolite (which i'm familiar with) to there own. Sorry.jeremy
I also wish you could help me more. I've no idea what the problem can be. But no worries. Hopefully I will be able to fix it someday.Joakim Engstrom

6 Answers

7
votes

I finally figured it out after many hours of debugging, and I somehow knew there was a simple issue with the configuration.

Since the second guide mention how to set up gitlab on apache with a relative url you actually have to do some more configs inside gitlab. I uncommented the line about relative url:s unicorn.rb and in gitlab-shell/config I added my whole URL (with subdirectory).

Before:

 http://web-adress.com/

after:

 http://web-adress.com/subdomain/

Now it works great.

4
votes

You can test it with the command bellow. When you login it should say your name.

ssh -T [email protected]

Welcome to GitLab, Christian Hammer!

If it says "Welcome to GitLab, Anonymous!" gitlab does not recognise you as a user of gitlab.

2
votes

I do not know if you have resolved this yet but what I found is if I generate a key with the email address I used in gitlab the process works. Steps I took:

ssh-keygen -t rsa -C "#email address#"

Creates a new ssh key using the provided email.

Generates public/private RSA key pair.

Next just use code below to dump your public key and add to GitLab SSH Keys

cat ~/.ssh/#key name#.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....*
2
votes

To be more precise regarding the accepted answer ("answered Apr 6 at 17:23" and "edited Jul 21 at 10:07" by "Joakim Engstrom"):

You're most probably in the situation where you updated Gitlab to fit your own context path (that's accessing it from http://localhost/<my_context_path> and not http://localhost).

In the how-tos for this, is not mentionned to also modify this gitlab-shell configuration file:

// logout any Gitlab open session, stop your Gitlab service, and your possible third-party webserver first  
$ sudo service apache2 stop  
$ sudo service gitlab stop  

// perform the modification that fixes it, if you indeed configured Gitlab to be accessed with a custom context path  
$ sudo -u git -H nano ~git/gitlab-shell/config.yml  

# Url to gitlab instance. Used for api calls. Should end with a slash.
-gitlab_url: "http://localhost/"
+gitlab_url: "http://localhost/<my_context_path>/"

// restart services  
$ sudo service gitlab start  
$ sudo service apache2 start  

// Try to push again from your particular Gitlab user local repository, to the Gitlab remote repository    
$ cd <path_to_my_local_repository>  
$ sudo -u <OS_username_that_owns_the_local_repository> -H git push -u origin master  
Counting objects: 3202, done.  
Delta compression using up to 2 threads.  
Compressing objects: 100% (3115/3115), done.  
Writing objects: 100% (3202/3202), 11.56 MiB | 5.34 MiB/s, done.  
Total 3202 (delta 609), reused 0 (delta 0)  
To `git@<my_FQDN>:<my_Gitlab_user_or_group_name>/<my_gitlab_project_ID>.git`  
  * [new branch]      master -> master  
Branch master set up to track remote branch master from origin.  
$   

About "similar to stackoverflow.com/questions/13071234/… – Paul Verest Jul 18 at 6:20" (Can't push to new gitlab install):
No, this is not the same issue in this page topic.

0
votes

In my case the reason was an enforced redirect to https by nginx. Check if the git user can use the gitlab-api by running

sudo -u git -H /home/git/gitlab-shell/bin/check

on the server. In my case the output was

Check GitLab API access: FAILED. code: 301

I had to change the gitlab_url in /home/git/gitlab-shell/config.yml to https://<domain>

0
votes

for me it was because i had restricted who could ssh into my server in /etc/ssh/sshd_config AllowUsers git