Full-featured and highly configurable SFTP, HTTP/S, FTP/S and WebDAV server - S3, Google Cloud Storage, Azure Blob
Find a file
Nicola Murino 4f668bf558 simplify some httpd related code
and update chi, cobra and viper
2020-04-21 19:24:38 +02:00
cmd add profiler support 2020-03-15 15:16:35 +01:00
config add HTTP hooks 2020-04-01 23:25:23 +02:00
dataprovider add support for checking pbkdf2 passwords with base64 encoded salt 2020-04-11 12:25:21 +02:00
docker docker: TAG build arg can be used to build a specific commit too 2020-04-09 11:30:51 +02:00
docs Update performance.md 2020-04-13 21:20:53 +02:00
examples/ldapauth add an example auth program that allow to authenticate against LDAP 2020-04-11 22:30:41 +02:00
fail2ban proxy protocol: added an option to make the proxy header required 2020-02-29 00:02:06 +01:00
httpd simplify some httpd related code 2020-04-21 19:24:38 +02:00
init systemd service: add ExecReload 2020-04-05 11:36:29 +02:00
logger update deps 2020-04-03 22:30:30 +02:00
metrics add support for partial authentication 2020-04-09 23:32:42 +02:00
scripts add support for partial authentication 2020-04-09 23:32:42 +02:00
service add profiler support 2020-03-15 15:16:35 +01:00
sftpd add support for checking pbkdf2 passwords with base64 encoded salt 2020-04-11 12:25:21 +02:00
sql add support for integrated database schema migrations 2020-02-08 14:44:25 +01:00
static dataprovider: add support for user status and expiration 2019-11-13 11:36:21 +01:00
templates s3: upload concurrency is now configurable 2020-03-13 19:13:58 +01:00
utils back to development 2020-03-07 18:06:46 +01:00
vfs added test case that checks quota for files inside virtual folders 2020-03-29 11:10:03 +02:00
.gitignore Update README add section for dataprovider init 2020-01-31 08:56:15 +01:00
.travis.yml Support for HAProxy PROXY protocol 2020-02-27 09:21:30 +01:00
go.mod simplify some httpd related code 2020-04-21 19:24:38 +02:00
go.sum simplify some httpd related code 2020-04-21 19:24:38 +02:00
LICENSE Initial commit 2019-07-20 12:18:32 +02:00
main.go switch to viper for configuration and use cobra for cli 2019-08-07 22:46:52 +02:00
README.md add support for partial authentication 2020-04-09 23:32:42 +02:00
sftpgo.iss back to development 2020-03-07 18:06:46 +01:00
sftpgo.json add HTTP hooks 2020-04-01 23:25:23 +02:00

SFTPGo

Build Status Code Coverage Go Report Card License: GPL v3 Mentioned in Awesome Go

Fully featured and highly configurable SFTP server, written in Go

Features

  • Each account is chrooted to its home directory.
  • SFTP accounts are virtual accounts stored in a "data provider".
  • SQLite, MySQL, PostgreSQL, bbolt (key/value store in pure Go) and in-memory data providers are supported.
  • Public key and password authentication. Multiple public keys per user are supported.
  • Keyboard interactive authentication. You can easily setup a customizable multi-factor authentication.
  • Partial authentication. You can configure multi-step authentication requiring, for example, the user password after successful public key authentication.
  • Per user authentication methods. You can, for example, deny one or more authentication methods to one or more users.
  • Custom authentication via external programs is supported.
  • Dynamic user modification before login via external programs is supported.
  • Quota support: accounts can have individual quota expressed as max total size and/or max number of files.
  • Bandwidth throttling is supported, with distinct settings for upload and download.
  • Per user maximum concurrent sessions.
  • Per user and per directory permission management: list directory contents, upload, overwrite, download, delete, rename, create directories, create symlinks, change owner/group and mode, change access and modification times.
  • Per user files/folders ownership mapping: you can map all the users to the system account that runs SFTPGo (all platforms are supported) or you can run SFTPGo as root user and map each user or group of users to a different system account (*NIX only).
  • Per user IP filters are supported: login can be restricted to specific ranges of IP addresses or to a specific IP address.
  • Per user and per directory file extensions filters are supported: files can be allowed or denied based on their extensions.
  • Virtual folders are supported: directories outside the user home directory can be exposed as virtual folders.
  • Configurable custom commands and/or HTTP notifications on file upload, download, delete, rename, on SSH commands and on user add, update and delete.
  • Automatically terminating idle connections.
  • Atomic uploads are configurable.
  • Support for Git repositories over SSH.
  • SCP and rsync are supported.
  • Support for serving local filesystem, S3 Compatible Object Storage and Google Cloud Storage over SFTP/SCP.
  • Prometheus metrics are exposed.
  • Support for HAProxy PROXY protocol: you can proxy and/or load balance the SFTP/SCP service without losing the information about the client's address.
  • REST API for users management, backup, restore and real time reports of the active connections with possibility of forcibly closing a connection.
  • Web based administration interface to easily manage users and connections.
  • Easy migration from Linux system user accounts.
  • Portable mode: a convenient way to share a single directory on demand.
  • Performance analysis using built-in profiler.
  • Configuration format is at your choice: JSON, TOML, YAML, HCL, envfile are supported.
  • Log files are accurate and they are saved in the easily parsable JSON format (more information).

