Full-featured and highly configurable SFTP, HTTP/S, FTP/S and WebDAV server - S3, Google Cloud Storage, Azure Blob
Find a file
Nicola Murino 4a6a4ce28d
sftpfs: map path resolution error to permission denied
we do the same for os fs so that the problematic directory is excluded
from the webdav listing instead of failing the whole directory listing
2021-10-16 10:32:18 +02:00
.github rework user and admin profiles 2021-09-29 18:46:15 +02:00
cmd refactor custom actions 2021-10-10 13:08:05 +02:00
common pkgs: update nfpm to 2.7 and use xz as compression for both deb and rpm 2021-10-13 09:15:04 +02:00
config refactor custom actions 2021-10-10 13:08:05 +02:00
dataprovider refactor custom actions 2021-10-10 13:08:05 +02:00
docker Docker: remove rsync from default images 2021-09-27 11:34:11 +02:00
docs sftpfs: map path resolution error to permission denied 2021-10-16 10:32:18 +02:00
examples Flesh out examples/ldapauth, specifically: 2021-10-01 09:10:13 +02:00
fail2ban proxy protocol: added an option to make the proxy header required 2020-02-29 00:02:06 +01:00
ftpd refactor custom actions 2021-10-10 13:08:05 +02:00
httpclient minor fixes and doc improvements 2021-09-18 10:50:17 +02:00
httpd pkgs: update nfpm to 2.7 and use xz as compression for both deb and rpm 2021-10-13 09:15:04 +02:00
httpdtest Added email field for user account 2021-09-25 19:06:13 +02:00
init systemd unit: set LimitNOFILE to 8192 2021-09-19 17:37:18 +02:00
kms KMS: allow to provide the master encryption key as string 2021-07-17 15:34:48 +02:00
logger minor fixes and doc improvements 2021-09-18 10:50:17 +02:00
metric dataprovider: add timestamp fields for users and admins 2021-08-19 15:51:43 +02:00
mfa add basic REST APIs for data retention 2021-09-25 12:20:31 +02:00
pkgs sftpfs: map path resolution error to permission denied 2021-10-16 10:32:18 +02:00
sdk refactor custom actions 2021-10-10 13:08:05 +02:00
service refactor custom actions 2021-10-10 13:08:05 +02:00
sftpd refactor custom actions 2021-10-10 13:08:05 +02:00
smtp data retention: allow to notify results via e-mail 2021-10-02 22:25:41 +02:00
static web client UI: allow to edit plain text files 2021-10-09 14:17:28 +02:00
telemetry add experimental plugin system 2021-07-11 15:26:51 +02:00
templates web client UI: allow to edit plain text files 2021-10-09 14:17:28 +02:00
util rate limiting: allow to exclude IP addresses/ranges 2021-10-03 20:50:05 +02:00
version fix a possible nil pointer dereference 2021-09-11 14:19:17 +02:00
vfs sftpfs: map path resolution error to permission denied 2021-10-16 10:32:18 +02:00
webdavd refactor custom actions 2021-10-10 13:08:05 +02:00
windows-installer add a basic front-end web interface for end-users 2021-05-06 21:35:43 +02:00
.gitignore Update README add section for dataprovider init 2020-01-31 08:56:15 +01:00
.golangci.yml actions: add pre-download and pre-upload 2021-05-26 07:48:37 +02:00
Dockerfile data retention: allow to notify results via e-mail 2021-10-02 22:25:41 +02:00
Dockerfile.alpine data retention: allow to notify results via e-mail 2021-10-02 22:25:41 +02:00
Dockerfile.distroless data retention: allow to notify results via e-mail 2021-10-02 22:25:41 +02:00
go.mod sftpfs: map path resolution error to permission denied 2021-10-16 10:32:18 +02:00
go.sum sftpfs: map path resolution error to permission denied 2021-10-16 10:32:18 +02:00
LICENSE change license to AGPL-3 2021-02-26 19:47:48 +01:00
main.go move cloud KMS providers to an external plugin 2021-07-17 13:08:05 +02:00
README.md add basic REST APIs for data retention 2021-09-25 12:20:31 +02:00
SECURITY.md back to development 2020-10-11 09:29:17 +02:00
sftpgo.json refactor custom actions 2021-10-10 13:08:05 +02:00

SFTPGo

CI Status Code Coverage License: AGPL v3 Docker Pulls Mentioned in Awesome Go

Fully featured and highly configurable SFTP server with optional FTP/S and WebDAV support, written in Go. Several storage backends are supported: local filesystem, encrypted local filesystem, S3 (compatible) Object Storage, Google Cloud Storage, Azure Blob Storage, SFTP.

