Can't clone gitlab's repo via ssh, via htt

2019-01-22 14:29发布

问题:

I'm new to gitlab and CI so i had tons of questions but some of them solved via google, SO, git mans, but not the last ...

I can't clone repo via ssh =(

If i try to clone repo via http:

lesha@lesha-SeoTeam:/var/www$ git clone http://gitlab.vbox/root/virtualboxgitlab.git
Cloning into 'virtualboxgitlab'...
Username for 'http://gitlab.vbox': root
Password for 'http://root@gitlab.vbox':
warning: You appear to have cloned an empty repository.

That's OK!

But via ssh ...

lesha@lesha-SeoTeam:/var/www$ git clone git@gitlab.vbox:root/virtualboxgitlab.git
Cloning into virtualbox 'gitlab'
git@gitlab.vbox's password:<br />   

It prompts me git's password which I didn't create during install (as I had in man)

rsa keys

I added my key via gitlab's web (to account root, actually I didn't create any other accounts)

And also I added key by "cat my_rsa.pub >> authorized_keys"

I read few posts here about ssh troubles, but most have gitolite installed

I installed gitlab 5.3 without gitolite (as in manual), may be I should ?

Also I tried ssh -vT git@gitlab.vbox and it outputs :

....
debug1: Server host key: ECDSA 48:83:ba:b3:37:72:a0:dc:ca:2c:a3:b8:78:a1:c4:ad
debug1: Host 'gitlab.vbox' is known and matches the ECDSA host key.
debug1: Found key in /home/lesha/.ssh/known_hosts:2
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/lesha/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/lesha/.ssh/id_dsa
debug1: Trying private key: /home/lesha/.ssh/id_ecdsa
debug1: Next authentication method: password
git@gitlab.vbox's password:


root@seotm-server:/home/git/.ssh# ls -l
итого 4
-rw------- 1 git git 922 Июл 18 21:05 authorized_keys

environmetnt: debian 7, nginx + passenger, gitlab 5.3, ruby 2.0.0p247 , without gitolite, puma against unicorn

please help!=) i'm stuck ...


some additions (20.07.2013):

I created user git as in manual install

sudo adduser --disabled-login --gecos 'GitLab' git

The next day, I tried to kill git and re-add simply by useradd command, after that my keys are working but i'm still not happy because:

lesha@lesha-SeoTeam:/var/www$ git clone git@gitlab.vbox:root/virtualboxgitlab.git
Cloning into 'virtualboxgitlab'...
fatal: 'root/virtualboxgitlab.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

and http works as well as previous:

lesha@lesha-SeoTeam:/var/www$ git clone http://gitlab.vbox/root/virtualboxgitlab.git
Cloning into 'virtualboxgitlab'...
Username for 'http://gitlab.vbox': root
Password for 'http://root@gitlab.vbox': 
warning: You appear to have cloned an empty repository.

So, now I don't have auth problems but have another one.

How would you troubleshoot this issue from there?

回答1:

GitLab 5.x doesn't use gitolite anymore, but gitlab-shell.

I would advise to create a dedicated account, as recommended in the installation process.

ssh git@gitlab.vbox

That ssh commands means you are asking for a secure shell on 'gitlab.vbox' as user 'git'. If that user doesn't exist... it won't work.

There is no need to try and clone repo is the tests doesn't run properly:

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

The OP reports ssh works better after creating the git user and adding the keys, but:

  • first make sure you create your keys on a 'client' account', not in ~git/.ssh/id_rsa: you are trying to open a session as git, from a client account. git is the account in which gitlab is installed.
  • You should then register your public key in the ssh page of the user account you declare through the gitlab gui. You should not "useradd" an ssh to root.

If you see this:

lesha@lesha-SeoTeam:/var/www$ git clone git@gitlab.vbox:root/virtualboxgitlab.git
Cloning into 'virtualboxgitlab'...
fatal: 'root/virtualboxgitlab.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

That also means you shouldn't specify the path of the repo (root/):

 git clone git@gitlab.vbox:virtualboxgitlab.git

It is gitlab job to know where virtualboxgitlab.git is stored (as specified in its gitlab.yml config file)

Basically, forget root, and do the full installation of gitlab as it was intended: in a 'git' account.

The OP made it work, commenting that:

"root" is administrators namespace, gitlab creates this url automatically and without it clone doesn't work, now everything clones and I begin to install gitlab CI,

The OP had to:

add my user to sudo group, made clean install, received error

/usr/local/lib/ruby/2.0.0/net/http.rb:878:in initialize': getaddrinfo: 
  Name or service not known (SocketError)

which can't resolve hostname, added gitlab.vbox to /etc/hosts



标签: gitlab