0

I've just setup my first local Gitea server and everything works fine except SSH. Normal SSH works fine but not when I try to interact with Gitea.

The shown URL is ssh://[email protected]:123/user/hello-world.git Why "git@"? My username is not "git" but Gitea server runs as user "git". If I change "git" to my real username I at least can successful authenticate with my private SSH key. How can I fix that URL to display the correct username?

However, if I try git clone, I always get fatal: '/user/hello-world.git' does not appear to be a git repository

This is my gitea/app.ini file:

[server]
ROOT_URL         = https://gitea.xxx.local/
DOMAIN           = gitea.xxx.local
HTTP_PORT        = 3000
SSH_DOMAIN       = gitea.xxx.local
SSH_PORT         = 123
DISABLE_SSH      = false

Gitea is listening on localhost only, and I'm using nginx as a reverse proxy from :443 to :3000 which works fine for web but not for SSH.

openssh-server is listening on :123 and I can successfully authenticate there. How do I forward the SSH connection to the internal Gitea server? Also with nginx?

1 Answer 1

3

That's a normal and expected behavior of most Git servers, look at what GitLab give syou as a SSH cloning URL and you'll see it uses the git user as well.

That's because if your git server runs as the git user, it needs to be able to access, view, maintain and eventually delete files in the repositories.

When you add your SSH key through the Gitea interface, it will add a authorized key to the git user with no SSH privilege (port forwarding, pty, etc.) and a mandatory command that will call back into Gitea to let it know what user it attempting to access what repository. It will then decide how to handle it, whether to authorize it or not and eventually pass the information over to Git to merge into the repository.

Edit: To address the no repository part: again, that's normal and expected since the git repository is actually in the git user's home folder. So when you try and access group/repo.git from the git user that's expanded to an absolute path of /home/git/group/repo.git but if you login as user, that, would expand to /home/user/group/repo.git which might not exist, and if it did, might not be the same. (user homes are examples and will likely differ in production)

1
  • Thanks for the answer. Today - one night later - it is totally obvios that the user has to be "git". Otherwise I had to create an OS user for every Git account, that doesn't make sense. And it is also totally obvious that the user "git" needs to have SSH rights... gave him that and now everthing works like intended. Probably it was too late yesterday... :D Thanks anyway! Sep 3, 2019 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .