Add TLS Support

This commit is contained in:
Amin Vakil 2020-02-06 00:46:40 +03:30
parent d7d630b527
commit d805748b9f
No known key found for this signature in database
GPG Key ID: 1EFC1864E9D9E56B
5 changed files with 90 additions and 27 deletions

View File

@ -1,12 +1,13 @@
FROM alpine:3.13
LABEL maintainer="Amin Vakil <info@aminvakil.com>"
RUN apk --no-cache add vsftpd
COPY start_vsftpd.sh /bin/start_vsftpd.sh
COPY vsftpd.pem /etc/ssl/certs/vsftpd.pem
COPY start_vsftpd.sh /usr/local/bin/start_vsftpd.sh
COPY vsftpd.conf /etc/vsftpd/vsftpd.conf
EXPOSE 21 21000-21010
VOLUME /ftp/ftp
STOPSIGNAL SIGKILL
ENTRYPOINT ["/bin/start_vsftpd.sh"]
ENTRYPOINT ["/usr/local/bin/start_vsftpd.sh"]

View File

@ -1,5 +1,4 @@
# docker-alpine-ftp-server
[![Docker Stars](https://img.shields.io/docker/stars/delfer/alpine-ftp-server.svg)](https://hub.docker.com/r/delfer/alpine-ftp-server/) [![Docker Pulls](https://img.shields.io/docker/pulls/delfer/alpine-ftp-server.svg)](https://hub.docker.com/r/delfer/alpine-ftp-server/) [![Docker Automated build](https://img.shields.io/docker/automated/delfer/alpine-ftp-server.svg)](https://hub.docker.com/r/delfer/alpine-ftp-server/) [![Docker Build Status](https://img.shields.io/docker/build/delfer/alpine-ftp-server.svg)](https://hub.docker.com/r/delfer/alpine-ftp-server/) [![MicroBadger Layers](https://img.shields.io/microbadger/layers/delfer/alpine-ftp-server.svg)](https://hub.docker.com/r/delfer/alpine-ftp-server/) [![MicroBadger Size](https://img.shields.io/microbadger/image-size/delfer/alpine-ftp-server.svg)](https://hub.docker.com/r/delfer/alpine-ftp-server/)
Small and flexible docker image with vsftpd server
## Usage
@ -26,3 +25,6 @@ Environment variables:
- `user|password foo|bar|/home/foo`
- `user|password|/home/user/dir|10000`
- `user|password||10000`
=======
# docker-alpine-ftp-server-tls
Small and flexible docker image with vsftpd server with tls

View File

@ -1,7 +1,7 @@
#!/bin/sh
set +x
#Remove all ftp users
grep '/ftp/' /etc/passwd | cut -d':' -f1 | xargs -n1 deluser
#grep '/ftp/' /etc/passwd | cut -d':' -f1 | xargs -n1 deluser
#Create users
#USERS='name1|password1|[folder1][|uid1] name2|password2|[folder2][|uid2]'
@ -15,7 +15,7 @@ grep '/ftp/' /etc/passwd | cut -d':' -f1 | xargs -n1 deluser
#Default user 'ftp' with password 'alpineftp'
if [ -z "$USERS" ]; then
USERS="ftp|alpineftp"
USERS="amin|alpineftp"
fi
for i in $USERS ; do
@ -55,6 +55,5 @@ fi
if [ ! -z "$1" ]; then
exec "$@"
else
exec /usr/sbin/vsftpd -opasv_min_port=$MIN_PORT -opasv_max_port=$MAX_PORT $ADDR_OPT /etc/vsftpd/vsftpd.conf
exec /usr/sbin/vsftpd -opasv_min_port=$MIN_PORT -opasv_max_port=$MAX_PORT $ADDR_OPT /etc/vsftpd/vsftpd.conf & sleep infinity
fi

View File

@ -1,5 +1,5 @@
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
@ -9,11 +9,7 @@ write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#local_umask=022
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
@ -21,15 +17,9 @@ xferlog_enable=YES
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/dev/stdout
#xferlog_file=/var/log/vsftpd.log
vsftpd_log_file=/proc/1/fd/1
#
# If you want, you can have your log file in standard ftpd xferlog format.
@ -42,6 +32,10 @@ vsftpd_log_file=/proc/1/fd/1
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
@ -60,7 +54,7 @@ vsftpd_log_file=/proc/1/fd/1
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=Welcome Alpine ftp server https://hub.docker.com/r/delfer/alpine-ftp-server/
ftpd_banner=Welcome Alpine ftp server tls https://quay.io/aminvakil/alpine-ftp-server-tls
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
@ -79,17 +73,34 @@ ftpd_banner=Welcome Alpine ftp server https://hub.docker.com/r/delfer/alpine-ftp
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
## Enable passive mode
# Enable passive mode
pasv_enable=YES
pasv_addr_resolve=YES
#
## Disable seccomp filter sanboxing
# Disable seccomp filter sanboxing
seccomp_sandbox=NO
#
# Run in background
background=NO
ssl_enable=YES
# by default all non anonymous logins and forced to use SSL to send and receive password and data, set to NO to allow non secure connections
force_local_logins_ssl=YES
force_local_data_ssl=YES
# provide the path of your certificate and of your private key
# note that both can be contained in the same file or in different files
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
rsa_private_key_file=/etc/ssl/certs/vsftpd.pem
# this setting is set to YES by default and requires all data connections exhibit session reuse which proves they know the secret of the control channel.
# this is more secure but is not supported by many FTP clients, set to NO for better compatibility
require_ssl_reuse=YES
ssl_ciphers=HIGH

50
vsftpd.pem Normal file
View File

@ -0,0 +1,50 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD1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