HTTPS connection works, SSH does not, docker-compose #8157

Closed
opened 2025-11-02 07:55:31 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @Benaiah2320 on GitHub (Nov 22, 2021).

Gitea Version

1.15.6

Git Version

2.30.2

Operating System

Docker on Centos8 Stream

How are you running Gitea?

docker-compose, following install instructions on site

Database

MySQL

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

I have gitea up and running, the webserver is functioning, and I can push/pull with https, but I get this message when I use ssh:

Hi there, <user>! You've successfully authenticated with the key named <key_name>, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.
fatal: Could not read from remote repository.

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

I checked that the keys are all correct, and that all of the instructions for using gitea with docker-compose were followed.

I checked that the git user was allowed ssh access inside the container as well.

I also tried using a different key than the one that I use to ssh into the server, because I read that sometimes it doesn't like those keys to be the same, although that may have been for a completely different issue.

The only thing coming out of the docker container logs are:

2021-11-22T19:26:53.970366655Z Accepted publickey for git from 172.23.0.1 port 32864 ssh2: RSA SHA256:oMPU5a9eCQESKU6hwv1MR5xLtFVtiXRiDbpLSvxEoMA
2021-11-22T19:26:54.130474001Z 2021/11/22 19:26:54 Started GET /api/internal/serv/none/2 for 127.0.0.1:54380
2021-11-22T19:26:54.138183758Z 2021/11/22 19:26:54 Completed GET /api/internal/serv/none/2 200 OK in 9.385939ms
2021-11-22T19:26:54.145589865Z Received disconnect from 172.23.0.1 port 32864:11: disconnected by user
2021-11-22T19:26:54.145642305Z Disconnected from user git 172.23.0.1 port 32864

My docker-compose.yml:

version: "3.7"

services:
  gitea:
    image: gitea/gitea:1.15.6
    container_name: gitea
    hostname: gitea
    environment:
      - USER=$GITEAUSER
      - USER_UID=$PUID
      - USER_GID=$PGID
      - GITEA__service__DISABLE_REGISTRATION=true
      - GITEA__database__DB_TYPE=mysql
      - GITEA__database__HOST=gitea-db:3306
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=/run/secrets/db_password
      - GITEA__server__ROOT_URL=https://gitea.$DOMAINNAME/
    restart: unless-stopped
    networks:
      - t2_proxy
      - gitea
    ports:
      - "127.0.0.1:2222:22"
    volumes:
      - $ENCRYPTEDDIR/gitea:/data
      - /home/git/.ssh/:/data/git/.ssh
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      - gitea-db
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.gitea.entrypoints=https"
      - "traefik.http.routers.gitea.rule=Host(`gitea.$DOMAINNAME`)"
      - "traefik.http.routers.gitea.tls=true"
      - "traefik.http.routers.gitea.middlewares=chain-gitea@file"
      - "traefik.http.routers.gitea.service=gitea"
      - "traefik.http.services.gitea.loadbalancer.server.port=3000"

  gitea-db:
    image: mysql:8
    container_name: gitea-db
    hostname: gitea-db
    restart: unless-stopped
    secrets:
      - db_password
      - db_root_password
    environment:
      - MYSQL_ROOT_PASSWORD=/run/secrets/db_root_password
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=/run/secrets/db_password
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
      - $ENCRYPTEDDIR/gitea-db:/var/lib/mysql

networks:
  gitea:
    name: gitea
    driver: bridge
    external: false
  t2_proxy:
    name: t2_proxy
secrets:
  db_password:
    file: $DOCKERSECRETSDIR/gitea_db_password
  db_root_password:
    file: $DOCKERSECRETSDIR/gitea_db_root_password

I can use the https for now, but I'd like to get the ssh working. Otherwise I'm really liking gitea so far.

Screenshots

No response

Originally created by @Benaiah2320 on GitHub (Nov 22, 2021). ### Gitea Version 1.15.6 ### Git Version 2.30.2 ### Operating System Docker on Centos8 Stream ### How are you running Gitea? docker-compose, following install instructions on site ### Database MySQL ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Description I have gitea up and running, the webserver is functioning, and I can push/pull with https, but I get this message when I use ssh: ``` Hi there, <user>! You've successfully authenticated with the key named <key_name>, but Gitea does not provide shell access. If this is unexpected, please log in with password and setup Gitea under another user. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ```` I checked that the keys are all correct, and that all of the instructions for using gitea with docker-compose were followed. I checked that the git user was allowed ssh access inside the container as well. I also tried using a different key than the one that I use to ssh into the server, because I read that sometimes it doesn't like those keys to be the same, although that may have been for a completely different issue. The only thing coming out of the docker container logs are: ``` 2021-11-22T19:26:53.970366655Z Accepted publickey for git from 172.23.0.1 port 32864 ssh2: RSA SHA256:oMPU5a9eCQESKU6hwv1MR5xLtFVtiXRiDbpLSvxEoMA 2021-11-22T19:26:54.130474001Z 2021/11/22 19:26:54 Started GET /api/internal/serv/none/2 for 127.0.0.1:54380 2021-11-22T19:26:54.138183758Z 2021/11/22 19:26:54 Completed GET /api/internal/serv/none/2 200 OK in 9.385939ms 2021-11-22T19:26:54.145589865Z Received disconnect from 172.23.0.1 port 32864:11: disconnected by user 2021-11-22T19:26:54.145642305Z Disconnected from user git 172.23.0.1 port 32864 ``` My docker-compose.yml: ``` version: "3.7" services: gitea: image: gitea/gitea:1.15.6 container_name: gitea hostname: gitea environment: - USER=$GITEAUSER - USER_UID=$PUID - USER_GID=$PGID - GITEA__service__DISABLE_REGISTRATION=true - GITEA__database__DB_TYPE=mysql - GITEA__database__HOST=gitea-db:3306 - GITEA__database__NAME=gitea - GITEA__database__USER=gitea - GITEA__database__PASSWD=/run/secrets/db_password - GITEA__server__ROOT_URL=https://gitea.$DOMAINNAME/ restart: unless-stopped networks: - t2_proxy - gitea ports: - "127.0.0.1:2222:22" volumes: - $ENCRYPTEDDIR/gitea:/data - /home/git/.ssh/:/data/git/.ssh - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro depends_on: - gitea-db labels: - "traefik.enable=true" - "traefik.http.routers.gitea.entrypoints=https" - "traefik.http.routers.gitea.rule=Host(`gitea.$DOMAINNAME`)" - "traefik.http.routers.gitea.tls=true" - "traefik.http.routers.gitea.middlewares=chain-gitea@file" - "traefik.http.routers.gitea.service=gitea" - "traefik.http.services.gitea.loadbalancer.server.port=3000" gitea-db: image: mysql:8 container_name: gitea-db hostname: gitea-db restart: unless-stopped secrets: - db_password - db_root_password environment: - MYSQL_ROOT_PASSWORD=/run/secrets/db_root_password - MYSQL_USER=gitea - MYSQL_PASSWORD=/run/secrets/db_password - MYSQL_DATABASE=gitea networks: - gitea volumes: - $ENCRYPTEDDIR/gitea-db:/var/lib/mysql networks: gitea: name: gitea driver: bridge external: false t2_proxy: name: t2_proxy secrets: db_password: file: $DOCKERSECRETSDIR/gitea_db_password db_root_password: file: $DOCKERSECRETSDIR/gitea_db_root_password ``` I can use the https for now, but I'd like to get the ssh working. Otherwise I'm really liking gitea so far. ### Screenshots _No response_
Author
Owner

@techknowlogick commented on GitHub (Nov 22, 2021):

Does the drive that is mounted into your containers have noexec set? Seems the git hooks aren't executing possibly

@techknowlogick commented on GitHub (Nov 22, 2021): Does the drive that is mounted into your containers have noexec set? Seems the git hooks aren't executing possibly
Author
Owner

@zeripath commented on GitHub (Nov 22, 2021):

One thing concerning me is that:

Hi there, <user>! You've successfully authenticated with the key named <key_name>, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.
fatal: Could not read from remote repository.

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

Are you getting all of this when you try to push to Gitea?

If so that that's weird.

You should only get the first part of you were trying to ssh to Gitea without sending an attached git command.

@zeripath commented on GitHub (Nov 22, 2021): One thing concerning me is that: ``` Hi there, <user>! You've successfully authenticated with the key named <key_name>, but Gitea does not provide shell access. If this is unexpected, please log in with password and setup Gitea under another user. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` Are you getting all of this when you try to push to Gitea? If so that that's weird. You should only get the first part of you were trying to ssh to Gitea without sending an attached git command.
Author
Owner

@Benaiah2320 commented on GitHub (Nov 22, 2021):

Yes, I'm getting this when I do a

git push -u origin master

with origin set as

git@gitea.<domain>:<user>/<repo>.git

I thought something similar, that the command was being confused as something other than a git request. Based on it getting all the way to a place where "Gitea" could be in the error response I assumed that all of the git user stuff was set correctly.

I just double checked everything, and I found that I had misspelled "SSH_ORIGINAL_COMMAND" in /app/gitea/gitea. It was right at the edge of my terminal, and I just passed over it.

I guess it could be helpful to make a more informative error, but it's probably more helpful for me to just check all of the code before I pull my hair out.

(It works now that the script is correct)

@Benaiah2320 commented on GitHub (Nov 22, 2021): Yes, I'm getting this when I do a ``` git push -u origin master ``` with origin set as ``` git@gitea.<domain>:<user>/<repo>.git ``` I thought something similar, that the command was being confused as something other than a git request. Based on it getting all the way to a place where "Gitea" could be in the error response I assumed that all of the git user stuff was set correctly. I just double checked everything, and I found that I had misspelled "SSH_ORIGINAL_COMMAND" in /app/gitea/gitea. It was right at the edge of my terminal, and I just passed over it. I guess it could be helpful to make a more informative error, but it's probably more helpful for me to just check all of the code before I pull my hair out. (It works now that the script is correct)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8157