2

I have three servers (two ubuntu 16.04, one mac mini) and several macbooks.

One server ubuntu is for gitlab and the other is an internal site server. The mac mini is running a CI.

Recently the gitlab server was replaced with another gitlab server. (Hardware replaced, same IP address and hostname, new software, new ssh key, all other hardware (the other servers and laptops) are using the ssh keys as before).

Any of the macbooks can SSH into either of the servers (using the username/password of a user on the server) and they can use Git to clone, push, etc with the git server via public key.

The site server can SSH (via public key) into the git server but once the welcome message appears the connection is terminated. The site server can not use git via public key as Git prompts for a password, except for when it doesn't and works using the public key which lasts for some time, it only starts to work using testing in the users documents directory, if I attempt to clone in the /var/www directory git breaks again (this may be coincidence, it has only worked twice).

The CI has no issues connecting with the git server.

Using ssh -v the output shows ssh is using the correct public key.

So running the following command on the site server

ssh git@10.10.10.10 

connects (and then disconnects) but

git clone git@10.10.10.10:somerepo.git

asks for the password of the git user.

The site server has a user (with a ssh key) registered on gitlab.

Example output from multiple calls: https://pastebin.com/QH0AntK7

  • Please use (and show results) syntactically complete and unambiguous form of clone for testing purposes git clone -v ssh://git@10.10.10.10:/Full/Path/To/myproject.git – Lazy Badger Oct 15 '17 at 20:26
  • @LazyBadger added output to question – Ray Britton Oct 16 '17 at 6:01
0

First thing to test is whether key based SSH from site server to git server works or not. From your description, it seems it doesn't. Have your cat the public key of user on site server to git user's ~/.ssh/authoried_keys prior your run of ssh?

  • Unless I'm misunderstanding you, it does work. Running ssh git@10.10.10.10 on the site server does connect and the git server recognises the user. Gitlab puts the ssh key somewhere not the auth_keys file. – Ray Britton Oct 15 '17 at 15:47
0

After creating the log for @LazyBadger, I've realised it only fails when run with sudo because it's using a different ssh key.

I've included the root users ssh key on the site servers account on the git server and now it works.

  • You can accept your own answer as well, to stop the question being listed as unanswered. – Gnudiff Oct 16 '17 at 7:07
  • @Gnudiff I will tomorrow (I have to wait until then) – Ray Britton Oct 16 '17 at 8:44
  • 2
    Why do you run git as root? – Kusalananda Oct 26 '18 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.