3

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

2
  • 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 Oct 15, 2017 at 20:26
  • @LazyBadger added output to question Oct 16, 2017 at 6:01

3 Answers 3

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?

1
  • 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. Oct 15, 2017 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.

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

I stumbled upon the same issue and the problem was that I did some operations in the git user's home directory as root so the authorized SSH keys file couldn't be read.

The fix was to run:

$ chown -R git:git /home/git/.ssh

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.