Error with SSH Container Passthrough #6394

Closed
opened 2025-11-02 06:54:36 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @Robertzi on GitHub (Nov 27, 2020).

  • Gitea version (or commit ref): 1.12.6
  • Git version:git version 2.29.2 and git version 2.16.6
  • Operating system:docker on ubuntu
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:

Description

setup gitea follow https://docs.gitea.io/en-us/install-with-docker/#ssh-container-passthrough
I use docker run instead of docker-compose :

docker run --name gitea 
-e USER_UID=1001 \
-e USER_GID=1001 \
--restart=always \
-v /home/git/gitea:/data \
-v /home/git/.ssh/:/data/git/.ssh/ \
-p 2222:22 \
-d gitea/gitea:1.12.6

create file /app/gitea/gitea :

#!/bin/sh
ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"

when I use git clone, i got this error in git bash:

$ git clone git@xxx.com:robert/test.git
Cloning into 'test'...
Gitea: Invalid repo name
Invalid repo name: test.git'" /app/gitea/gitea --config=/data/gitea/conf/app.ini serv key-1
fatal: Could not read from remote repository.

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

I tryed to do this in xxx.com host as git user (172.17.0.4 is gitea container ip):

$ git clone git@172.17.0.4:robert/test.git
Cloning into 'test'...
warning: You appear to have cloned an empty repository.

it succeed.
but got the same error use localhost:

$ git clone git@localhost:robert/test.git
Cloning into 'test'...
Gitea: Invalid repo name
Invalid repo name: test.git'" /app/gitea/gitea --config=/data/gitea/conf/app.ini serv key-1
fatal: Could not read from remote repository.

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

It seems that Gitea can't read SSH_ORIGINAL_COMMAND as expected

Originally created by @Robertzi on GitHub (Nov 27, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.12.6 - Git version:git version 2.29.2 and git version 2.16.6 - Operating system:docker on ubuntu <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - Log gist: <!-- It really is important to provide pertinent logs --> <!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems --> <!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini --> ## Description setup gitea follow https://docs.gitea.io/en-us/install-with-docker/#ssh-container-passthrough I use docker run instead of docker-compose : ``` docker run --name gitea -e USER_UID=1001 \ -e USER_GID=1001 \ --restart=always \ -v /home/git/gitea:/data \ -v /home/git/.ssh/:/data/git/.ssh/ \ -p 2222:22 \ -d gitea/gitea:1.12.6 ``` create file ```/app/gitea/gitea``` : ``` #!/bin/sh ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@" ``` when I use git clone, i got this error in git bash: ``` $ git clone git@xxx.com:robert/test.git Cloning into 'test'... Gitea: Invalid repo name Invalid repo name: test.git'" /app/gitea/gitea --config=/data/gitea/conf/app.ini serv key-1 fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` I tryed to do this in xxx.com host as git user (172.17.0.4 is gitea container ip): ``` $ git clone git@172.17.0.4:robert/test.git Cloning into 'test'... warning: You appear to have cloned an empty repository. ``` it succeed. but got the same error use localhost: ``` $ git clone git@localhost:robert/test.git Cloning into 'test'... Gitea: Invalid repo name Invalid repo name: test.git'" /app/gitea/gitea --config=/data/gitea/conf/app.ini serv key-1 fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` It seems that Gitea can't read ```SSH_ORIGINAL_COMMAND``` as expected
Author
Owner

@Robertzi commented on GitHub (Nov 30, 2020):

Thanks @pat-s ! it's working!

@Robertzi commented on GitHub (Nov 30, 2020): Thanks @pat-s ! it's working!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6394