Features

  • Support for serving local filesystem, encrypted local filesystem, S3 Compatible Object Storage, Google Cloud Storage, Azure Blob Storage or other SFTP accounts over SFTP/SCP/FTP/WebDAV.
  • Virtual folders are supported: a virtual folder can use any of the supported storage backends. So you can have, for example, an S3 user that exposes a GCS bucket (or part of it) on a specified path and an encrypted local filesystem on another one. Virtual folders can be private or shared among multiple users, for shared virtual folders you can define different quota limits for each user.
  • Configurable custom commands and/or HTTP hooks on file upload, pre-upload, download, pre-download, delete, pre-delete, rename, mmkdir, rmdir on SSH commands and on user add, update and delete.
  • Virtual accounts stored within a "data provider".
  • SQLite, MySQL, PostgreSQL, CockroachDB, Bolt (key/value store in pure Go) and in-memory data providers are supported.
  • Chroot isolation for local accounts. Cloud-based accounts can be restricted to a certain base path.
  • Per user and per directory virtual permissions, for each exposed path you can allow or deny: directory listing, upload, overwrite, download, delete, rename, create directories, create symlinks, change owner/group/file mode.
  • REST API for users and folders management, data retention, 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, folders and connections.
  • Web client interface so that end users can change their credentials and browse their files.
  • Public key and password authentication. Multiple public keys per user are supported.
  • SSH user certificate authentication.
  • 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.
  • Two-factor authentication based on time-based one time passwords (RFC 6238) which works with Authy, Google Authenticator and other compatible apps.
  • Custom authentication via external programs/HTTP API.
  • Data At Rest Encryption.
  • Dynamic user modification before login via external programs/HTTP API.
  • Quota support: accounts can have individual quota expressed as max total size and/or max number of files.
  • Bandwidth throttling, with distinct settings for upload and download.
  • Per-protocol rate limiting is supported and can be optionally connected to the built-in defender to automatically block hosts that repeatedly exceed the configured limit.
  • Per user maximum concurrent sessions.
  • Per user and global IP filters: login can be restricted to specific ranges of IP addresses or to a specific IP address.
  • Per user and per directory shell like patterns filters: files can be allowed or denied based on shell like patterns.
  • Automatically terminating idle connections.
  • Automatic blocklist management using the built-in defender.
  • Atomic uploads are configurable.
  • 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).
  • Support for Git repositories over SSH.
  • SCP and rsync are supported.
  • FTP/S is supported. You can configure the FTP service to require TLS for both control and data connections.
  • WebDAV is supported.
  • Two-Way TLS authentication, aka TLS with client certificate authentication, is supported for REST API/Web Admin, FTPS and WebDAV over HTTPS.
  • Per user protocols restrictions. You can configure the allowed protocols (SSH/FTP/WebDAV) for each user.
  • Prometheus metrics are exposed.
  • Support for HAProxy PROXY protocol: you can proxy and/or load balance the SFTP/SCP/FTP/WebDAV service without losing the information about the client's address.
  • Easy migration from Linux system user accounts.
  • Portable mode: a convenient way to share a single directory on demand.
  • SFTP subsystem mode: you can use SFTPGo as OpenSSH's SFTP subsystem.
  • 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).
  • SFTPGo supports a plugin system and therefore can be extended using external plugins.

Platforms

SFTPGo is developed and tested on Linux. After each commit, the code is automatically built and tested on Linux, macOS and Windows using a GitHub Action. The test cases are regularly manually executed and passed on FreeBSD. Other *BSD variants should work too.

Requirements

  • Go as build only dependency. We support the Go version(s) used in continuous integration workflows.
  • A suitable SQL server to use as data provider: PostgreSQL 9.4+ or MySQL 5.6+ or SQLite 3.x or CockroachDB stable.
  • The SQL server is optional: you can choose to use an embedded bolt database as key/value store or an in memory data provider.

Installation

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

An official Docker image is available. Documentation is here.

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 main branch. It requires git, gcc and go to build.
  • Deb and RPM packages are built after each commit and for each release.
  • For Ubuntu a PPA is available here.

SFTPGo is also available on AWS Marketplace, purchasing from there will help keep SFTPGo a long-term sustainable project.

On FreeBSD you can install from the SFTPGo port.

On Windows you can use:

  • The Windows installer to install and run SFTPGo as a Windows service.
  • The portable package to start SFTPGo on demand.

You can easily test new features selecting a commit from the Actions page and downloading the matching build artifacts for Linux, macOS or Windows. GitHub stores artifacts for 90 days.

