Full-featured and highly configurable SFTP, HTTP/S, FTP/S and WebDAV server - S3, Google Cloud Storage, Azure Blob https://sftpgo.com/
|
|
6 anni fa | |
|---|---|---|
| api | 6 anni fa | |
| config | 6 anni fa | |
| dataprovider | 6 anni fa | |
| init | 6 anni fa | |
| logger | 6 anni fa | |
| sftpd | 6 anni fa | |
| sql | 6 anni fa | |
| utils | 6 anni fa | |
| .travis.yml | 6 anni fa | |
| LICENSE | 6 anni fa | |
| README.md | 6 anni fa | |
| go.mod | 6 anni fa | |
| go.sum | 6 anni fa | |
| main.go | 6 anni fa | |
| sftpgo.conf | 6 anni fa |
Full featured and highly configurable SFTP server software
Provider interface could be extended to support non SQL backends tooSFTPGo is developed and tested on Linux. After each commit the code is automatically built and tested on Linux and macOS using Travis CI. Regularly the test cases are manually executed and pass on Windows. Other UNIX variants such as *BSD should work too.
Simple install the package to your $GOPATH with the go tool from shell:
$ go get -u github.com/drakkan/sftpgo
Make sure Git is installed on your machine and in your system's PATH.
A systemd sample service can be found inside the source tree.
Alternately you can use distro packages:
The sftpgo executable supports the following command line flags:
-config-dir string. Location of the config dir. This directory should contain the sftpgo.conf configuration file, the private key for the SFTP server (id_rsa file) and the SQLite database if you use SQLite as data provider. The server private key will be autogenerated if the user that executes SFTPGo has write access to the config-dir. The default value is "."-log-file-path string. Location for the log file, default "sftpgo.log"-log-max-size int. Maximum size in megabytes of the log file before it gets rotated. Default 10-log-max-backups int. Maximum number of old log files to retain. Default 5-log-max-age int. Maximum number of days to retain old log files. Default 28-log-compress boolean. Determine if the rotated log files should be compressed using gzip-log-verbose boolean. Enable verbose logs. Default trueBefore starting sftpgo a dataprovider must be configured.
Sample SQL scripts to create the required database structure can be found insite the source tree sql directory. The SQL scripts filename's 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 20190706.sql must be applied before 20190728.sql and so on.
The sftpgo.conf configuration file contains the following sections:
bind_port, integer. The port used for serving SFTP requests. Default: 2022bind_address, string. Leave blank to listen on all available network interfaces. Default: ""idle_timeout, integer. Time in minutes after which an idle client will be disconnected. Default: 15max_auth_tries integer. Maximum number of authentication attempts permitted per connection. If set to a negative number, the number of attempts are unlimited. If set to zero, the number of attempts are limited to 6.umask, string. Umask for the new files and directories. This setting has no effect on Windows. Default: "0022"banner, string. Identification string used by the server. Default "SFTPGo"actions, struct. It contains the command to execute and/or the HTTP URL to notify and the trigger conditions
execute_on, list of strings. Valid values are download, upload, delete, rename. On folder deletion a delete notification will be sent for each deleted file. Leave empty to disable actions.command, string. Absolute path to the command to execute. Leave empty to disable. The command is invoked with the following arguments:
action, any valid execute_on stringusername, user who did the actionpath to the affected file. For rename action this is the old file nametarget_path, non empty for rename action, this is the new file namehttp_notification_url, a valid URL. An HTTP GET request will be executed to this URL. Leave empty to disable. The query string will contain the following parameters that have the same meaning of the command's arguments:
actionusernamepathtarget_path, added for rename action onlydriver, string. Supported drivers are sqlite, mysql, postgresqlname, string. Database namehost, string. Database host. Leave empty for driver sqliteport, integer. Database port. Leave empty for driver sqliteusername, string. Database user. Leave empty for driver sqlitepassword, string. Database password. Leave empty for driver sqlitesslmode, integer. Used for drivers mysql and postgresql. 0 disable SSL/TLS connections, 1 require ssl, 2 set ssl mode to verify-ca for driver postgresql and skip-verify for driver mysql, 3 set ssl mode to verify-full for driver postgresql and preferred for driver mysqlconnectionstring, string. Provide a custom database connection string. If not empty this connection string will be used instead of build one using the previous parametersusers_table, string. Database table for SFTP usersmanage_users, integer. Set to 0 to disable users management, 1 to enabletrack_quota, integer. Set the preferred way to track users quota between the following choices:
bind_port, integer. The port used for serving HTTP requests. Set to 0 to disable HTTP server. Default: 8080bind_address, string. Leave blank to listen on all available network interfaces. Default: "127.0.0.1"Here is a full example showing the default config:
{
"sftpd":{
"bind_port":2022,
"bind_address":"",
"idle_timeout":15,
"max_auth_tries":0,
"umask":"0022",
"banner":"SFTPGo",
"actions":{
"execute_on":[],
"command":"",
"http_notification_url":""
}
},
"data_provider":{
"driver":"sqlite",
"name":"sftpgo.db",
"host":"",
"port":5432,
"username":"",
"password":"",
"sslmode":0,
"connection_string":"",
"users_table":"users",
"manage_users":1,
"track_quota":1
},
"httpd":{
"bind_port":8080,
"bind_address":"127.0.0.1"
}
}
For each account the following properties can be configured:
usernamepassword used for password authentication. For users created using SFTPGo REST API the password will be stored using argon2id hashing algo. SFTPGo supports checking passwords stored with bcrypt too. Currently, as fallback, there is a clear text password checking but you should not store passwords as clear text and this support could be removed at any time, so please don't depend on it.public_key used for public key authentication. At least one between password and public key is mandatoryhome_dir The user cannot upload or download files outside this directory. Must be an absolute pathuid, gid. If sftpgo runs as root system user then the created files and directories will be assigned to this system uid/gid. Ignored on windows and if sftpgo runs as non root user: in this case files and directories for all SFTP users will be owned by the system user that runs sftpgo.max_sessions maximum concurrent sessions. 0 means unlimitedquota_size maximum size allowed as bytes. 0 means unlimitedquota_files maximum number of files allowed. 0 means unlimitedpermissions the following permissions are supported:
* all permission are grantedlist list items is alloweddownload download files is allowedupload upload files is alloweddelete delete files or directories is allowedrename rename files or directories is allowedcreate_dirs create directories is allowedcreate_symlinks create symbolic links is allowedupload_bandwidth maximum upload bandwidth as KB/s, 0 means unlimiteddownload_bandwidth maximum download bandwidth as KB/s, 0 means unlimitedThese properties are stored inside the data provider. If you want to use your existing accounts, you can create a database view. Since a view is read only, you have to disable user management and quota tracking so sftpgo will never try to write to the view.
SFTPGo exposes REST API to manage users and quota and to get real time reports for the active connections with possibility of forcibly closing a connection.
If quota tracking is enabled in sftpgo.conf configuration file, then the used size and number of files are updated each time a file is added/removed. If files are added/removed not using SFTP or if you change track_quota from 2 to 1, you can rescan the user home dir and update the used quota using the REST API.
REST API is designed to run on localhost or on a trusted network, if you need https or authentication you can setup a reverse proxy using an HTTP Server such as Apache or NGNIX.
The OpenAPI 3 schema for the exposed API can be found inside the source tree: openapi.yaml.
Inside the log file each line is a JSON struct, each struct has a sender fields that identify the log type.
The logs can be divided into the following categories:
sftpgo:
sender string. This is generally the package name that emits the logtime string. Date/time with millisecond precisionlevel stringmessage stringsender string. SFTPUpload or SFTPDownloadtime string. Date/time with millisecond precisionlevel stringelapsed_ms, int64. Elapsed time, as milliseconds, for the upload/downloadsize_bytes, int64. Size, as bytes, of the download/uploadusername, stringfile_path stringconnection_id string. Unique SFTP connection identifiersender string. SFTPRename, SFTPRmdir, SFTPMkdir, SFTPSymlink, SFTPRemovelevel stringusername, stringfile_path stringtarget_path stringconnection_id string. Unique SFTP connection identifiersender string. httpdlevel stringremote_addr string. IP and port of the remote clientproto string, for example HTTP/1.1method string. HTTP method (GET, POST, PUT, DELETE etc.)user_agent stringuri string. Full uriresp_status integer. HTTP response status coderesp_size integer. Size in bytes of the HTTP responseelapsed_ms int64. Elapsed time, as milliseconds, to complete the requestrequest_id string. Unique request identifier
Some code was initially taken from Pterodactyl sftp server
GNU GPLv3