1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 16:44:26 +00:00

Correct permissions for .ssh and authorized_keys (#25721)

Set the correct permissions on the .ssh directory and authorized_keys
file, or sshd will refuse to use them and lead to clone/push/pull
failures.

It could happen when users have copied their data to a new volume and
changed the file permission by accident, and it would be very hard to
troubleshoot unless users know how to check the logs of sshd which is
started by s6.

Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
Jason Song 2023-07-06 23:00:38 +08:00 committed by GitHub
parent 45ac90eb54
commit 5b7b7c4f3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,15 @@
if [ ! -d /data/git/.ssh ]; then if [ ! -d /data/git/.ssh ]; then
mkdir -p /data/git/.ssh mkdir -p /data/git/.ssh
fi
# Set the correct permissions on the .ssh directory and authorized_keys file,
# or sshd will refuse to use them and lead to clone/push/pull failures.
# It could happen when users have copied their data to a new volume and changed the file permission by accident,
# and it would be very hard to troubleshoot unless users know how to check the logs of sshd which is started by s6.
chmod 700 /data/git/.ssh chmod 700 /data/git/.ssh
if [ -f /data/git/.ssh/authorized_keys ]; then
chmod 600 /data/git/.ssh/authorized_keys
fi fi
if [ ! -f /data/git/.ssh/environment ]; then if [ ! -f /data/git/.ssh/environment ]; then