user1049761
user1049761

Reputation: 61

GitLab ssh to hostname with local user causes "fatal: Could not read from remote repository"

An odd situation

Using Ubuntu with GitLab 7.0.0

A user (me) has a local account on the server accessed using SSH keys. A user same name as above and has an account in GitLab also with the same SSH keys.

My preferred access method is to use SSH when pushing and pulling.

So after creating repository in GitLab and trying

git remote add origin git@[HOST NAME]:[GROUP]/[PROJECT].git
git push -v -u origin master

I got:

fatal: Could not read from remote repository.
...

There are lots of web pages about this error, did all the checking and seemed ok.

git remote add origin http://[HOST NAME]:[GROUP]/[PROJECT].git
git push -v -u origin master

Worked like a charm ...

Now for other users of GitLab who DO NOT have a local account git@[HOST NAME]:[GROUP]/[PROJECT].git works fine.

Now if I do the following:

git remote add origin git@[**IP ADDRESS**]:[GROUP]/[PROJECT].git
git push -v -u origin master

It works fine!

When looking at the auth.log on the machine git@[HOST NAME]

Accepted publickey for [USER]

When looking at the auth.log on the machine git@[IP ADDRESS]

Accepted publickey for git

Any ideas?

Upvotes: 1

Views: 2425

Answers (2)

user1049761
user1049761

Reputation: 61

The problem was not with Gitlab but a feature of PuTTY. If you have a named session saved in PuTTY as the hostname of the server being connected to it will use the user name defined in the saved session not what was defined on the command line [This behaviour exists as of PuTTY V0.64].

To work around this feature make sure that the session name is not just the host name.

Upvotes: 1

jvanbaarsen
jvanbaarsen

Reputation: 339

Most likely the problem is that your key is not created properly. Can you login to your server, and remove your SSH key from the Git's ~/.ssh/authorized_keys file? After you removed it, recreate the SSH key true GitLab, changes are it will work afterwards.

See: https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide#could-not-read-from-remote-repository

Upvotes: 0

Related Questions