Platforms

SFTPGo is developed and tested on Linux. After each commit, the code is automatically built and tested on Linux and macOS using Travis CI. The test cases are regularly manually executed and passed on Windows. Other UNIX variants such as *BSD should work too.

Requirements

  • Go 1.13 or higher as build only dependency.
  • A suitable SQL server or key/value store to use as data provider: PostgreSQL 9.4+ or MySQL 5.6+ or SQLite 3.x or bbolt 1.3.x

Installation

Binary releases for Linux, macOS, and Windows are available. Please visit the releases page.

Sample Dockerfiles for Debian and Alpine are available inside the source tree docker directory.

Some Linux distro packages are available:

  • For Arch Linux via AUR:
    • sftpgo. This package follows stable releases. It requires git, gcc and go to build.
    • sftpgo-bin. This package follows stable releases downloading the prebuilt linux binary from GitHub. It does not require git, gcc and go to build.
    • sftpgo-git. This package builds and installs the latest git master. It requires git, gcc and go to build.

Alternately, you can build from source.

Configuration

A full explanation of all configuration methods can be found here.

Please make sure to initialize the data provider before running the daemon!

To start the SFTP server with default settings, simply run:

sftpgo serve

Check out this documentation if you want to run SFTPGo as a service.

Data provider initialization

Before starting the SFTPGo server, please ensure that the configured data provider is properly initialized.

SQL based data providers (SQLite, MySQL, PostgreSQL) require the creation of a database containing the required tables. Memory and bolt data providers do not require an initialization.

After configuring the data provider using the configuration file, you can create the required database structure using the initprovider command. For SQLite provider, the initprovider command will auto create the database file, if missing, and the required tables. For PostgreSQL and MySQL providers, you need to create the configured database, and the initprovider command will create the required tables.

For example, you can simply execute the following command from the configuration directory:

sftpgo initprovider

Take a look at the CLI usage to learn how to specify a different configuration file:

sftpgo initprovider --help

The initprovider command is enough for new installations. From now on, the database structure will be automatically checked and updated, if required, at startup.

Upgrading

If you are upgrading from version 0.9.5 or before, you have to manually execute the SQL scripts to create the required database structure. These scripts can be found inside the source tree sql directory. The SQL scripts filename is, by convention, the date as YYYYMMDD and the suffix .sql. You need to apply all the SQL scripts for your database ordered by name. For example, 20190828.sql must be applied before 20191112.sql, and so on. Example for SQLite: find sql/sqlite/ -type f -iname '*.sql' -print | sort -n | xargs cat | sqlite3 sftpgo.db. After applying these scripts, your database structure is the same as the one obtained using initprovider for new installations, so from now on, you don't have to manually upgrade your database anymore.

Authentication options

External Authentication

Custom authentication methods can easily be added. SFTPGo supports external authentication modules, and writing a new backend can be as simple as a few lines of shell script. More information can be found here.

Keyboard Interactive Authentication

Keyboard interactive authentication is, in general, a series of questions asked by the server with responses provided by the client. This authentication method is typically used for multi-factor authentication.

More information can be found here.

Dynamic user creation or modification

A user can be created or modified by an external program just before the login. More information about this can be found here.

Custom Actions

SFTPGo allows you to configure custom commands and/or HTTP notifications on file upload, download, delete, rename, on SSH commands and on user add, update and delete.

More information about custom actions can be found here.

Storage backends

S3 Compabible Object Storage backends

Each user can be mapped to whole bucket or to a bucket virtual folder. This way, the mapped bucket/virtual folder is exposed over SFTP/SCP. More information about S3 integration can be found here.

Google Cloud Storage backend

Each user can be mapped with a Google Cloud Storage bucket or a bucket virtual folder. This way, the mapped bucket/virtual folder is exposed over SFTP/SCP. More information about Google Cloud Storage integration can be found here.

Other Storage backends

Adding new storage backends is quite easy:

  • implement the Fs interface.
  • update the user method GetFilesystem to return the new backend
  • update the web interface and the REST API CLI
  • add the flags for the new storage backed to the portable mode

Anyway, some backends require a pay per use account (or they offer free account for a limited time period only). To be able to add support for such backends or to review pull requests, please provide a test account. The test account must be available for enough time to be able to maintain the backend and do basic tests before each new release.

Brute force protection

The connection failed logs can be used for integration in tools such as Fail2ban. Example of jails and filters working with systemd/journald are available in fail2ban directory.

Account's configuration properties

Details information about account configuration properties can be found here.

Performance

SFTPGo can easily saturate a Gigabit connection on low end hardware with no special configuration, this is generally enough for most use cases.

More in-depth analysis of performance can be found here.

Acknowledgements

Some code was initially taken from Pterodactyl sftp server

License

GNU GPLv3