Alternately, you can build from source.

Getting Started Guide for the Impatient.

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 SFTPGo with the default settings, simply run:

sftpgo serve

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

Data provider initialization and management

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

For PostgreSQL, MySQL and CockroachDB providers, you need to create the configured database. For SQLite, the configured database will be automatically created at startup. Memory and bolt data providers do not require an initialization but they could require an update to the existing data after upgrading SFTPGo.

SFTPGo will attempt to automatically detect if the data provider is initialized/updated and if not, will attempt to initialize/ update it on startup as needed.

Alternately, you can create/update the required data provider structures yourself using the initprovider command.

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

You can disable automatic data provider checks/updates at startup by setting the update_mode configuration key to 1.

Create the first admin

To start using SFTPGo you need to create an admin user, you can do it in several ways:

  • by using the web admin interface. The default URL is http://127.0.0.1:8080/web/admin
  • by loading initial data
  • by enabling create_default_admin in your configuration file. In this case the credentials are admin/password

Upgrading

SFTPGo supports upgrading from the previous release branch to the current one. Some examples for supported upgrade paths are:

  • from 1.2.x to 2.0.x
  • from 2.0.x to 2.1.x and so on.

For supported upgrade paths, the data and schema are migrated automatically, alternately you can use the initprovider command.

So if, for example, you want to upgrade from a version before 1.2.x to 2.0.x, you must first install version 1.2.x, update the data provider and finally install the version 2.0.x. It is recommended to always install the latest available minor version, ie do not install 1.2.0 if 1.2.2 is available.

Loading data from a provider independent JSON dump is supported from the previous release branch to the current one too. After upgrading SFTPGo it is advisable to regenerate the JSON dump from the new version.

Downgrading

If for some reason you want to downgrade SFTPGo, you may need to downgrade your data provider schema and data as well. You can use the revertprovider command for this task.

As for upgrading, SFTPGo supports downgrading from the previous release branch to the current one.

So, if you plan to downgrade from 2.0.x to 1.2.x, before uninstalling 2.0.x version, you can prepare your data provider executing the following command from the configuration directory:

sftpgo revertprovider --to-version 4

Take a look at the CLI usage to see the supported parameter for the --to-version argument and to learn how to specify a different configuration file:

sftpgo revertprovider --help

The revertprovider command is not supported for the memory provider.

Please note that we only support the current release branch and the current main branch, if you find a bug it is better to report it rather than downgrading to an older unsupported version.

Users and folders management

After starting SFTPGo you can manage users and folders using:

To support embedded data providers like bolt and SQLite we can't have a CLI that directly write users and folders to the data provider, we always have to use the REST API.

Full details for users, folders, admins and other resources are documented in the OpenAPI schema. If you want to render the schema without importing it manually, you can explore it on Stoplight.

Tutorials

Some step-to-step tutorials can be found inside the source tree howto directory.

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 hooks to receive notifications about file uploads, deletions and several other events.

More information about custom actions can be found here.

Virtual folders

Directories outside the user home directory or based on a different storage provider can be exposed as virtual folders, more information here.

Other hooks

You can get notified as soon as a new connection is established using the Post-connect hook and after each login using the Post-login hook. You can use your own hook to check passwords.

Storage backends

S3 Compatible Object Storage backends

Each user can be mapped to the whole bucket or to a bucket virtual folder. This way, the mapped bucket/virtual folder is exposed over SFTP/SCP/FTP/WebDAV. 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/FTP/WebDAV. More information about Google Cloud Storage integration can be found here.

Azure Blob Storage backend

Each user can be mapped with an Azure Blob Storage container or a container virtual folder. This way, the mapped container/virtual folder is exposed over SFTP/SCP/FTP/WebDAV. More information about Azure Blob Storage integration can be found here.

SFTP backend

Each user can be mapped to another SFTP server account or a subfolder of it. More information can be found here.

Encrypted backend

Data at-rest encryption is supported via the cryptfs backend.

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.

You can also use the built-in defender.

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.

Release Cadence

SFTPGo releases are feature-driven, we don't have a fixed time based schedule. As a rough estimate, you can expect 1 or 2 new releases per year.

Acknowledgements

SFTPGo makes use of the third party libraries listed inside go.mod.

We are very grateful to all the people who contributed with ideas and/or pull requests.

Thank you ysura for granting me stable access to a test AWS S3 account.

Sponsors

I'd like to make SFTPGo into a sustainable long term project and your sponsorship will really help ❤️

Thank you to our sponsors!

License

GNU AGPLv3