"Update the '.ssh/authorized_keys' file" claims to be successful, to no effect #2789

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

Originally created by @mytskine on GitHub (Jan 21, 2019).

  • Gitea version (or commit ref): 1.5.0
  • Git version: 2.11
  • Operating system: Debian stable
  • Database (use [x]):
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Not relevant

Description

The bug is that Gitea declares a file was modified, but the file does not exist or (if created externally) stays unchanged.

As an admin user, clicking on "Update the '.ssh/authorized_keys' file with Gitea SSH keys" produces the message "The public SSH keys controlled by Gitea have been updated". I've checked that ~git/.ssh/authorized_keys was unchanged, so which file was modified? The action does not appear in the log files of Gitea, even at Trace level. The consequence is that SSH access is broken on this instance.

BTW namei -l ~git/.ssh/authorized_keys shows that the file is writable by the git user, which is the user running gitea and declared in the RUN_USER config variable. I tried to use the documentation to debug more, but the SSH process is unmentioned, apart from vague references in the "Troubleshouting" page (the various terms "user", "repository", "directory"… are unclear, because there are several of them).

Originally created by @mytskine on GitHub (Jan 21, 2019). - Gitea version (or commit ref): 1.5.0 - Git version: 2.11 - Operating system: Debian stable - Database (use `[x]`): - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Not relevant ## Description The bug is that Gitea declares a file was modified, but the file does not exist or (if created externally) stays unchanged. As an admin user, clicking on "Update the '.ssh/authorized_keys' file with Gitea SSH keys" produces the message "The public SSH keys controlled by Gitea have been updated". I've checked that `~git/.ssh/authorized_keys` was unchanged, so which file was modified? The action does not appear in the log files of Gitea, even at Trace level. The consequence is that SSH access is broken on this instance. BTW `namei -l ~git/.ssh/authorized_keys` shows that the file is writable by the `git` user, which is the user running `gitea` and declared in the `RUN_USER` config variable. I tried to use the documentation to debug more, but the SSH process is unmentioned, apart from vague references in the "Troubleshouting" page (the various terms "user", "repository", "directory"… are unclear, because there are several of them).
Author
Owner

@mytskine commented on GitHub (Jan 21, 2019):

The problem was that the homedir of the "git" user was overwritten when running gitea web. I suggest to update the file /contrib/systemd/gitea.service and replace the line

Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

with

Environment=GITEA_WORK_DIR=/var/lib/gitea

The unix user is already declared in the ".service" file, so these environment variables will be automatically filled. Overwriting HOME can only lead to hard-to-track errors.

@mytskine commented on GitHub (Jan 21, 2019): The problem was that the homedir of the "git" user was overwritten when running `gitea web`. I suggest to update the file [/contrib/systemd/gitea.service](https://github.com/go-gitea/gitea/blob/master/contrib/systemd/gitea.service) and replace the line ``` Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea ``` with ``` Environment=GITEA_WORK_DIR=/var/lib/gitea ``` The unix user is already declared in the ".service" file, so these environment variables will be automatically filled. Overwriting HOME can only lead to hard-to-track errors.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2789