Skip to content

SSH_USER can never be different from RUN_USER #28563

@LunarLambda

Description

@LunarLambda

Description

My gitea instance runs as user gitea, as configured by the official Arch Linux package. The gitea docs mention the following:

BUILTIN_SSH_SERVER_USER: %(RUN_USER)s: Username to use for the built-in SSH Server.

SSH_USER: %(BUILTIN_SSH_SERVER_USER)s: SSH username displayed in clone URLs. This is only for people who configure the SSH server themselves; in most cases, you want to leave this blank and modify the BUILTIN_SSH_SERVER_USER.

I am using OpenSSH, and I would like my ssh user to be git.

In sshd_config, I have:

Match User git
        AuthorizedKeysCommandUser gitea
        AuthorizedKeysCommand /usr/bin/gitea keys -e git -u %u -t %t -k %k

This is adapted from the docs.

This works, and produces the correct output when trying to authenticate as git via ssh.

This gets me as far as the following, when testing with git clone:

fatal: unrecognized command '/usr/bin/gitea --config=/etc/gitea/app.ini serv key-7'
fatal: Could not read from remote repository.

Testing the resulting command with sudo -u git /usr/bin/gitea --config=/etc/gitea/app.ini serv key-7 fails.

  1. Because /etc/gitea/app.ini is not readable by git
  2. Because gitea complains that git is not the RUN_USER (gitea)

I believe this means it is currently impossible to have an SSH user that is different from the Gitea RUN_USER, despite the documentation suggesting that it should be possible if one sets up SSH appropriately. I could not find any other way to "alias" git to gitea in SSH's configuration (tried AuthorizedKeysFile, etc.)

Related issues: #9426, #20568

Gitea Version

1.21.2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.43.0

Operating System

Arch Linux

How are you running Gitea?

Official package

Database

SQLite

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detailissue/workaroundit is or has a workaround

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions