Skip to content

Commit 493a456

Browse files
GiteaBotearl-warren
authored andcommitted
Correct permissions for .ssh and authorized_keys (go-gitea#25721) (go-gitea#25731)
Backport go-gitea#25721 by @wolfogre 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: Jason Song <i@wolfogre.com> (cherry picked from commit e6801df)
1 parent b01fb88 commit 493a456

File tree

1 file changed

+9
-1
lines changed
  • docker/root/etc/s6/gitea

1 file changed

+9
-1
lines changed

docker/root/etc/s6/gitea/setup

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

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

816
if [ ! -f /data/git/.ssh/environment ]; then

0 commit comments

Comments
 (0)