sftp
sftp copied to clipboard
not allowd to upload
Hey, I ran both the example docker run with user foo (unchanged), and a version with my custom user. Additionally I tried both alpine and debian, but the error persists in all 4 scenarios.
I can connect via SFTP to the machine, even list the home and upload directory, but have no permission to upload
What am I doing wrong?
Example docker compose:
version: "3.8"
services:
sftp:
image: atmoz/sftp
volumes:
- ./upload:/home/foo/upload
ports:
- "2222:22"
command: foo:pass:1001
Same here, documentation is lacking in detail
Edit: I think it also might be a permission issue related to Docker on Windows, being that the directory on the host that is mounted inside the container has Windows permissions and the user inside the container is not allowed to write
Solved it. Although I´m using Testcontainers and only use atmoz/sftp in my tests which is not critical in terms of security, you might be able to solve it in a similar manner
https://github.com/atmoz/sftp/issues/268
In production I wouldn´t be comfortable with the permissions I´ve set there.
To sum it up, I´m executing a separate command to create the user dir and set the directory permissions
mkdir -p /home/user/upload; chmod -R 007 /home/user
(Not sure why I need the public executable permissions in order to make it work)
and I´m using the command:
user:password:1001:::upload
Hope this helps in some way
Hi guys. I had this issue initially but solved with the proper permissions on the local upload dir so the docker process can read/write on it...
Permissions will change according your environment.
IMHO documentation is ok....
On Ubuntu 20.04 docker sets the ownership of /upload
directory to root by default so it needs to be changed to user. Alternatively one can create the folder manually as the user before running docker-compose up
command.
Also in the container the ownership of the folder seems to be assigned to 1000
instead of 1001
so I had to use foo:pass:1000
instead of foo:pass:1001
or leave the 1001
out to be able to upload files to /home/foo/upload
folder or I would get permission denied.
sftp> ls -la
drwxr-xr-x 3 root root 4096 Jul 31 08:40 .
drwxr-xr-x 3 root root 4096 Jul 31 08:40 ..
drwxrwxr-x 2 1000 1000 4096 Jul 31 08:36 upload
docker-compose.yml
sftp:
image: atmoz/sftp
volumes:
- ./upload:/home/foo/upload
ports:
- "2222:22"
command: foo:pass:1000