Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 7 tasks
keltik85 opened this issue Nov 19, 2018 · 7 comments
Closed
2 of 7 tasks
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.

Comments

@keltik85
Copy link

keltik85 commented 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:[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?

@lunny
Copy link
Member

lunny commented Nov 20, 2018

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

PATH     = data/gitea.db 

@lafriks lafriks added the type/question Issue needs no code to be fixed, only a description on how to fix it yourself. label Nov 21, 2018
@keltik85
Copy link
Author

keltik85 commented 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.

@lunny
Copy link
Member

lunny commented Nov 21, 2018

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

@keltik85
Copy link
Author

keltik85 commented 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.

@stale
Copy link

stale bot commented 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 stale bot added the issue/stale label Jan 21, 2019
@porjo
Copy link

porjo commented 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://[email protected]:2222/~/gitea-repositories/something/somerepo.git

@stale stale bot removed the issue/stale label Feb 7, 2019
@lunny
Copy link
Member

lunny commented Feb 8, 2019

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

@lunny lunny closed this as completed Feb 8, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.
Projects
None yet
Development

No branches or pull requests

4 participants