Skip to content

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

Closed
@keltik85

Description

@keltik85
  • 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:[email protected]: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://[email protected]: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 [email protected]
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/questionIssue needs no code to be fixed, only a description on how to fix it yourself.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions