Skip to content

Commit

Permalink
Improve security and handling around BORG_AUTHORIZED_KEYS
Browse files Browse the repository at this point in the history
Adds `restrict` to lock down all extra features on connections.
This is what was recommended by borg's documentation.

Ignores empty lines, space/tab filled lines and comment lines.
This makes me less guilty for adding documentation.
  • Loading branch information
Spice-King authored Dec 10, 2023
1 parent 5a130c4 commit 430f90e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fi

# if BORG_AUTHORIZED_KEYS is set substitute authorized_keys file
if [ -n "${BORG_AUTHORIZED_KEYS+x}" ]; then
echo -e "${BORG_AUTHORIZED_KEYS}" | sed -e "s/^/command=\"borg serve ${BORG_SERVE_ADDITIONAL_ARGS} --restrict-to-path \/home\/borg\/backups\" /" >/home/borg/.ssh/authorized_keys
echo -e "${BORG_AUTHORIZED_KEYS}" | sed -re "/^\\s*(\$|#)/! s/^/restrict,command=\"borg serve ${BORG_SERVE_ADDITIONAL_ARGS} --restrict-to-path \/home\/borg\/backups\" /" >/home/borg/.ssh/authorized_keys
fi
chown borg:borg /home/borg/.ssh/authorized_keys
chmod og-rwx /home/borg/.ssh/authorized_keys
Expand Down

0 comments on commit 430f90e

Please sign in to comment.