Skip to content

Commit

Permalink
user ssh files moved at startup if volume doesnt support permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Feb 10, 2024
1 parent 9f2d374 commit 9ae34c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions .ssh
9 changes: 8 additions & 1 deletion build/COPY_ROOT/opt/ai-dock/bin/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down

0 comments on commit 9ae34c8

Please sign in to comment.