sftp
sftp copied to clipboard
Run custom scripts before generating host key
Hi Adrian,
First of all, thanks for this project, very useful to get started quickly! I was wondering what your ideas are regarding the order of execution of the custom scripts vs the creation of users and the generation of the host keys.
What we want to do is run the sftp server and get the host key and the user's SSH key at startup from our secret store. This is easily possible with the custom script functionality apart from the fact that they are only executed after the user and host key generation. We could just overwrite the generated files of course, but I'd prefer to make use of the existing implementation in the entrypoint script that handles all this for us.
I think moving the generation of host keys down below the execution of the custom scripts would solve the host key part of this issue, but I'm not sure why it's in the if [ ! -f "$userConfFinalPath" ]; then conditional.
Alternatively moving the custom script execution before the user and host key generation would fix both issues, but that would make it impossible to do anything with users (like chown on the home directory as shown in the readme). So maybe a pre and a post user-creation hook would be in order?