SftpGo is a high-performance, versatile, easy-to-configure SFTP server service developed based on go. At present, it can run stably under Linux and MacOS (Windows has not been tested). Data can be persisted to mainstream databases such as Mysql, PostgreSQL, and Sqlilte.
Sftpgo main components
- Server side main program: sftpgosever
- Cli script: sftpcli
The data directory
- Conf Storage service configuration file
- Data Creates an SFTP user directory
- Backups Stores application backup data
This time based on K8S running service, mysql5.7 to do persistent storage, Tencent cloud NFS service to do data directory, ConfigMap to mount configuration files, nginx Stream to provide domain name mapping TCP access
Build the mirror
Direct pull
Docker pull taylordang/sftpgo: v1.0Copy the code
Build locally based on Dockerfile
To view specific documents: [https://github.com/dtcka/sftpgo/tree/master/docker/sftpgo/alpine](https://github.com/dtcka/sftpgo/tree/master/docker/sf tpgo/alpine)Copy the code
Scaffolding construction
Build script: [https://github.com/dtcka/sftpgo/blob/master/docker/rest-api-cli/Dockerfile](https://github.com/dtcka/sftpgo/blob/master /docker/rest-api-cli/Dockerfile)Copy the code
Standard profile
{" SFTPD ": {" bind_port:" 2022, "bind_address" : "0.0.0.0", "idle_timeout" : 15, "max_auth_tries" : 0, "umask" : "0022", "banner": "", "upload_mode": 0, "actions": { "execute_on": [], "command": "", "http_notification_url": "" }, "keys": [], "kex_algorithms": [], "ciphers": [], "macs": [], "login_banner_file": "", "setstat_mode": 0, "enabled_ssh_commands": [ "md5sum", "sha1sum", "cd", "pwd", "scp" ], "keyboard_interactive_auth_program": "", "proxy_protocol": 0, "proxy_allowed": [] }, "data_provider": { "driver": "mysql", "name": "sftpgo", "host": "xxxxxx", "port": 9999, "username": "sftpgo", "password": "xxxxx", "sslmode": 0, "connection_string": "", "users_table": "users", "manage_users": 1, "track_quota": 2, "pool_size": 0, "users_base_dir": "", "actions": { "execute_on": [], "command": "", "http_notification_url": "" }, "external_auth_program": "", "external_auth_scope": 0, "credentials_path": "credentials", "pre_login_program": "" }, "httpd": { "bind_port": 8080, "bind_address": "0.0.0.0", "templates_PATH ": "templates"," STATIC_FILES_PATH ": "static", "backupS_PATH ": "backups", "auth_user_file": "", "certificate_file": "", "certificate_key_file": "" } }Copy the code
Run the application
After the above service configuration is ready, the run container automatically generates the corresponding tables in the database
Provide external service warehousing
1. Set the Intranet service entrance
apiVersion: v1
kind: Service
metadata:
name: sftpgo
namespace: sftp
spec:
clusterIP: xxxx
externalTrafficPolicy: Cluster
ports:
- name: 8080-8080-tcp
nodePort: 31807
port: 8080
protocol: TCP
targetPort: 8080
- name: 2022-2022-tcp
nodePort: 30865
port: 2022
protocol: TCP
targetPort: 2022
selector:
k8s-app: sftpgo
qcloud-app: sftpgo
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer:
ingress:
- ip: xxxxCopy the code
2. Set an external service entrance
– nginx configuration file ` ` ` apiVersion: v1 data: nginx. Conf: | – user nginx; worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } stream { server { listen 2022; Proxy_pass Internal IP address of the sftpgo service :2022; } } kind: ConfigMap metadata: name: tcp-config namespace: sftp
##### 3. Test service status and data directory permissions! [image.png](https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/4/19/171903050cf2eddb~tplv-t2oaga2asx-im Age.image) <br /> Test OK: data permission UID GID needs to be set to 1003.<br /> ##### 4. Set domain name resolution to nginx externalIps to enable domain name access! [image.png](https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/4/19/1719030545a4227e~tplv-t2oaga2asx-im Image) -- <br/> <br/>Copy the code
Sftpgo service source: github.com/dtcka/sftpg… Sftpgo container related image: hub.docker.com/repository/… Sftpgo scaffolding: hub.docker.com/repository/…
` ` `
For more, visit blog.dtcka.com