sftp icon indicating copy to clipboard operation
sftp copied to clipboard

users.conf regex error

Open LeonT-A opened this issue 3 years ago • 3 comments

I'm having issues setting up the users.conf file. It seems incredibly straight-forward, but I've been ripping my hair out for a few hours with no luck.

I used this command (from the README) to encrypt my password (dummy password)...

echo -n "fQ1qVFhJ5UyN2D3WIJlooNwF297jv7lCYgEpj8E9VQOkUIZRI4w7Stq5wlOe" | docker run -i --rm atmoz/makepasswd --crypt-md5 --clearfrom=-

It returned the encrypted password, which I placed into a users.conf file...

superman:$1$MS4IkSp5$BcMB1UWAYdM1O5dX5u7VF.:e

And then mounted that file according to the README

    sftp_service:
        image: atmoz/sftp
        container_name: sftp_container
        env_file: ./docker/sftp/variables.env
        restart: unless-stopped
        ports:
            - "25000:22"
        volumes:
            - ./docker/sftp/users.conf:/etc/sftp/users.conf:ro
            - /B/temp/superman/:/home/superman/

When I build my docker-compose file, I am presented with this error and it exits with code 1...

sftp_container           | [/usr/local/bin/create-sftp-user] Parsing user data: "superman:$1$MS4IkSp5$BcMB1UWAYdM1O5dX5u7VF.:e", do not match required regex pattern: [[:digit:]]*tp-user] ERROR: Invalid UID "e

sftp_container           | /entrypoint: Error on line 60: create-sftp-user "$user"

I've also tried shorter passwords, adding uid/gid, and even using plain-text password without encryption in the users.conf file (which builds successfully, but gives me a failed password error whenever I try to connect). Using command: "superman:$$1$$MS4IkSp5$$BcMB1UWAYdM1O5dX5u7VF.:e" in my docker-compose works fine, but I cant get the users.conf file to work at all.

OS: Windows 10 Image: latest Docker: 2.3.0.3 (45519)

P.S I can't find any documentation on how to use the SFTP_USERS environment variable (specifically with multiple users). I haven't tested it yet.

LeonT-A avatar Jul 14 '20 03:07 LeonT-A

Another user was able to show me a work-around for the issue and why it was happening.

For others with this problem, look here for a temporary solution until the problem is resolved...

https://github.com/atmoz/sftp/issues/234#issuecomment-670701339

LeonT-A avatar Aug 09 '20 02:08 LeonT-A

A couple of problems are happening for you.

  1. docker cant mount single files, only directories, so
volumes:
            - ./docker/sftp/users.conf:/etc/sftp/users.conf:ro

was never going to work. 2. the /etc/sftp/ path doesnt exist in the dockerfile.

the correct way to do this is to put users.conf in a local directory, e.g. "conf/users.conf" and mount that in your compose file

        volumes:
            - docker/conf:/etc:ro**

will work, however

aubreybailey avatar Oct 04 '21 12:10 aubreybailey

docker cant mount single files, only directories, so

Not true. See https://github.com/atmoz/sftp/issues/285#issuecomment-933716962

On Docker Desktop for Windows there may be extra configuration needed, depending on your docker setup. See https://docs.docker.com/desktop/windows/#resources under "File Sharing".

atmoz avatar Oct 04 '21 20:10 atmoz