emberstack/sftp

By emberstack

Updated about 2 years ago

SFTP (SSH File Transfer Protocol) server using OpenSSH

Image
24

10M+

emberstack/sftp repository overview

SFTP (SSH File Transfer Protocol) server using OpenSSH

This project provides a Docker image for hosting a SFTP server. Included are Docker (docker-cli and docker-compose) and Kubernetes (kubectl and helm) deployment scripts

Build Status Release Docker Image Docker Pulls license slack

Supports architectures: amd64, arm and arm64

Support

If you need help or found a bug, please feel free to open an issue on the emberstack/docker-sftp GitHub project.

You can also join our Slack workspace and talk to us:
slack

Usage

The SFTP server can be easily deployed to any platform that can host containers based on Docker. Below are deployment methods for:

  • Docker CLI
  • Docker-Compose
  • Kubernetes using Helm (recommended for Kubernetes)

Process:

  1. Create server configuration
  2. Mount volumes as needed
  3. Set host file for consistent server fingerprint
Configuration

The SFTP server uses a json based configuration file for default server options and to define users. This file has to be mounted on /app/config/sftp.json inside the container. Environment variable based configuration is not supported (see the Advanced Configuration section below for the reasons).

Below is the simplest configuration file for the SFTP server:

{
    "Global": {
        "Chroot": {
            "Directory": "%h",
            "StartPath": "sftp"
        },
        "Directories": ["sftp"]
    },
    "Users": [
        {
            "Username": "demo",
            "Password": "demo"
        }
    ]
}

This configuration creates a user demo with the password demo. A directory "sftp" is created for each user in the own home and is accessible for read/write. The user is chrooted to the /home/demo directory. Upon connect, the start directory is sftp.

You can add additional users, default directories or customize start directories per user. You can also define the UID and GID for each user. See the Advanced Configuration section below for all configuration options.

Deployment using Docker CLI

Simple Docker CLI run

$ docker run -p 22:22 -d emberstack/sftp --name sftp

This will start a SFTP in the container sftp with the default configuration. You can connect to it and login with the user: demo and password: demo.

Provide your configuration

$ docker run -p 22:22 -d emberstack/sftp --name sftp -v /host/sftp.json:/app/config/sftp.json:ro

This will override the default (/app/config/sftp.json) configuration with the one from the host /host/sftp.json.

Mount a directory from the host for the user 'demo'

$ docker run -p 22:22 -d emberstack/sftp --name sftp -v /host/sftp.json:/app/config/sftp.json:ro -v /host/demo:/home/demo/sftp

This will mount the demo directory from the host on the sftp directory for the "demo" user.

Deployment using Docker Compose

Simple docker-compose configuration

Create a docker-compose configuration file:

version: '3'
services:
  sftp:
    image: "emberstack/sftp"
    ports:
      - "22:22"
    volumes:
      - ../config-samples/sample.sftp.json:/app/config/sftp.json:ro

And run it using docker-compose

$ docker-compose -p sftp -f docker-compose.yaml up -d

The above configuration is available in the deploy\docker-compose folder in this repository. You can use it to start customizing the deployment for your environment.

Deployment to Kubernetes using Helm

Use Helm to install the latest released chart:

$ helm repo add emberstack https://emberstack.github.io/helm-charts
$ helm repo update
$ helm upgrade --install sftp emberstack/sftp

You can customize the values of the helm deployment by using the following Values:

ParameterDescriptionDefault
nameOverrideOverrides release name""
fullnameOverrideOverrides release fullname""
image.repositoryContainer image repositoryemberstack/sftp
image.tagContainer image taglatest
image.pullPolicyContainer image pull policyAlways if image.tag is latest, else IfNotPresent
storage.volumesDefines additional volumes for the pod{}
storage.volumeMountsDefines additional volumes mounts for the sftp container{}
configurationAllows the in-line override of the configuration valuesnull
configuration.Global.Chroot.DirectoryGlobal chroot directory for the sftp user group. Can be overriden per-user"%h"
configuration.Global.Chroot.StartPathStart path for the sftp user group. Can be overriden per-user"sftp"
configuration.Global.DirectoriesDirectories that get created for all sftp users. Can be appended per user["sftp"]
configuration.Global.HostKeys.Ed25519Set the server's ED25519 private key""
configuration.Global.HostKeys.RsaSet the server's RSA private key""
configuration.UsersArray of users and their propertiesContains demo user by default
configuration.Users[].UsernameSet the user's usernameN/A
configuration.Users[].PasswordSet the user's password. If empty or null, password authentication is disabledN/A
configuration.Users[].PasswordIsEncryptedtrue or false. Indicates if the password value is already encryptedfalse
configuration.Users[].AllowedHostsSet the user's allowed hosts. If empty, any host is allowed[]
configuration.Users[].PublicKeysSet the user's public keys[]
configuration.Users[].UIDSets the user's UID.null
configuration.Users[].GIDSets the user's GID. A group is created for this value and the user is includednull
configuration.Users[].ChrootIf set, will override global Chroot settings for this user.null
configuration.Users[].DirectoriesArray of additional directories created for this usernull
initContainersAdditional initContainers for the pod{}
resourcesResource limits{}
nodeSelectorNode labels for pod assignment{}
tolerationsToleration labels for pod assignment[]
affinityNode affinity for pod assignment{}

Find us on Helm Hub

Advanced Configuration

TODO: This section is under development due to the number of configuration options being added. Please open an issue on the emberstack/docker-sftp project if you need help.

Tag summary

Content type

Image

Digest

sha256:9ac1eada3

Size

127.3 MB

Last updated

about 2 years ago

docker pull emberstack/sftp:build-5.1.72