ssh chroot error when deployed in a podman pod #10815

Closed
opened 2025-11-02 09:18:54 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @dchats1 on GitHub (May 9, 2023).

Description

I recently tried setting up Gitea using Podman (v4.4.2) on Fedora Server 37. When I try to clone a repo I get the following error:

$ git clone git@gitea.lab.davidchatterton.com:dchatterton/test.git
Cloning into 'test'...
Connection closed by 172.16.20.70 port 22
fatal: Could not read from remote repository.

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

And in the container logs I see the follow error every time I try to clone a repo:

chroot("/var/empty"): Operation not permitted [preauth]

I've tried with and without selinux enabled. I've also come across a couple related issues, but I haven't been able to come up with a fix for podman:
https://github.com/go-gitea/gitea/issues/15907
https://gitea.com/gitea/helm-chart/issues/8

Gitea Version

1.19

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

Fedora Server 37, Podman 4.4.2

How are you running Gitea?

The current deployment is as follows:
Podman Pod:

     "CreateCommand": [
          "podman",
          "pod",
          "create",
          "--name",
          "gitea-pod",
          "--network",
          "prod",
          "--ip",
          "172.16.20.70",
          "--hostname",
          "gitea.lab.davidchatterton.com"
     ],

and the container:

     "CreateCommand": [
          "/usr/bin/podman",
          "run",
          "--cidfile=/run/container-gitea.service.ctr-id",
          "--cgroups=no-conmon",
          "--rm",
          "--sdnotify=conmon",
          "--replace",
          "--detach",
          "--name",
          "gitea-test",
          "--pod",
          "gitea-pod",
          "-v",
          "gitea:/data:z",
           "docker.io/gitea/gitea:latest"
      ],

Database

SQLite

Originally created by @dchats1 on GitHub (May 9, 2023). ### Description I recently tried setting up Gitea using Podman (v4.4.2) on Fedora Server 37. When I try to clone a repo I get the following error: ``` $ git clone git@gitea.lab.davidchatterton.com:dchatterton/test.git Cloning into 'test'... Connection closed by 172.16.20.70 port 22 fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` And in the container logs I see the follow error every time I try to clone a repo: ``` chroot("/var/empty"): Operation not permitted [preauth] ``` I've tried with and without selinux enabled. I've also come across a couple related issues, but I haven't been able to come up with a fix for podman: https://github.com/go-gitea/gitea/issues/15907 https://gitea.com/gitea/helm-chart/issues/8 ### Gitea Version 1.19 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System Fedora Server 37, Podman 4.4.2 ### How are you running Gitea? The current deployment is as follows: Podman Pod: ``` "CreateCommand": [ "podman", "pod", "create", "--name", "gitea-pod", "--network", "prod", "--ip", "172.16.20.70", "--hostname", "gitea.lab.davidchatterton.com" ], ``` and the container: ``` "CreateCommand": [ "/usr/bin/podman", "run", "--cidfile=/run/container-gitea.service.ctr-id", "--cgroups=no-conmon", "--rm", "--sdnotify=conmon", "--replace", "--detach", "--name", "gitea-test", "--pod", "gitea-pod", "-v", "gitea:/data:z", "docker.io/gitea/gitea:latest" ], ``` ### Database SQLite
GiteaMirror added the type/docstype/bug labels 2025-11-02 09:18:54 -06:00
Author
Owner

@wxiaoguang commented on GitHub (May 9, 2023):

Two solutions:

  1. use "gitea:rootless" image
  2. (OR) update the podman to latest version and enable SYS_CHROOT capability (--cap-add=SYS_CHROOT)
@wxiaoguang commented on GitHub (May 9, 2023): Two solutions: 1. use "gitea:rootless" image 2. (OR) update the podman to latest version and enable SYS_CHROOT capability (`--cap-add=SYS_CHROOT`)
Author
Owner

@wxiaoguang commented on GitHub (May 9, 2023):

More details:

  1. By default you are using "gitea:root" image, which uses OpenSSH, while OpenSSH needs "chroot"
  2. Some recent podman removes the SYS_CHROOT support, many user complains, and then podman team added it back
  3. Gitea's rootless image "gitea:rootless" ( helm has image.rootless variable ) doesn't use OpenSSH, so no chroot problem.
@wxiaoguang commented on GitHub (May 9, 2023): More details: 1. By default you are using "gitea:root" image, which uses OpenSSH, while OpenSSH needs "chroot" 2. Some recent podman removes the SYS_CHROOT support, many user complains, and then podman team added it back * https://github.com/containers/common/commit/c700408fdb5aeac5ef024aa7a4bc64abae5ddaab * (maybe) containers-common >= 0.52 3. Gitea's rootless image "gitea:rootless" ( [helm has image.rootless variable](https://gitea.com/gitea/helm-chart/issues/432) ) doesn't use OpenSSH, so no chroot problem.
Author
Owner

@dchats1 commented on GitHub (May 9, 2023):

Thanks for the quick reply @wxiaoguang! The --cap-add=SYS_CHROOT flag fixed the issue!

@dchats1 commented on GitHub (May 9, 2023): Thanks for the quick reply @wxiaoguang! The `--cap-add=SYS_CHROOT` flag fixed the issue!
Author
Owner

@wxiaoguang commented on GitHub (May 9, 2023):

I think we can keep this issue open, to improve documents.

@wxiaoguang commented on GitHub (May 9, 2023): I think we can keep this issue open, to improve documents.
Author
Owner

@gorsing commented on GitHub (Jul 20, 2023):

Fix in podman 4.5.1

@gorsing commented on GitHub (Jul 20, 2023): Fix in podman 4.5.1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10815