SSH connections fail: fatal: '/something/somerepo.git' does not appear to be a git repository #2547

Closed
opened 2025-11-02 04:40:00 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @keltik85 on GitHub (Nov 19, 2018).

  • Gitea version (or commit ref): 1.1.0
  • Git version: git version 2.7.4
  • Operating system: Ubuntu 18.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

Short Story

I can connect to my Gitea Server through the git-cli using HTTP, but SSH connections do not work.

Long Story

I am running gitea as a service using a service file /etc/systemd/system/gitea.service with the following content:

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea DISABLE_REGISTRATION=true SSH_PORT=2222
# If you want to bind Gitea to a port below 1024 uncomment
# the two values below
###
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target

The other configuration file at /etc/gitea/app.ini looks like this:

APP_NAME = Gitea: Git with a cup of tea
RUN_USER = git
RUN_MODE = prod
[database]
DB_TYPE  = sqlite3
HOST     = 127.0.0.1:3306
NAME     = gitea
USER     = gitea
PASSWD   = asdf1234.
SSL_MODE = disable
PATH     = data/gitea.db
[repository]
ROOT = /home/git/gitea-repositories
[server]
SSH_DOMAIN       = localhost
HTTP_PORT        = 3000
ROOT_URL         = http://localhost:3000/
DISABLE_SSH      = false
SSH_PORT         = 2222
LFS_START_SERVER = false
OFFLINE_MODE     = false
[mailer]
ENABLED = false
[service]
REGISTER_EMAIL_CONFIRM     = false
ENABLE_NOTIFY_MAIL         = false
DISABLE_REGISTRATION       = true
ENABLE_CAPTCHA             = false
REQUIRE_SIGNIN_VIEW        = false
DEFAULT_KEEP_EMAIL_PRIVATE = false
NO_REPLY_ADDRESS           =
[picture]
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = false
[session]
PROVIDER = file
[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /var/lib/gitea/log
[security]
INSTALL_LOCK = true
SECRET_KEY   = SM21LaUtn4

I am able to check out my repo using HTTP connections like this:

myuser@myhost ~/workspace/somerepo $ git remote set-url origin http://12.34.45.56:3000/something/somerepo.git
myuser@myhost ~/workspace/somerepo $ vim .gitignore 
myuser@myhost ~/workspace/somerepo $ git add .gitignore 
myuser@myhost ~/workspace/somerepo $ git commit -m "testing http push"
myuser@myhost ~/workspace/somerepo $ git push origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 337 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To http://myhttpuser:myhttpuserpassword@12.34.45.56:3000/something/somerepo.git
   a90b3c3..4cc65e9  master -> master

But when I switch my remote address to ssh I get an error:

myuser@myhost ~/workspace/somerepo $ git remote set-url origin ssh://git@12.34.45.56:2222/something/somerepo.git
myuser@myhost ~/workspace/somerepo $ GIT_SSH_COMMAND="ssh -i /home/myuser/.ssh/my_id_rsa -p 2222 -l git -vvv -E /home/myuser/Documents/gitea_ssh_debug.log" git fetch -v
fatal: '/something/somerepo.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.

The above command produces a logfile (/home/myuser/Documents/gitea_ssh_debug.log) for the ssh connection made by git and the output of it reads like this:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.6, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /home/myuser/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "12.34.45.56" port 2222
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 12.34.45.56 [12.34.45.56] port 2222.
debug1: Connection established.
... some stuff ommited...
debug1: Trying private key: /home/myuser/.ssh/my_id_rsa
debug3: sign_and_send_pubkey: RSA SHA256:QIrrZZUuiw2pjlVtQBo0TyfF1QLM11tmLFT/rn2bZHk
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to 12.34.45.56 ([12.34.45.56]:2222).
... some stuff ommited...
Transferred: sent 4412, received 2424 bytes, in 1.4 seconds
Bytes per second: sent 3135.8, received 1722.9
debug1: Exit status 128

So my interpretation of this debug-log is, that the ssh connection is established correctly, because when I connect manually with ssh I can log in:

myuser@myhost ~/workspace/somerepo $ ssh -p 2222 -i /home/myuser/.ssh/my_id_rsa -v git@12.34.45.56
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-39-generic x86_64)
git@my-remote-host:~$

As you can see i have already tried to give the git-cli some information about the ssh connection like ssh key to use.
I think the Gitea-Server lacks some crucial piece of configuration, but I cant find out which.

I tried already giving the git-cli some information as you can see in the commmand using the environment variable GIT_SSH_COMMAND.
Then I also with the Gitea-Gui in Settings->SSH keys I added the SSH keys that I use for the plain ssh connection, but of no avail.

Has someone had similar problems and knows how to fix it?

Originally created by @keltik85 on GitHub (Nov 19, 2018). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.1.0 - Git version: git version 2.7.4 - Operating system: Ubuntu 18.04 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant ## Description ### Short Story I can connect to my Gitea Server through the git-cli using HTTP, but SSH connections do not work. ### Long Story I am running gitea as a service using a service file `/etc/systemd/system/gitea.service` with the following content: ``` [Unit] Description=Gitea (Git with a cup of tea) After=syslog.target After=network.target [Service] # Modify these two values and uncomment them if you have # repos with lots of files and get an HTTP error 500 because # of that ### #LimitMEMLOCK=infinity #LimitNOFILE=65535 RestartSec=2s Type=simple User=git Group=git WorkingDirectory=/var/lib/gitea/ ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini Restart=always Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea DISABLE_REGISTRATION=true SSH_PORT=2222 # If you want to bind Gitea to a port below 1024 uncomment # the two values below ### #CapabilityBoundingSet=CAP_NET_BIND_SERVICE #AmbientCapabilities=CAP_NET_BIND_SERVICE [Install] WantedBy=multi-user.target ``` The other configuration file at `/etc/gitea/app.ini` looks like this: ``` APP_NAME = Gitea: Git with a cup of tea RUN_USER = git RUN_MODE = prod [database] DB_TYPE = sqlite3 HOST = 127.0.0.1:3306 NAME = gitea USER = gitea PASSWD = asdf1234. SSL_MODE = disable PATH = data/gitea.db [repository] ROOT = /home/git/gitea-repositories [server] SSH_DOMAIN = localhost HTTP_PORT = 3000 ROOT_URL = http://localhost:3000/ DISABLE_SSH = false SSH_PORT = 2222 LFS_START_SERVER = false OFFLINE_MODE = false [mailer] ENABLED = false [service] REGISTER_EMAIL_CONFIRM = false ENABLE_NOTIFY_MAIL = false DISABLE_REGISTRATION = true ENABLE_CAPTCHA = false REQUIRE_SIGNIN_VIEW = false DEFAULT_KEEP_EMAIL_PRIVATE = false NO_REPLY_ADDRESS = [picture] DISABLE_GRAVATAR = false ENABLE_FEDERATED_AVATAR = false [session] PROVIDER = file [log] MODE = file LEVEL = Info ROOT_PATH = /var/lib/gitea/log [security] INSTALL_LOCK = true SECRET_KEY = SM21LaUtn4 ``` I am able to check out my repo using HTTP connections like this: ``` myuser@myhost ~/workspace/somerepo $ git remote set-url origin http://12.34.45.56:3000/something/somerepo.git myuser@myhost ~/workspace/somerepo $ vim .gitignore myuser@myhost ~/workspace/somerepo $ git add .gitignore myuser@myhost ~/workspace/somerepo $ git commit -m "testing http push" myuser@myhost ~/workspace/somerepo $ git push origin master Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 337 bytes | 0 bytes/s, done. Total 3 (delta 1), reused 0 (delta 0) To http://myhttpuser:myhttpuserpassword@12.34.45.56:3000/something/somerepo.git a90b3c3..4cc65e9 master -> master ``` But when I switch my remote address to ssh I get an error: ``` myuser@myhost ~/workspace/somerepo $ git remote set-url origin ssh://git@12.34.45.56:2222/something/somerepo.git myuser@myhost ~/workspace/somerepo $ GIT_SSH_COMMAND="ssh -i /home/myuser/.ssh/my_id_rsa -p 2222 -l git -vvv -E /home/myuser/Documents/gitea_ssh_debug.log" git fetch -v fatal: '/something/somerepo.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. ``` The above command produces a logfile (`/home/myuser/Documents/gitea_ssh_debug.log`) for the ssh connection made by git and the output of it reads like this: ``` OpenSSH_7.2p2 Ubuntu-4ubuntu2.6, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /home/myuser/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: resolving "12.34.45.56" port 2222 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to 12.34.45.56 [12.34.45.56] port 2222. debug1: Connection established. ... some stuff ommited... debug1: Trying private key: /home/myuser/.ssh/my_id_rsa debug3: sign_and_send_pubkey: RSA SHA256:QIrrZZUuiw2pjlVtQBo0TyfF1QLM11tmLFT/rn2bZHk debug3: send packet: type 50 debug2: we sent a publickey packet, wait for reply debug3: receive packet: type 52 debug1: Authentication succeeded (publickey). Authenticated to 12.34.45.56 ([12.34.45.56]:2222). ... some stuff ommited... Transferred: sent 4412, received 2424 bytes, in 1.4 seconds Bytes per second: sent 3135.8, received 1722.9 debug1: Exit status 128 ``` So my interpretation of this debug-log is, that the ssh connection is established correctly, because when I connect manually with ssh I can log in: ``` myuser@myhost ~/workspace/somerepo $ ssh -p 2222 -i /home/myuser/.ssh/my_id_rsa -v git@12.34.45.56 Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-39-generic x86_64) git@my-remote-host:~$ ``` As you can see i have already tried to give the git-cli some information about the ssh connection like ssh key to use. I think the Gitea-Server lacks some crucial piece of configuration, but I cant find out which. I tried already giving the git-cli some information as you can see in the commmand using the environment variable GIT_SSH_COMMAND. Then I also with the Gitea-Gui in Settings->SSH keys I added the SSH keys that I use for the plain ssh connection, but of no avail. Has someone had similar problems and knows how to fix it?
GiteaMirror added the type/question label 2025-11-02 04:40:00 -06:00
Author
Owner

