Skip to content

A Docker-based SFTP server using the atmoz/sftp image for secure file transfer with multiple user accounts.

Notifications You must be signed in to change notification settings

makevoid/docker-sftp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-sftp-server

A Docker-based SFTP server using the atmoz/sftp image for secure file transfer with multiple user accounts.

Note: This is a small project originally created in 2020 and open-sourced in 2025. It's a simple, practical example of setting up an SFTP server with Docker that others might find useful.

Features

  • Multiple user account support with auto-generated secure passwords
  • Persistent data storage using Docker volumes
  • Easy user management via Ruby script
  • Production-ready configuration

Setup

Prerequisites

  • Docker and Docker Compose installed
  • Ruby installed (for user generation)

Generate Users

Generate user accounts and credentials:

ruby gen_users.rb

This creates:

  • users.conf - User configuration file (username:password:uid:gid:data format)
  • users.csv - CSV file with usernames and passwords for distribution

By default, 3 users are created (user0001, user0002, user0003). Modify the USERS constant in gen_users.rb to change this.

Local Development

docker compose build
docker compose up -d

The SFTP server will be available on port 22.

Production Deployment

  1. Provision a VM
  2. Install Docker and Docker Compose
  3. Generate users via ruby gen_users.rb
  4. Copy docker-compose.yml and users.conf to the VM
  5. Open port 2222 on the firewall
  6. Change the SSH port from 22 to 2222:
    • Edit Port in /etc/ssh/sshd_config
    • Restart SSH service: service sshd restart
  7. Start the SFTP server: docker-compose up -d

Production Security

  • Restrict port 2222 access to specific DevOps IPs only (e.g., via VPN)
  • Users are created with unique UIDs starting at 1001
  • Passwords are generated using SecureRandom (20 characters)

User Management

User home directories are stored in the sftp_data Docker volume and persist across container restarts.

To add more users:

  1. Modify the USERS constant in gen_users.rb
  2. Run ruby gen_users.rb
  3. Restart the container: docker compose restart

About

A Docker-based SFTP server using the atmoz/sftp image for secure file transfer with multiple user accounts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages