mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-11 17:46:29 -05:00
Permission denied (publickey) #9854
Closed
opened 2025-11-02 08:51:25 -06:00 by GiteaMirror
·
7 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.16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1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/bug
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#9854
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tonydm on GitHub (Nov 18, 2022).
Description
Without any changes to the host, docker image version, docker-compose.yml file or data directory (config files), I can no longer access my repos via ssh. I can, however, still access the repos via the webui. I've read through the numerous issues posted w/o finding a cause or resolution. I've seen a number of posts that appear to be stale/closed w/o a resolution.
I have "Verified" keys in the user profile via the Webui. I also have a YubiKey configured. I removed it to verify that wasn't the cause. I've verified that the container
/data/git/.ssh/authorized_keysfile contains the relevant public keys. I've verified that the/etc/ssh/sshd_configfile points to the /data/git/.ssh directory.I even installed tcpdump (apk add tcpdump) to confirm that my connection from the client was indeed reaching the correct server and that there was no firewall filter blocking traffic to the docker container.
After verifying that everything seemed configured properly, etc., I moved to the next step and issued a docker pull to pull down the latest (today 11/18/2022). Still no joy. I don't understand the cause and hesitate at a complete reinstall as I find no reason for the failure in the first place. I don't want to repeat this scenario.
Thank you very much
within the container
within the container
Gitea Version
v1.17.3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
https://gist.github.com/tonydm/ea7f990515f7891f4c61507e8f0821c6
Screenshots
No response
Git Version
2.34.1
Operating System
Ubuntu 22.04.1 LTS
How are you running Gitea?
Cloned gitea repo and made relative docker-compose.yml file changes.
Database
MySQL
@tonydm commented on GitHub (Nov 18, 2022):
With further investigation, I think I found why the authentication is failing. According to the sshd stderr output, there is a permissions or ownership issue.
The permissions are correct for the root dir and files respectively (644 for .ssh/, 600 for authorized_keys)
But ownership nobody is in question. I have no idea of how/where/when the ownership was set to nobody. But where I'm perplexed is that I haven't touched the NFS Share permissions since it was set up to host the data for the Gitea data
git user - /etc/passwd & /etc/group
attempting to change ownership fails. may be related to the data residing on TrueNAS NFS share?
@tonydm commented on GitHub (Nov 18, 2022):
Progress, I believe I've resolved the SSH issue. But now WebUI and access to repos via ssh is broken. With that said, I had created a volume for the NFS mount in Portainer. Portainer had set it to NFSv4. While this had worked from the initial deployment until yesterday, some Googling seemed to indicate that NFSv4 has some issues with root_squash [chown: changing ownership of `.': Invalid argument](https://serverfault.com/questions/443957/chown-changing-ownership-of-invalid-argument).
I suppose that means I have to re-deploy from scratch. POOP!
Some detail
When I tried to create another Volume mount, via Portainer, and add nfsv3 as another option, the container creation would fail because the volume mount would fail. So I moved the volume mount config into the docker-compose.yml file
no v3 option is specified, which then defaults to v3 unless v4 is specified
and file ownership now shows the correct ownership
The WebUI now displays
Bad Gatewayand a git push fails... still, but for another reason. But no longer shows Permission denied (publickey)SSH now appears successful. I am prompted for my passphrase which means that the authorized_keys file is being read.
@tonydm commented on GitHub (Nov 19, 2022):
I have redeployed gitea making a change to how I access my NFS share. Instead of creating the Volume mounts in the docker-compose.yml file, I've mounted the NFS share directly at the host level. Then changed the volumes to bind mounts in the compose file. While it may not have been necessary, it simplified the mounting of the two separate paths pointing to the same NFS share. All is working as expected.
Please forgive the verbosity throughout the post, but perhaps anyone else encountering similar issues can find inspiration in resolving their issue.
NFS mount
persist mount on reboot
docker-compose.yml
host
container
I want to thank the devs for including the
-eoption in the openssh run script which enabled the sshd daemon error output needed to see what was really going on without the need to rebuild the image. Kudos!@tonydm commented on GitHub (Nov 19, 2022):
Issue resolved
@Nomsplease commented on GitHub (Nov 21, 2022):
Just noting here I ran into similar permissions issues with Docker.
My git user inside the docker was unable to access its .ssh directory, even though the directory and ls showed they had the correct permissions. These were even more permissive than necessary.
I used the root user in the docker to open up the permissions entirely on the .ssh directory. After that I used the git user to set the permissions correctly on the directory which. After which ssh worked just as expected.
I'm not sure how these permissions got so out of sync or why the git user could not access the directory, but this fixed it for me. Hopefully this stops someone else from pulling their hair out for outs due to the container being a bit silly with its permissions.
@99rgosse commented on GitHub (Nov 22, 2022):
I was having the same issue after upgrading docker gitea from 1.16.8 to 1.17.3
I solved this by setting the HOME_PATH in app.ini:
@gylove1994 commented on GitHub (Dec 9, 2022):
The error log
Due to this caused the error:
how to fix
try to use:
chown -R 1000:1000 ./.ssh(1000:1000 is your git user uid:gid) in your git home path.It could be able to fix the problem.
About chown command
The chown command is used to change the owner and group of a file or directory. The -R option specifies that the owner and group should be recursively changed for all files and directories in subdirectories.
For example, if you use the above command, the .ssh directory and all its subdirectories and files will have their owner and group changed to the user with user ID 1000 and the group with group ID 1000.
The syntax for this command is:
Typically, you need superuser privileges to change the owner or group of a file or directory. So if you want to use the chown command, you can use the sudo command to gain superuser privileges, for example:
Please note that you should be careful when changing the owner and group of a file or directory, as this can potentially damage the integrity of the file system or cause other unintended consequences.