@lunny commented on GitHub (Nov 20, 2018):

I think change sqlite path with an absolute path maybe fix your problem.

PATH     = data/gitea.db 
@lunny commented on GitHub (Nov 20, 2018): I think change sqlite path with an absolute path maybe fix your problem. ```ini PATH = data/gitea.db ```
Author
Owner

@keltik85 commented on GitHub (Nov 21, 2018):

I think change sqlite path with an absolute path maybe fix your problem.

PATH     = data/gitea.db 

I set the Path in app.ini to /var/lib/gitea/data/gitea.db.

Restarted the Service service gitea restart.

Still the same error.

Additionally I checked that the git user has the correct access rights on that Path:

root@gitea-host: ~/# ls -all /var/lib/gitea
total 28
drwxr-xr-x  7 root root 4096 Nov 18 21:45 .
drwxr-xr-x 78 root root 4096 Nov 18 21:45 ..
drwxr-xr-x  2 root root 4096 Nov 18 21:45 custom
drwxr-x---  3 git  git  4096 Nov 20 22:14 data
drwxr-x---  3 git  git  4096 Nov 18 21:58 indexers
drwxr-x---  3 git  git  4096 Nov 21 00:03 log
drwxr-xr-x  2 root root 4096 Nov 18 21:45 public

It seems there is no problem with access right.

