atmoz / sftp

Securely share your files
https://hub.docker.com/r/atmoz/sftp/
MIT License
1.66k stars 834 forks source link

wrong error handling in entrypoint #222

Open Drtuna opened 4 years ago

Drtuna commented 4 years ago

Hi,

I have an error in the entry point script during creation of the keys.

    if [ ! -f /etc/ssh/ssh_host_ed25519_key ]; then
>>>        ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
    fi
    if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
        ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N ''
    fi
artifact_server_1  | Generating public/private ed25519 key pair.
artifact_server_1  | /etc/ssh/ssh_host_ed25519_key already exists.
artifact_server_1  | Overwrite (y/n)? /entrypoint: Error on line 69: ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
docker_mlflow_artifact_server_1 exited with code 1

I mounted a directory using docker-compose which contains the keys

       - type: bind
         source: /dev/ssh_keys/
         target: /etc/ssh/

However, I had a typo. Hence, it is not a regular file but a directory. the sse-keygen than tries to overwrite that specific directory with a file, which results in the question and ultimately the crash of the docker container

atmoz commented 4 years ago

How do you propose this should be handled differently?