{"id":13441293,"url":"https://github.com/atmoz/sftp","last_synced_at":"2025-10-19T13:59:39.288Z","repository":{"id":21542016,"uuid":"24861567","full_name":"atmoz/sftp","owner":"atmoz","description":"Securely share your files","archived":false,"fork":false,"pushed_at":"2024-09-14T14:33:09.000Z","size":260,"stargazers_count":1741,"open_issues_count":188,"forks_count":835,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-05-15T03:05:20.144Z","etag":null,"topics":["docker","openssh","sftp"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/atmoz/sftp/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atmoz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-10-06T19:34:01.000Z","updated_at":"2025-05-12T20:23:38.000Z","dependencies_parsed_at":"2024-07-12T23:43:23.231Z","dependency_job_id":"18e2391b-0167-413d-8010-e13c3d1b12e8","html_url":"https://github.com/atmoz/sftp","commit_stats":{"total_commits":172,"total_committers":17,"mean_commits":"10.117647058823529","dds":"0.12209302325581395","last_synced_commit":"eacf69313194e36a9ec991a9a163431e1d563d75"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atmoz%2Fsftp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atmoz%2Fsftp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atmoz%2Fsftp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atmoz%2Fsftp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atmoz","download_url":"https://codeload.github.com/atmoz/sftp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264765,"owners_count":22041793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","openssh","sftp"],"created_at":"2024-07-31T03:01:32.144Z","updated_at":"2025-10-19T13:59:34.240Z","avatar_url":"https://github.com/atmoz.png","language":"Shell","funding_links":[],"categories":["HarmonyOS","Shell","docker"],"sub_categories":["Windows Manager"],"readme":"# SFTP\n\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/atmoz/sftp/build.yml?logo=github) ![GitHub stars](https://img.shields.io/github/stars/atmoz/sftp?logo=github) ![Docker Stars](https://img.shields.io/docker/stars/atmoz/sftp?label=stars\u0026logo=docker) ![Docker Pulls](https://img.shields.io/docker/pulls/atmoz/sftp?label=pulls\u0026logo=docker)\n\n![OpenSSH logo](https://raw.githubusercontent.com/atmoz/sftp/master/openssh.png \"Powered by OpenSSH\")\n\n# Supported tags and respective `Dockerfile` links\n\n- [`debian`, `latest` (*Dockerfile*)](https://github.com/atmoz/sftp/blob/master/Dockerfile) ![Docker Image Size (debian)](https://img.shields.io/docker/image-size/atmoz/sftp/debian?label=debian\u0026logo=debian\u0026style=plastic)\n- [`alpine` (*Dockerfile*)](https://github.com/atmoz/sftp/blob/master/Dockerfile-alpine) ![Docker Image Size (alpine)](https://img.shields.io/docker/image-size/atmoz/sftp/alpine?label=alpine\u0026logo=Alpine%20Linux\u0026style=plastic)\n\n# Securely share your files\n\nEasy to use SFTP ([SSH File Transfer Protocol](https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol)) server with [OpenSSH](https://en.wikipedia.org/wiki/OpenSSH).\n\n# Usage\n\n- Define users in (1) command arguments, (2) `SFTP_USERS` environment variable\n  or (3) in file mounted as `/etc/sftp/users.conf` (syntax:\n  `user:pass[:e][:uid[:gid[:dir1[,dir2]...]]] ...`, see below for examples)\n  - Set UID/GID manually for your users if you want them to make changes to\n    your mounted volumes with permissions matching your host filesystem.\n  - Directory names at the end will be created under user's home directory with\n    write permission, if they aren't already present.\n- Mount volumes\n  - The users are chrooted to their home directory, so you can mount the\n    volumes in separate directories inside the user's home directory\n    (/home/user/**mounted-directory**) or just mount the whole **/home** directory.\n    Just remember that the users can't create new files directly under their\n    own home directory, so make sure there are at least one subdirectory if you\n    want them to upload files.\n  - For consistent server fingerprint, mount your own host keys (i.e. `/etc/ssh/ssh_host_*`)\n\n# Examples\n\n## Simplest docker run example\n\n```\ndocker run -p 22:22 -d atmoz/sftp foo:pass:::upload\n```\n\nUser \"foo\" with password \"pass\" can login with sftp and upload files to a folder called \"upload\". No mounted directories or custom UID/GID. Later you can inspect the files and use `--volumes-from` to mount them somewhere else (or see next example).\n\n## Sharing a directory from your computer\n\nLet's mount a directory and set UID:\n\n```\ndocker run \\\n    -v \u003chost-dir\u003e/upload:/home/foo/upload \\\n    -p 2222:22 -d atmoz/sftp \\\n    foo:pass:1001\n```\n\n### Using Docker Compose:\n\n```\nsftp:\n    image: atmoz/sftp\n    volumes:\n        - \u003chost-dir\u003e/upload:/home/foo/upload\n    ports:\n        - \"2222:22\"\n    command: foo:pass:1001\n```\n\n### Logging in\n\nThe OpenSSH server runs by default on port 22, and in this example, we are forwarding the container's port 22 to the host's port 2222. To log in with the OpenSSH client, run: `sftp -P 2222 foo@\u003chost-ip\u003e`\n\n## Store users in config\n\n```\ndocker run \\\n    -v \u003chost-dir\u003e/users.conf:/etc/sftp/users.conf:ro \\\n    -v mySftpVolume:/home \\\n    -p 2222:22 -d atmoz/sftp\n```\n\n\u003chost-dir\u003e/users.conf:\n\n```\nfoo:123:1001:100\nbar:abc:1002:100\nbaz:xyz:1003:100\n```\n\n## Encrypted password\n\nAdd `:e` behind password to mark it as encrypted. Use single quotes if using terminal.\n\n```\ndocker run \\\n    -v \u003chost-dir\u003e/share:/home/foo/share \\\n    -p 2222:22 -d atmoz/sftp \\\n    'foo:$1$0G2g0GSt$ewU0t6GXG15.0hWoOX8X9.:e:1001'\n```\n\nTip: you can use this Python code to generate encrypted passwords:  \n`docker run --rm python:alpine python -c \"import crypt; print(crypt.crypt('YOUR_PASSWORD'))\"`\n\n## Logging in with SSH keys\n\nMount public keys in the user's `.ssh/keys/` directory. All keys are automatically appended to `.ssh/authorized_keys` (you can't mount this file directly, because OpenSSH requires limited file permissions). In this example, we do not provide any password, so the user `foo` can only login with his SSH key.\n\n```\ndocker run \\\n    -v \u003chost-dir\u003e/id_rsa.pub:/home/foo/.ssh/keys/id_rsa.pub:ro \\\n    -v \u003chost-dir\u003e/id_other.pub:/home/foo/.ssh/keys/id_other.pub:ro \\\n    -v \u003chost-dir\u003e/share:/home/foo/share \\\n    -p 2222:22 -d atmoz/sftp \\\n    foo::1001\n```\n\n## Providing your own SSH host key (recommended)\n\nThis container will generate new SSH host keys at first run. To avoid that your users get a MITM warning when you recreate your container (and the host keys changes), you can mount your own host keys.\n\n```\ndocker run \\\n    -v \u003chost-dir\u003e/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key \\\n    -v \u003chost-dir\u003e/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key \\\n    -v \u003chost-dir\u003e/share:/home/foo/share \\\n    -p 2222:22 -d atmoz/sftp \\\n    foo::1001\n```\n\nTip: you can generate your keys with these commands:\n\n```\nssh-keygen -t ed25519 -f ssh_host_ed25519_key \u003c /dev/null\nssh-keygen -t rsa -b 4096 -f ssh_host_rsa_key \u003c /dev/null\n```\n\n## Execute custom scripts or applications\n\nPut your programs in `/etc/sftp.d/` and it will automatically run when the container starts.\nSee next section for an example.\n\n## Bindmount dirs from another location\n\nIf you are using `--volumes-from` or just want to make a custom directory available in user's home directory, you can add a script to `/etc/sftp.d/` that bindmounts after container starts.\n\n```\n#!/bin/bash\n# File mounted as: /etc/sftp.d/bindmount.sh\n# Just an example (make your own)\n\nfunction bindmount() {\n    if [ -d \"$1\" ]; then\n        mkdir -p \"$2\"\n    fi\n    mount --bind $3 \"$1\" \"$2\"\n}\n\n# Remember permissions, you may have to fix them:\n# chown -R :users /data/common\n\nbindmount /data/admin-tools /home/admin/tools\nbindmount /data/common /home/dave/common\nbindmount /data/common /home/peter/common\nbindmount /data/docs /home/peter/docs --read-only\n```\n\n**NOTE:** Using `mount` requires that your container runs with the `CAP_SYS_ADMIN` capability turned on. [See this answer for more information](https://github.com/atmoz/sftp/issues/60#issuecomment-332909232).\n\n# What's the difference between Debian and Alpine?\n\nThe biggest differences are in size and OpenSSH version. [Alpine](https://hub.docker.com/_/alpine/) is 10 times smaller than [Debian](https://hub.docker.com/_/debian/). OpenSSH version can also differ, as it's two different teams maintaining the packages. Debian is generally considered more stable and only bugfixes and security fixes are added after each Debian release (about 2 years). Alpine has a faster release cycle (about 6 months) and therefore newer versions of OpenSSH. As I'm writing this, Debian has version 7.4 while Alpine has version 7.5. Recommended reading: [Comparing Debian vs Alpine for container \u0026 Docker apps](https://www.turnkeylinux.org/blog/alpine-vs-debian)\n\n# What version of OpenSSH do I get?\n\nIt depends on which linux distro and version you choose (see available images at the top). You can see what version you get by checking the distro's packages online. I have provided direct links below for easy access.\n\n- [List of `openssh` packages on Alpine releases](https://pkgs.alpinelinux.org/packages?name=openssh\u0026branch=\u0026repo=main\u0026arch=x86_64)\n- [List of `openssh-server` packages on Debian releases](https://packages.debian.org/search?keywords=openssh-server\u0026searchon=names\u0026exact=1\u0026suite=all\u0026section=main)\n\n# Daily builds\n\nImages are automatically built daily to get the newest version of OpenSSH provided by the package managers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatmoz%2Fsftp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatmoz%2Fsftp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatmoz%2Fsftp/lists"}