Skip to content

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

Closed
@axelrindle

Description

@axelrindle
  • 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:

gitea/models/ssh_key.go

Lines 89 to 92 in e7fc078

// AuthorizedString returns formatted public key string for authorized_keys file.
func (key *PublicKey) AuthorizedString() string {
return fmt.Sprintf(tplPublicKey, util.ShellEscape(fmt.Sprintf(tplCommand, util.ShellEscape(setting.AppPath), util.ShellEscape(setting.CustomConf), key.ID)), key.Content)
}

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 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/proposalThe new feature has not been accepted yet but needs to be discussed first.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions