From 9ae34c838fd6fe5e6bbfbf98f19eec9357cb19df Mon Sep 17 00:00:00 2001 From: Rob Ballantyne Date: Sat, 10 Feb 2024 12:47:01 +0000 Subject: [PATCH] user ssh files moved at startup if volume doesnt support permissions --- .ssh | 1 + build/COPY_ROOT/opt/ai-dock/bin/init.sh | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 120000 .ssh diff --git a/.ssh b/.ssh new file mode 120000 index 0000000..6a1db01 --- /dev/null +++ b/.ssh @@ -0,0 +1 @@ +/home/-linux/.ssh \ No newline at end of file diff --git a/build/COPY_ROOT/opt/ai-dock/bin/init.sh b/build/COPY_ROOT/opt/ai-dock/bin/init.sh index 3a3b0e0..8937093 100755 --- a/build/COPY_ROOT/opt/ai-dock/bin/init.sh +++ b/build/COPY_ROOT/opt/ai-dock/bin/init.sh @@ -257,10 +257,17 @@ function init_create_user() { fi # Set initial keys to match root if [[ -e /root/.ssh/authorized_keys && ! -d ${home_dir}/.ssh ]]; then - mkdir -m 700 ${home_dir}/.ssh + mkdir -pm 700 ${home_dir}/.ssh cp /root/.ssh/authorized_keys ${home_dir}/.ssh chown -R ${WORKSPACE_UID}:${WORKSPACE_GID} "${home_dir}/.ssh" chmod 600 ${home_dir}/.ssh/authorized_keys + if [[ $WORKSPACE_MOUNTED == 'true' && $WORKSPACE_PERMISSIONS == 'false' ]]; then + mkdir -pm 700 "/home/${USER_NAME}-linux" + mv "${home_dir}.ssh" "/home/${USER_NAME}-linux" + chown -R ${WORKSPACE_UID}.${WORKSPACE_GID} "/home/${USER_NAME}-linux" + chmod 600 "/home/${USER_NAME}-linux/.ssh/authorized_keys" + ln -s "/home/${USER_NAME}-linux/.ssh" "${home_dir}.ssh" + fi fi # Set username in startup sctipts sed -i "s/\$USER_NAME/$USER_NAME/g" /etc/supervisor/supervisord/conf.d/*