Golang based autonomous FTP server with AWS S3 and Google Drive integrations
This FTP server is a gateway between old-school FTP devices and modern cloud based file systems, using the afero's Fs interface and acting as a reference implementation of the ftpserverlib.
At the current stage, supported backend are: - Local disk - S3 through afero-s3 - Dropbox (see doc) through afero-dropbox - Google Drive (see doc) through afero-gdrive - SFTP through afero's sftpfs - Email through go-mail thanks to @x-way
These features are brought by ftpserverlib itself:
go get -u github.com/fclairamb/ftpserver
If you don't create a
ftpserver.jsonfile, it will be created for you.
Here is a sample config file:
{ "version": 1, "accesses": [ { "user": "test", "pass": "test", "fs": "os", "params": { "basePath": "/tmp" } }, { "user": "test", "pass": "test", "fs": "os", "params": { "basePath": "/tmp" } }, { "user": "dropbox", "pass": "dropbox", "fs": "dropbox", "params": { "token": "..." } }, { "user": "gdrive", "pass": "gdrive", "fs": "gdrive", "params": { "google_client_id": "***.apps.googleusercontent.com", "google_client_secret": "****" } }, {"user": "s3", "pass": "s3", "fs": "s3", "params": { "endpoint": "https://s3.amazonaws.com", "region": "eu-west-1", "bucket": "my-bucket", "access_key_id": "AKIA....", "secret_access_key": "IDxd....", "disable_ssl": "false", "path_style": "false" } }, { "user": "sftp", "pass": "sftp", "fs": "sftp", "params": { "username": "user", "password": "password", "hostname": "192.168.168.11:22" } }
], "passive_transfer_port_range": { "start": 2122, "end": 2130 } }
You can build the binary and use it directly:
# Get and install the server go get github.com/fclairamb/ftpserverftpserver &
Download some file
[ -f kitty.jpg ] || (curl -o kitty.jpg.tmp https://placekitten.com/2048/2048 && mv kitty.jpg.tmp kitty.jpg)
Upload it to the server
curl -v -T kitty.jpg ftp://test:[email protected]:2121/
Download it back
curl ftp://test:[email protected]:2121/kitty.jpg -o kitty2.jpg
Compare it
diff kitty.jpg kitty2.jpg
There's also a containerized version of the server (15MB, based on alpine).
# Starting the sample FTP server docker run --rm -d -p 2121-2130:2121-2130 fclairamb/ftpserverDownload some file
[ -f kitty.jpg ] || (curl -o kitty.jpg.tmp https://placekitten.com/2048/2048 && mv kitty.jpg.tmp kitty.jpg)
Upload it
curl -v -T kitty.jpg ftp://test:[email protected]:2121/
Download it back
curl ftp://test:[email protected]:2121/kitty.jpg -o kitty2.jpg
Compare it
diff kitty.jpg kitty2.jpg