Skip to content

Commit c0d767f

Browse files
committed
Applied work around for docker/compose#9648
1 parent e54040a commit c0d767f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/etc/s6-overlay/scripts/prep-ssh-server

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,24 @@ set_authorized_keys_from_variable () {
5151
echo "${AUTHORIZED_KEYS}" > $SSH_USER_HOME/.ssh/authorized_keys
5252
}
5353

54+
set_authorized_keys_from_file () {
55+
echo "🔐 Using the provided authorized_keys file..."
56+
# Copy the authorized_keys file to the user's home directory
57+
# This is a workaround for https://github.com/docker/compose/issues/9648
58+
# The UID an GID options are not working with Docker Compose
59+
cp /authorized_keys $SSH_USER_HOME/.ssh/authorized_keys
60+
}
61+
5462
# ✅ AUTHORIZED_KEYS Variable, ❌ authorized_keys File: Use the variable
55-
if [ -v AUTHORIZED_KEYS ] && ! [ -f $SSH_USER_HOME/.ssh/authorized_keys ]; then
63+
if [ -v AUTHORIZED_KEYS ] && ! [ -f /authorized_keys ]; then
5664
set_authorized_keys_from_variable
5765

5866
# ❌ AUTHORIZED_KEYS Variable, ✅ authorized_keys File: Use the file
59-
elif [ -z $AUTHORIZED_KEYS ] && [ -f $SSH_USER_HOME/.ssh/authorized_keys ]; then
60-
echo "🔐 Using the provided authorized_keys file..."
67+
elif [ -z $AUTHORIZED_KEYS ] && [ -f ]; then
68+
set_authorized_keys_from_file
6169

6270
# ✅ AUTHORIZED_KEYS Variable, ✅ authorized_keys File: Use the variable
63-
elif [ -v AUTHORIZED_KEYS ] && [ -f $SSH_USER_HOME/.ssh/authorized_keys ]; then
71+
elif [ -v AUTHORIZED_KEYS ] && [ -f /authorized_keys ]; then
6472
echo "⚠️ WARNING: Both AUTHORIZED_KEYS and authorized_keys file are set."
6573
echo "ℹ️ INFO: We'll be using the AUTHORIZED_KEYS variable to configure SSH."
6674
set_authorized_keys_from_variable

0 commit comments

Comments
 (0)