├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── docker-compose.yml ├── docker_139x115.png ├── docker_fauria_161x115.png ├── run-vsftpd.sh ├── vsftpd.conf └── vsftpd_virtual /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | 3 | ARG USER_ID=14 4 | ARG GROUP_ID=50 5 | 6 | MAINTAINER Fer Uria 7 | LABEL Description="vsftpd Docker image based on Centos 7. Supports passive mode and virtual users." \ 8 | License="Apache License 2.0" \ 9 | Usage="docker run -d -p [HOST PORT NUMBER]:21 -v [HOST FTP HOME]:/home/vsftpd fauria/vsftpd" \ 10 | Version="1.0" 11 | 12 | RUN yum -y update && yum clean all 13 | RUN yum install -y \ 14 | vsftpd \ 15 | db4-utils \ 16 | db4 \ 17 | iproute && yum clean all 18 | 19 | RUN usermod -u ${USER_ID} ftp 20 | RUN groupmod -g ${GROUP_ID} ftp 21 | 22 | ENV FTP_USER **String** 23 | ENV FTP_PASS **Random** 24 | ENV PASV_ADDRESS **IPv4** 25 | ENV PASV_ADDR_RESOLVE NO 26 | ENV PASV_ENABLE YES 27 | ENV PASV_MIN_PORT 21100 28 | ENV PASV_MAX_PORT 21110 29 | ENV XFERLOG_STD_FORMAT NO 30 | ENV LOG_STDOUT **Boolean** 31 | ENV FILE_OPEN_MODE 0666 32 | ENV LOCAL_UMASK 077 33 | ENV REVERSE_LOOKUP_ENABLE YES 34 | ENV PASV_PROMISCUOUS NO 35 | ENV PORT_PROMISCUOUS NO 36 | 37 | COPY vsftpd.conf /etc/vsftpd/ 38 | COPY vsftpd_virtual /etc/pam.d/ 39 | COPY run-vsftpd.sh /usr/sbin/ 40 | 41 | RUN chmod +x /usr/sbin/run-vsftpd.sh 42 | RUN mkdir -p /home/vsftpd/ 43 | RUN chown -R ftp:ftp /home/vsftpd/ 44 | 45 | VOLUME /home/vsftpd 46 | VOLUME /var/log/vsftpd 47 | 48 | EXPOSE 20 21 49 | 50 | CMD ["/usr/sbin/run-vsftpd.sh"] 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fauria/vsftpd 2 | 3 | ![docker_logo](https://raw.githubusercontent.com/fauria/docker-vsftpd/master/docker_139x115.png)![docker_fauria_logo](https://raw.githubusercontent.com/fauria/docker-vsftpd/master/docker_fauria_161x115.png) 4 | 5 | [![Docker Pulls](https://img.shields.io/docker/pulls/fauria/vsftpd.svg?style=plastic)](https://hub.docker.com/r/fauria/vsftpd/) 6 | [![Docker Build Status](https://img.shields.io/docker/build/fauria/vsftpd.svg?style=plastic)](https://hub.docker.com/r/fauria/vsftpd/builds/) 7 | [![](https://images.microbadger.com/badges/image/fauria/vsftpd.svg)](https://microbadger.com/images/fauria/vsftpd "fauria/vsftpd") 8 | 9 | This Docker container implements a vsftpd server, with the following features: 10 | 11 | * Centos 7 base image. 12 | * vsftpd 3.0 13 | * Virtual users 14 | * Passive mode 15 | * Logging to a file or `STDOUT`. 16 | 17 | ### Installation from [Docker registry hub](https://registry.hub.docker.com/r/fauria/vsftpd/). 18 | 19 | You can download the image with the following command: 20 | 21 | ```bash 22 | docker pull fauria/vsftpd 23 | ``` 24 | 25 | Environment variables 26 | ---- 27 | 28 | This image uses environment variables to allow the configuration of some parameters at run time: 29 | 30 | * Variable name: `FTP_USER` 31 | * Default value: admin 32 | * Accepted values: Any string. Avoid whitespaces and special chars. 33 | * Description: Username for the default FTP account. If you don't specify it through the `FTP_USER` environment variable at run time, `admin` will be used by default. 34 | 35 | ---- 36 | 37 | * Variable name: `FTP_PASS` 38 | * Default value: Random string. 39 | * Accepted values: Any string. 40 | * Description: If you don't specify a password for the default FTP account through `FTP_PASS`, a 16 character random string will be automatically generated. You can obtain this value through the [container logs](https://docs.docker.com/engine/reference/commandline/container_logs/). 41 | 42 | ---- 43 | 44 | * Variable name: `PASV_ADDRESS` 45 | * Default value: Docker host IP / Hostname. 46 | * Accepted values: Any IPv4 address or Hostname (see PASV_ADDRESS_RESOLVE). 47 | * Description: If you don't specify an IP address to be used in passive mode, the routed IP address of the Docker host will be used. Bear in mind that this could be a local address. 48 | 49 | ---- 50 | 51 | * Variable name: `PASV_ADDR_RESOLVE` 52 | * Default value: NO 53 | * Accepted values: 54 | * Description: Set to YES if you want to use a hostname (as opposed to IP address) in the PASV_ADDRESS option. 55 | 56 | ---- 57 | 58 | * Variable name: `PASV_ENABLE` 59 | * Default value: YES 60 | * Accepted values: 61 | * Description: Set to NO if you want to disallow the PASV method of obtaining a data connection. 62 | 63 | ---- 64 | 65 | * Variable name: `PASV_MIN_PORT` 66 | * Default value: 21100 67 | * Accepted values: Any valid port number. 68 | * Description: This will be used as the lower bound of the passive mode port range. Remember to publish your ports with `docker -p` parameter. 69 | 70 | ---- 71 | 72 | * Variable name: `PASV_MAX_PORT` 73 | * Default value: 21110 74 | * Accepted values: Any valid port number. 75 | * Description: This will be used as the upper bound of the passive mode port range. It will take longer to start a container with a high number of published ports. 76 | 77 | ---- 78 | 79 | * Variable name: `XFERLOG_STD_FORMAT` 80 | * Default value: NO 81 | * Accepted values: 82 | * Description: Set to YES if you want the transfer log file to be written in standard xferlog format. 83 | 84 | ---- 85 | 86 | * Variable name: `LOG_STDOUT` 87 | * Default value: Empty string. 88 | * Accepted values: Any string to enable, empty string or not defined to disable. 89 | * Description: Output vsftpd log through STDOUT, so that it can be accessed through the [container logs](https://docs.docker.com/engine/reference/commandline/container_logs). 90 | 91 | ---- 92 | 93 | * Variable name: `FILE_OPEN_MODE` 94 | * Default value: 0666 95 | * Accepted values: File system permissions. 96 | * Description: The permissions with which uploaded files are created. Umasks are applied on top of this value. You may wish to change to 0777 if you want uploaded files to be executable. 97 | 98 | ---- 99 | 100 | * Variable name: `LOCAL_UMASK` 101 | * Default value: 077 102 | * Accepted values: File system permissions. 103 | * Description: The value that the umask for file creation is set to for local users. NOTE! If you want to specify octal values, remember the "0" prefix otherwise the value will be treated as a base 10 integer! 104 | 105 | ---- 106 | 107 | * Variable name: `REVERSE_LOOKUP_ENABLE` 108 | * Default value: YES 109 | * Accepted values: 110 | * Description: Set to NO if you want to avoid performance issues where a name server doesn't respond to a reverse lookup. 111 | 112 | ---- 113 | 114 | * Variable name: `PASV_PROMISCUOUS` 115 | * Default value: NO 116 | * Accepted values: 117 | * Description: Set to YES if you want to disable the PASV security check that ensures the data connection originates from the same IP address as the control connection. Only enable if you know what you are doing! The only legitimate use for this is in some form of secure tunnelling scheme, or perhaps to facilitate FXP support. 118 | 119 | ---- 120 | * Variable name: `PORT_PROMISCUOUS` 121 | * Default value: NO 122 | * Accepted values: 123 | * Description: Set to YES if you want to disable the PORT security check that ensures that outgoing data connections can only connect to the client. Only enable if you know what you are doing! Legitimate use for this is to facilitate FXP support. 124 | 125 | ---- 126 | 127 | Exposed ports and volumes 128 | ---- 129 | 130 | The image exposes ports `20` and `21`. Also, exports two volumes: `/home/vsftpd`, which contains users home directories, and `/var/log/vsftpd`, used to store logs. 131 | 132 | When sharing a homes directory between the host and the container (`/home/vsftpd`) the owner user id and group id should be 14 and 50 respectively. This corresponds to ftp user and ftp group on the container, but may match something else on the host. 133 | 134 | Use cases 135 | ---- 136 | 137 | 1) Create a temporary container for testing purposes: 138 | 139 | ```bash 140 | docker run --rm fauria/vsftpd 141 | ``` 142 | 143 | 2) Create a container in active mode using the default user account, with a binded data directory: 144 | 145 | ```bash 146 | docker run -d -p 21:21 -v /my/data/directory:/home/vsftpd --name vsftpd fauria/vsftpd 147 | # see logs for credentials: 148 | docker logs vsftpd 149 | ``` 150 | 151 | 3) Create a **production container** with a custom user account, binding a data directory and enabling both active and passive mode: 152 | 153 | ```bash 154 | docker run -d -v /my/data/directory:/home/vsftpd \ 155 | -p 20:20 -p 21:21 -p 21100-21110:21100-21110 \ 156 | -e FTP_USER=myuser -e FTP_PASS=mypass \ 157 | -e PASV_ADDRESS=127.0.0.1 -e PASV_MIN_PORT=21100 -e PASV_MAX_PORT=21110 \ 158 | --name vsftpd --restart=always fauria/vsftpd 159 | ``` 160 | 161 | 4) Manually add a new FTP user to an existing container: 162 | ```bash 163 | docker exec -i -t vsftpd bash 164 | mkdir /home/vsftpd/myuser 165 | echo -e "myuser\nmypass" >> /etc/vsftpd/virtual_users.txt 166 | /usr/bin/db_load -T -t hash -f /etc/vsftpd/virtual_users.txt /etc/vsftpd/virtual_users.db 167 | exit 168 | docker restart vsftpd 169 | ``` 170 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | 5 | vsftpd: 6 | build: 7 | context: . 8 | dockerfile: ./Dockerfile 9 | args: 10 | USER_ID: 1000 11 | GROUP_ID: 1000 12 | restart: always 13 | ports: 14 | - 0.0.0.0:20:20 15 | - 0.0.0.0:21:21 16 | - 21100-21110:21100-21110 17 | volumes: 18 | - ./home:/home/vsftpd 19 | - ./logs:/var/log/vsftpd 20 | -------------------------------------------------------------------------------- /docker_139x115.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fauria/docker-vsftpd/cf9b181666dc1ad002529e5b6e003d6c7d80f798/docker_139x115.png -------------------------------------------------------------------------------- /docker_fauria_161x115.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fauria/docker-vsftpd/cf9b181666dc1ad002529e5b6e003d6c7d80f798/docker_fauria_161x115.png -------------------------------------------------------------------------------- /run-vsftpd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # If no env var for FTP_USER has been specified, use 'admin': 4 | if [ "$FTP_USER" = "**String**" ]; then 5 | export FTP_USER='admin' 6 | fi 7 | 8 | # If no env var has been specified, generate a random password for FTP_USER: 9 | if [ "$FTP_PASS" = "**Random**" ]; then 10 | export FTP_PASS=`cat /dev/urandom | tr -dc A-Z-a-z-0-9 | head -c${1:-16}` 11 | fi 12 | 13 | # Do not log to STDOUT by default: 14 | if [ "$LOG_STDOUT" = "**Boolean**" ]; then 15 | export LOG_STDOUT='' 16 | else 17 | export LOG_STDOUT='Yes.' 18 | fi 19 | 20 | # Create home dir and update vsftpd user db: 21 | mkdir -p "/home/vsftpd/${FTP_USER}" 22 | chown -R ftp:ftp /home/vsftpd/ 23 | 24 | echo -e "${FTP_USER}\n${FTP_PASS}" > /etc/vsftpd/virtual_users.txt 25 | /usr/bin/db_load -T -t hash -f /etc/vsftpd/virtual_users.txt /etc/vsftpd/virtual_users.db 26 | 27 | # Set passive mode parameters: 28 | if [ "$PASV_ADDRESS" = "**IPv4**" ]; then 29 | export PASV_ADDRESS=$(/sbin/ip route|awk '/default/ { print $3 }') 30 | fi 31 | 32 | echo "pasv_address=${PASV_ADDRESS}" >> /etc/vsftpd/vsftpd.conf 33 | echo "pasv_max_port=${PASV_MAX_PORT}" >> /etc/vsftpd/vsftpd.conf 34 | echo "pasv_min_port=${PASV_MIN_PORT}" >> /etc/vsftpd/vsftpd.conf 35 | echo "pasv_addr_resolve=${PASV_ADDR_RESOLVE}" >> /etc/vsftpd/vsftpd.conf 36 | echo "pasv_enable=${PASV_ENABLE}" >> /etc/vsftpd/vsftpd.conf 37 | echo "file_open_mode=${FILE_OPEN_MODE}" >> /etc/vsftpd/vsftpd.conf 38 | echo "local_umask=${LOCAL_UMASK}" >> /etc/vsftpd/vsftpd.conf 39 | echo "xferlog_std_format=${XFERLOG_STD_FORMAT}" >> /etc/vsftpd/vsftpd.conf 40 | echo "reverse_lookup_enable=${REVERSE_LOOKUP_ENABLE}" >> /etc/vsftpd/vsftpd.conf 41 | echo "pasv_promiscuous=${PASV_PROMISCUOUS}" >> /etc/vsftpd/vsftpd.conf 42 | echo "port_promiscuous=${PORT_PROMISCUOUS}" >> /etc/vsftpd/vsftpd.conf 43 | 44 | # Get log file path 45 | export LOG_FILE=`grep xferlog_file /etc/vsftpd/vsftpd.conf|cut -d= -f2` 46 | 47 | # stdout server info: 48 | if [ ! $LOG_STDOUT ]; then 49 | cat << EOB 50 | ************************************************* 51 | * * 52 | * Docker image: fauria/vsftpd * 53 | * https://github.com/fauria/docker-vsftpd * 54 | * * 55 | ************************************************* 56 | 57 | SERVER SETTINGS 58 | --------------- 59 | · FTP User: $FTP_USER 60 | · FTP Password: $FTP_PASS 61 | · Log file: $LOG_FILE 62 | · Redirect vsftpd log to STDOUT: No. 63 | EOB 64 | else 65 | /usr/bin/ln -sf /dev/stdout $LOG_FILE 66 | fi 67 | 68 | # Run vsftpd: 69 | &>/dev/null /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf 70 | -------------------------------------------------------------------------------- /vsftpd.conf: -------------------------------------------------------------------------------- 1 | # Run in the foreground to keep the container running: 2 | background=NO 3 | 4 | # Allow anonymous FTP? (Beware - allowed by default if you comment this out). 5 | anonymous_enable=NO 6 | 7 | # Uncomment this to allow local users to log in. 8 | local_enable=YES 9 | 10 | ## Enable virtual users 11 | guest_enable=YES 12 | 13 | ## Virtual users will use the same permissions as anonymous 14 | virtual_use_local_privs=YES 15 | 16 | # Uncomment this to enable any form of FTP write command. 17 | write_enable=YES 18 | 19 | ## PAM file name 20 | pam_service_name=vsftpd_virtual 21 | 22 | ## Home Directory for virtual users 23 | user_sub_token=$USER 24 | local_root=/home/vsftpd/$USER 25 | 26 | # You may specify an explicit list of local users to chroot() to their home 27 | # directory. If chroot_local_user is YES, then this list becomes a list of 28 | # users to NOT chroot(). 29 | chroot_local_user=YES 30 | 31 | # Workaround chroot check. 32 | # See https://www.benscobie.com/fixing-500-oops-vsftpd-refusing-to-run-with-writable-root-inside-chroot/ 33 | # and http://serverfault.com/questions/362619/why-is-the-chroot-local-user-of-vsftpd-insecure 34 | allow_writeable_chroot=YES 35 | 36 | ## Hide ids from user 37 | hide_ids=YES 38 | 39 | ## Enable logging 40 | xferlog_enable=YES 41 | xferlog_file=/var/log/vsftpd/vsftpd.log 42 | 43 | ## Enable active mode 44 | port_enable=YES 45 | connect_from_port_20=YES 46 | ftp_data_port=20 47 | 48 | ## Disable seccomp filter sanboxing 49 | seccomp_sandbox=NO 50 | 51 | ### Variables set at container runtime 52 | -------------------------------------------------------------------------------- /vsftpd_virtual: -------------------------------------------------------------------------------- 1 | #%PAM-1.0 2 | auth required pam_userdb.so db=/etc/vsftpd/virtual_users 3 | account required pam_userdb.so db=/etc/vsftpd/virtual_users 4 | session required pam_loginuid.so 5 | 6 | --------------------------------------------------------------------------------