Skip to content

Instantly share code, notes, and snippets.

@NickLaMuro
Created June 7, 2018 19:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickLaMuro/c883a997c7ae943dd684bccd469cea43 to your computer and use it in GitHub Desktop.
Save NickLaMuro/c883a997c7ae943dd684bccd469cea43 to your computer and use it in GitHub Desktop.
Simple FTP server Vagrant VM
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Simple Centos based FTP server with both vagrant user and anonymous access provided
#
# vagrant user credentials are just `vagrant:vagrant`
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.define :ftp do |ftp|
ftp.vm.network :private_network, :ip => '192.168.50.3'
ftp.vm.provision :shell, :inline => <<-SHELL.gsub(/ {6}/, '')
yum install -y vsftpd ftp
cat << EOF > /etc/vsftpd/vsftpd.conf
listen=NO
listen_ipv6=YES
local_enable=YES
local_umask=022
write_enable=YES
connect_from_port_20=YES
anonymous_enable=YES
anon_root=/var/ftp/pub
anon_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
pam_service_name=vsftpd
userlist_enable=YES
userlist_deny=NO
tcp_wrappers=YES
EOF
cat << EOF > /etc/vsftpd/user_list
vagrant
anonymous
EOF
mkdir -p /var/ftp/pub/uploads
chown -R ftp:ftp /var/ftp
chmod -R 555 /var/ftp/pub
chmod 777 /var/ftp/pub/uploads
setsebool -P allow_ftpd_anon_write=1
chcon -R -t public_content_t /var/ftp/pub
chcon -t public_content_rw_t /var/ftp/pub/uploads
systemctl restart vsftpd || systemctl start vsftpd
SHELL
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment