### SFTP with Users from Config File Source: https://github.com/atmoz/sftp/blob/master/README.md This example demonstrates configuring SFTP users by mounting a `users.conf` file into the container. The file specifies multiple users with their passwords, UIDs, and GIDs. It also mounts a volume for user home directories. ```Shell docker run \ -v /users.conf:/etc/sftp/users.conf:ro \ -v mySftpVolume:/home \ -p 2222:22 -d atmoz/sftp ``` -------------------------------- ### Run SFTP Server with Docker Source: https://github.com/atmoz/sftp/blob/master/README.md This example demonstrates the simplest way to run the SFTP server using Docker. It maps port 22 from the container to the host and creates a user 'foo' with password 'pass' who can upload files to the 'upload' directory. ```Shell docker run -p 22:22 -d atmoz/sftp foo:pass:::upload ``` -------------------------------- ### SFTP with Encrypted Password Source: https://github.com/atmoz/sftp/blob/master/README.md This example shows how to use an encrypted password for SFTP authentication. The `:e` flag is appended to the password in the command arguments. It also mounts a shared directory and exposes the SFTP service on port 2222. ```Shell docker run \ -v /share:/home/foo/share \ -p 2222:22 -d atmoz/sftp \ 'foo:$1$0G2g0GSt$ewU0t6GXG15.0hWoOX8X9.:e:1001' ``` -------------------------------- ### Share Directory with Custom UID Source: https://github.com/atmoz/sftp/blob/master/README.md This example shows how to share a specific directory from the host machine with the SFTP server. It mounts a local directory to the container's user home and sets a custom UID (1001) for the user 'foo'. The SFTP server is exposed on port 2222. ```Shell docker run \ -v /upload:/home/foo/upload \ -p 2222:22 -d atmoz/sftp \ foo:pass:1001 ``` -------------------------------- ### SFTP with SSH Key Authentication Source: https://github.com/atmoz/sftp/blob/master/README.md This example configures SFTP to use SSH key authentication. Public keys are mounted into the user's `.ssh/keys/` directory within the container. The user 'foo' can log in using their SSH key, and no password is required. ```Shell docker run \ -v /id_rsa.pub:/home/foo/.ssh/keys/id_rsa.pub:ro \ -v /id_other.pub:/home/foo/.ssh/keys/id_other.pub:ro \ -v /share:/home/foo/share \ -p 2222:22 -d atmoz/sftp \ foo::1001 ``` -------------------------------- ### Bindmount Directories in SFTP Container Source: https://github.com/atmoz/sftp/blob/master/README.md This bash script, intended to be placed in `/etc/sftp.d/`, demonstrates how to bindmount directories from the host into the SFTP container's user home directories. It includes a helper function for bindmounting and notes on permission handling and the required `CAP_SYS_ADMIN` capability. ```bash #!/bin/bash # File mounted as: /etc/sftp.d/bindmount.sh # Just an example (make your own) function bindmount() { if [ -d "$1" ]; then mkdir -p "$2" fi mount --bind $3 "$1" "$2" } # Remember permissions, you may have to fix them: # chown -R :users /data/common bindmount /data/admin-tools /home/admin/toolsindmount /data/common /home/dave/commonindmount /data/common /home/peter/commonindmount /data/docs /home/peter/docs --read-only ``` -------------------------------- ### Run SFTP Container with Custom SSH Host Keys Source: https://github.com/atmoz/sftp/blob/master/README.md This command demonstrates how to run the Atmoz SFTP container, mounting custom SSH host keys from a host directory to prevent Man-in-the-Middle warnings upon container recreation. It also maps a host directory to the container's share and exposes the SFTP port. ```docker docker run \ -v /ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key \ -v /ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key \ -v /share:/home/foo/share \ -p 2222:22 -d atmoz/sftp \ foo::1001 ``` -------------------------------- ### Docker Compose for SFTP Sharing Source: https://github.com/atmoz/sftp/blob/master/README.md This configuration uses Docker Compose to set up the SFTP service. It mounts a host directory for uploads, maps port 2222 to the container's port 22, and defines the user 'foo' with password 'pass' and UID 1001. ```YAML sftp: image: atmoz/sftp volumes: - /upload:/home/foo/upload ports: - "2222:22" command: foo:pass:1001 ``` -------------------------------- ### Generate SSH Host Keys Source: https://github.com/atmoz/sftp/blob/master/README.md These commands generate SSH host keys using ed25519 and RSA algorithms, which can then be mounted into the Atmoz SFTP container to provide persistent host keys. ```bash ssh-keygen -t ed25519 -f ssh_host_ed25519_key < /dev/null ``` ```bash ssh-keygen -t rsa -b 4096 -f ssh_host_rsa_key < /dev/null ``` -------------------------------- ### Generate Encrypted Password Source: https://github.com/atmoz/sftp/blob/master/README.md This Python code snippet, executed within a Docker container, generates an encrypted password suitable for use with the SFTP server. Replace 'YOUR_PASSWORD' with the desired plain text password. ```Shell docker run --rm python:alpine python -c "import crypt; print(crypt.crypt('YOUR_PASSWORD'))" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.