Ability to change ssh command script path in .ssh/authorized_keys #7236

Closed
opened 2025-11-02 07:20:30 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @axelrindle on GitHub (Apr 22, 2021).

  • Gitea version (or commit ref): v1.14.1
  • Git version: 2.26.3
  • Operating system: Linux pi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:
ssh git@...
PTY allocation request failed
bash: /app/gitea/gitea: Datei oder Verzeichnis nicht gefunden
Shared connection to ... closed.

Description

I'm running a Gitea instance inside a Docker container. While the SSH connection works in general, the passthrough as described in the docs does not work, because the file /app/gitea/gitea does not exist on the host. As I don't want to create that path on the host, I'd like to specify an alternative path to the script with the content described in the docs, e.g. /home/git/handle-gitea-ssh.sh.

A new environment variable would probably be suited for this, for example:

[server]
SSH_AUTHORIZED_KEYS_HANDLER=/home/git/handle-gitea-ssh.sh

The changes in the code would probably have to be made here:

e7fc078891/models/ssh_key.go (L89-L92)

The result should look like this:

- command="/app/gitea/gitea --config=/data/gitea/conf/app.ini serv key-2" ...
+ command="/home/git/handle-gitea-ssh.sh --config=/data/gitea/conf/app.ini serv key-2" ...

I'd probably open a PR by myself, but I don't know any Go 😄

Originally created by @axelrindle on GitHub (Apr 22, 2021). <!-- 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. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): `v1.14.1` - Git version: `2.26.3` - Operating system: `Linux pi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux` <!-- 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: ``` ssh git@... PTY allocation request failed bash: /app/gitea/gitea: Datei oder Verzeichnis nicht gefunden Shared connection to ... closed. ``` ## Description I'm running a Gitea instance inside a Docker container. While the SSH connection works in general, the [passthrough as described in the docs](https://docs.gitea.io/en-us/install-with-docker/#ssh-container-passthrough) does not work, because the file `/app/gitea/gitea` does not exist on the host. As I don't want to create that path on the host, I'd like to specify an alternative path to the script with the content described in the docs, e.g. `/home/git/handle-gitea-ssh.sh`. A new environment variable would probably be suited for this, for example: ```ini [server] SSH_AUTHORIZED_KEYS_HANDLER=/home/git/handle-gitea-ssh.sh ``` The changes in the code would probably have to be made here: https://github.com/go-gitea/gitea/blob/e7fc078891d41798703b66bed8bdbf55e8b7c5e1/models/ssh_key.go#L89-L92 The result should look like this: ```patch - command="/app/gitea/gitea --config=/data/gitea/conf/app.ini serv key-2" ... + command="/home/git/handle-gitea-ssh.sh --config=/data/gitea/conf/app.ini serv key-2" ... ``` I'd probably open a PR by myself, but I don't know any Go :smile:
GiteaMirror added the type/proposal label 2025-11-02 07:20:30 -06:00
Author
Owner

@gimmelemons commented on GitHub (May 15, 2021):

Exactly what I wanted too. I don't want to create the script at a location outside the git home directory and possibly mess up when I do a migration in future.

@gimmelemons commented on GitHub (May 15, 2021): Exactly what I wanted too. I don't want to create the script at a location outside the git home directory and possibly mess up when I do a migration in future.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7236