@keltik85 commented on GitHub (Nov 21, 2018): > I think change sqlite path with an absolute path maybe fix your problem. > > ```ini > PATH = data/gitea.db > ``` I set the Path in `app.ini` to `/var/lib/gitea/data/gitea.db`. Restarted the Service `service gitea restart`. Still the same error. Additionally I checked that the `git` user has the correct access rights on that `Path`: ``` root@gitea-host: ~/# ls -all /var/lib/gitea total 28 drwxr-xr-x 7 root root 4096 Nov 18 21:45 . drwxr-xr-x 78 root root 4096 Nov 18 21:45 .. drwxr-xr-x 2 root root 4096 Nov 18 21:45 custom drwxr-x--- 3 git git 4096 Nov 20 22:14 data drwxr-x--- 3 git git 4096 Nov 18 21:58 indexers drwxr-x--- 3 git git 4096 Nov 21 00:03 log drwxr-xr-x 2 root root 4096 Nov 18 21:45 public ``` It seems there is no problem with access right.
Author
Owner

@lunny commented on GitHub (Nov 21, 2018):

If gitea want to modify custom/app.ini? Maybe you could change custom's owner to git and retry.

@lunny commented on GitHub (Nov 21, 2018): If gitea want to modify `custom/app.ini`? Maybe you could change `custom`'s owner to `git` and retry.
Author
Owner

@keltik85 commented on GitHub (Nov 22, 2018):

If gitea want to modify custom/app.ini? Maybe you could change custom's owner to git and retry.

I did a chown -R git:git /var/lib/gitea.

Which makes ls produce:

ls -all /var/lib/gitea
total 28
drwxr-xr-x  7 git  git  4096 Nov 18 21:45 .
drwxr-xr-x 78 root root 4096 Nov 18 21:45 ..
drwxr-xr-x  2 git  git  4096 Nov 18 21:45 custom
drwxr-x---  3 git  git  4096 Nov 22 13:40 data
drwxr-x---  3 git  git  4096 Nov 18 21:58 indexers
drwxr-x---  3 git  git  4096 Nov 22 13:40 log
drwxr-xr-x  2 git  git  4096 Nov 18 21:45 public

Restarted my service: service gitea restart .

But still i get the same error over ssh.

@keltik85 commented on GitHub (Nov 22, 2018): > If gitea want to modify `custom/app.ini`? Maybe you could change `custom`'s owner to `git` and retry. I did a `chown -R git:git /var/lib/gitea`. Which makes ls produce: ``` ls -all /var/lib/gitea total 28 drwxr-xr-x 7 git git 4096 Nov 18 21:45 . drwxr-xr-x 78 root root 4096 Nov 18 21:45 .. drwxr-xr-x 2 git git 4096 Nov 18 21:45 custom drwxr-x--- 3 git git 4096 Nov 22 13:40 data drwxr-x--- 3 git git 4096 Nov 18 21:58 indexers drwxr-x--- 3 git git 4096 Nov 22 13:40 log drwxr-xr-x 2 git git 4096 Nov 18 21:45 public ``` Restarted my service: `service gitea restart` . But still i get the same error over ssh.
Author
Owner

@stale[bot] commented on GitHub (Jan 21, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 21, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@porjo commented on GitHub (Feb 7, 2019):

@keltik85 the SSH path needs to be absolute or relative to the home directory for user git, so try this instead:

ssh://git@12.34.45.56:2222/~/gitea-repositories/something/somerepo.git
@porjo commented on GitHub (Feb 7, 2019): @keltik85 the SSH path needs to be absolute or relative to the home directory for user `git`, so try this instead: ``` ssh://git@12.34.45.56:2222/~/gitea-repositories/something/somerepo.git ```
Author
Owner

@lunny commented on GitHub (Feb 8, 2019):

I will close this one, please feel free to reopen it.

@lunny commented on GitHub (Feb 8, 2019): I will close this one, please feel free to reopen it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2547