go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
43.82k stars 5.38k forks source link

Ambigious doc on SSH Container Passthrough/Docker Shell #21197

Open IamIpanda opened 1 year ago

IamIpanda commented 1 year ago

Description

On section Docker Shell, it set the fake gitea as:

/usr/bin/docker exec -i -u git --env SSH_ORIGINAL_COMMAND="$SSH_ORIGINAL_COMMAND" gitea sh "$@"

And origin authorized_keys is

command="/app/gitea/gitea --config='/data/gitea/conf/app.ini' serv key-1"

So that will combine to

+ /usr/bin/docker exec -i -u git --env SSH_ORIGINAL_COMMAND=xxxxx gitea sh --config=/data/gitea/conf/app.ini serv key-1

And get a sh: can't open 'serv': No such file or directory

Is that the fake gitea

/usr/bin/docker exec -i -u git --env SSH_ORIGINAL_COMMAND="$SSH_ORIGINAL_COMMAND" gitea sh "$@"

the sh should be $0?

Or, you can get it work by change authorized_keys or set AuthorizedKeysCommand, but that's not mentioned in that section.

Gitea Version

N/A

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

N/A

Screenshots

N/A

Git Version

No response

Operating System

No response

How are you running Gitea?

Docker

Database

PostgreSQL

evlist commented 6 months ago

I have the same issue (serv not found) migrating an older version to 1.21.5. The command sent to the container appears to be "serv" when it should be "gitea serv" since there seems to be no "serv" executable and I got the following script working:

#!/bin/sh
shift
/usr/bin/docker exec -i -u git --env SSH_ORIGINAL_COMMAND="$SSH_ORIGINAL_COMMAND" gitea gitea $@

I am still not understanding why it doesn't work with the versions copied from the docs ;) ...