Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 6 tasks
axelrindle opened this issue Apr 22, 2021 · 1 comment · Fixed by #16003
Closed
2 of 6 tasks

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

axelrindle opened this issue Apr 22, 2021 · 1 comment · Fixed by #16003
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@axelrindle
Copy link

  • 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 😄

@axelrindle axelrindle changed the title Ability to change ssh script path in .ssh/authorized_keys Ability to change ssh command script path in .ssh/authorized_keys Apr 22, 2021
@gimmelemons
Copy link

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.

@lunny lunny added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label May 16, 2021
zeripath added a commit to zeripath/gitea that referenced this issue May 27, 2021
techknowlogick added a commit that referenced this issue Jun 15, 2021
Fix #15595
Replaces #15978

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this issue Aug 10, 2021
@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants