Wrong SSH clone URL #1770

Closed
opened 2025-11-02 04:12:46 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @ghost on GitHub (May 8, 2018).

  • Gitea version (or commit ref): 1.3.2
  • Git version: 1:2.11.0-2ubuntu0.3
  • Operating system: Ubuntu-1704
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

When trying to clone over ssh I get following url:

ssh://git@domain:port/user/repo.git

But the repos are located under

ssh://git@domain:port/home/git/user/repo.git

I did not find an option similar to ROOT_URL for ssh. How can I configure gitea to use a custom directory for clone url over ssh without jailing my user and moving the repo root?

Gitea config

RUN_USER = git
[repository]
ROOT = /home/git
[server]
SSH_DOMAIN = domain
DISABLE_SSH = false
SSH_PORT = 22

Originally created by @ghost on GitHub (May 8, 2018). - Gitea version (or commit ref): 1.3.2 - Git version: 1:2.11.0-2ubuntu0.3 - Operating system: Ubuntu-1704 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description When trying to clone over ssh I get following url: `ssh://git@domain:port/user/repo.git` But the repos are located under `ssh://git@domain:port/home/git/user/repo.git` I did not find an option similar to `ROOT_URL` for ssh. How can I configure gitea to use a custom directory for clone url over ssh without jailing my user and moving the repo root? ## Gitea config RUN_USER = git [repository] ROOT = /home/git [server] SSH_DOMAIN = domain DISABLE_SSH = false SSH_PORT = 22
Author
Owner

@daviian commented on GitHub (May 8, 2018):

The url seems fine. Gitea handles the mapping between the url and the actual location of the repository.
Have you had problems using this url!?

@daviian commented on GitHub (May 8, 2018): The url seems fine. Gitea handles the mapping between the url and the actual location of the repository. Have you had problems using this url!?
Author
Owner

@ghost commented on GitHub (May 8, 2018):

Yep, see this gist please: https://gist.github.com/youwontguess/7df4e19490ac53d589f8cf6b8fd789f6

@ghost commented on GitHub (May 8, 2018): Yep, see this gist please: https://gist.github.com/youwontguess/7df4e19490ac53d589f8cf6b8fd789f6
Author
Owner

@daviian commented on GitHub (May 8, 2018):

I think this could be related to this one: https://github.com/go-gitea/gitea/issues/3848. Especially this comment https://github.com/go-gitea/gitea/issues/3848#issuecomment-386772101

Please try:

  • Rewrite '.ssh/authorized_keys' file (for Gitea SSH keys). There is no need to do this if you are using the built-in SSH server.
  • Resync pre-receive, update and post-receive hooks of all repositories.

from Admin Panel

EDIT 1: Another possibility is that you are missing permission to access that repository.
Maybe your public key, you've entered in your user settings, is missing / wrong.

EDIT 2: Maybe your git users lacks a login shell?

@daviian commented on GitHub (May 8, 2018): I think this could be related to this one: https://github.com/go-gitea/gitea/issues/3848. Especially this comment https://github.com/go-gitea/gitea/issues/3848#issuecomment-386772101 Please try: * Rewrite '.ssh/authorized_keys' file (for Gitea SSH keys). There is no need to do this if you are using the built-in SSH server. * Resync pre-receive, update and post-receive hooks of all repositories. from Admin Panel EDIT 1: Another possibility is that you are missing permission to access that repository. Maybe your public key, you've entered in your user settings, is missing / wrong. EDIT 2: Maybe your git users lacks a login shell?
Author
Owner

@ghost commented on GitHub (May 8, 2018):

pre-receive and update seem to be populated with the default content, if I'm not mistaken (/user/repo/settings/hooks/git)

@ghost commented on GitHub (May 8, 2018): pre-receive and update seem to be populated with the default content, if I'm not mistaken (/user/repo/settings/hooks/git)
Author
Owner

@ghost commented on GitHub (May 8, 2018):

Did not see your edits.

  • can use ssh://git@domain:port/home/git/user/repo.git without problems, so permissions are there
  • I've rerun your points. Nothing changed.
  • The git user has a login shell and it's working.
  • I'm not using ssh keys at this point. But just for the sake of testing I did setup everything to use ssh keys, still no change.
@ghost commented on GitHub (May 8, 2018): Did not see your edits. - can use ssh://git@domain:port/home/git/user/repo.git without problems, so permissions are there - I've rerun your points. Nothing changed. - The git user has a login shell and it's working. - I'm not using ssh keys at this point. But just for the sake of testing I did setup everything to use ssh keys, still no change.
Author
Owner

@daviian commented on GitHub (May 8, 2018):

@youwontguess Can you provide the log entries during repository cloning?

@daviian commented on GitHub (May 8, 2018): @youwontguess Can you provide the log entries during repository cloning?
Author
Owner

@ghost commented on GitHub (May 8, 2018):

Thank you @daviian , that was the right hint.

May 8 19:22:59 Ubuntu-1704-zesty-64-minimal sshd[2390]: Authentication refused: bad ownership or modes for directory /home/git/.ssh

Fixed that, now auth via ssh keys is working :)

@ghost commented on GitHub (May 8, 2018): Thank you @daviian , that was the right hint. May 8 19:22:59 Ubuntu-1704-zesty-64-minimal sshd[2390]: Authentication refused: bad ownership or modes for directory /home/git/.ssh Fixed that, now auth via ssh keys is working :)
Author
Owner

@daviian commented on GitHub (May 8, 2018):

You are welcome!

@daviian commented on GitHub (May 8, 2018): You are welcome!
Author
Owner

@kiemrong08 commented on GitHub (Jul 20, 2018):

I faced same problem, anyone else have a solution.
Git version 280ebcb.
OS: CentOS 7.3
DB: MySQL
Can you reproduce the bug at https://try.gitea.io: No

$ git clone git@example.com:david/c-learning.git
Cloning into 'c-learning'...
fatal: 'david/c-learning.git' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

@kiemrong08 commented on GitHub (Jul 20, 2018): I faced same problem, anyone else have a solution. Git version `280ebcb`. OS: `CentOS 7.3` DB: `MySQL` Can you reproduce the bug at https://try.gitea.io: `No` ``` $ git clone git@example.com:david/c-learning.git Cloning into 'c-learning'... fatal: 'david/c-learning.git' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ```
Author
Owner

@sky5454 commented on GitHub (Aug 7, 2019):

YES, and more than this. When didn't use port 80(I use port 3000) , the SSH clone link is wrong. The copled link is git@localhost:Exam/Repos.git, but actually it must be ssh://git@hostname:port/Exam/Repos.git


And http clone is ok. (My Repos is private, http clone works.)
@sky5454 commented on GitHub (Aug 7, 2019): YES, and more than this. When didn't use port `80`(I use port 3000) , the SSH clone link is wrong. The copled link is `git@localhost:Exam/Repos.git`, but actually it must be `ssh://git@hostname:port/Exam/Repos.git` <hr> And http clone is ok. (My Repos is private, http clone works.)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1770