Refactor file and directory creation

This PR makes a few changes to ensure files have the correct ownership, that authorized_keys is usable and that the command in authorized_keys is wrapped in quotes.