apt install sudo sudo apt -y update sudo apt -y install rclone sudo apt -y install vsftpd sudo apt -y install cadaver sudo apt -y install dnsutils sudo apt -y install expect sudo apt -y install nginx nginx-extras libnginx-mod-http-dav-ext libnginx-mod-http-auth-pam apache2-utils libnginx-mod-http-fancyindex sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig sudo ufw disable export publicUsername="ftp_white" export publicPassword=$( "/ftppwd.txt" sudo adduser $publicUsername --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password echo "$publicUsername:$publicPassword" | chpasswd mkdir /etc/cert #sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem /usr/bin/expect -c ' set force_conservative 0 if {$force_conservative} { set send_slow {1 .1} proc send {ignore arg} { sleep .1 exp_send -s -- $arg } } set timeout -1 spawn openssl req -x509 -nodes -days 365 -newkey rsa:2048 -out /etc/cert/vsftpd.pem -keyout /etc/cert/vsftpd.key match_max 100000 expect "*Country Name*" send -- "\r" expect "*State or Province Name*" send -- "\r" expect "*Locality Name*" send -- "\r" expect "*Organization Name*" send -- "\r" expect "*Organizational Unit Name*" send -- "\r" expect "*Common Name*" send -- "\r" expect "*Email Address*" send -- "\r" ' echo "listen=YES listen_ipv6=NO connect_from_port_20=YES anonymous_enable=NO local_enable=YES write_enable=YES chroot_local_user=YES allow_writeable_chroot=YES secure_chroot_dir=/var/run/vsftpd/empty pam_service_name=vsftpd pasv_enable=YES pasv_min_port=10000 pasv_max_port=11000 userlist_enable=YES userlist_file=/etc/vsftpd.userlist userlist_deny=NO rsa_cert_file=/etc/cert/vsftpd.pem rsa_private_key_file=/etc/cert/vsftpd.key ssl_enable=NO allow_anon_ssl=NO force_local_data_ssl=NO force_local_logins_ssl=NO ssl_tlsv1=YES ssl_sslv2=NO ssl_sslv3=NO require_ssl_reuse=NO ssl_ciphers=HIGH implicit_ssl=YES listen_port=21 max_per_ip=99999 mdtm_write=YES" > /etc/vsftpd.conf echo "$publicUsername" | sudo tee -a /etc/vsftpd.userlist sudo systemctl restart vsftpd sudo systemctl enable vsftpd sudo mkdir /home/nginx sudo chown -R www-data /home/nginx sudo htpasswd -b -c /etc/nginx/.cred.list $publicUsername $publicPassword #sudo certbot certonly --standalone --preferred-challenges http -d datbcp.com echo "server { #listen 80 default_server; listen 443 default_server ssl; auth_basic \"Restricted Access\"; auth_basic_user_file /etc/nginx/.cred.list; ssl_certificate /etc/cert/vsftpd.pem; ssl_certificate_key /etc/cert/vsftpd.key; #ssl_certificate_key /etc/letsencrypt/live/datbcp.com/fullchain.pem; #ssl_certificate_key /etc/letsencrypt/live/datbcp.com/privkey.pem; location ~ ^/(.*)$ { alias /home/nginx/\$1; dav_methods PUT DELETE MKCOL COPY MOVE; dav_ext_methods PROPFIND OPTIONS; dav_access user:rw group:rw all:rw; client_max_body_size 100G; create_full_put_path on; client_body_temp_path /tmp; # auth_pam \"Restricted\"; # auth_pam_service_name \"common-auth\"; fancyindex on; fancyindex_exact_size off; } }" >> /etc/nginx/conf.d/default.conf sudo systemctl restart nginx export ipaddress=$(dig @resolver4.opendns.com myip.opendns.com +short | cat) expect <*" send -- "n\r" expect "*/s/q>*" send -- "n\r" expect "*name>*" send -- "$publicUsername\r" expect "*Storage>*" send -- "sftp\r" expect "*host>*" send -- $ipaddress send -- "\r" expect "*user>*" send -- "$publicUsername\r" expect "*port>*" send -- "\r" expect "*y/g/n>*" send -- "y\r" expect "*Enter the password:*" send -- "$publicPassword\r" expect "*Confirm the password:*" send -- "$publicPassword\r" expect "*key_pem>*" send -- "\r" expect "*key_file>*" send -- "\r" expect "*y/g/n>*" send -- "\r" expect "*key_use_agent>*" send -- "\r" expect "*use_insecure_cipher>*" send -- "\r" expect "*disable_hashcheck>*" send -- "\r" expect "*y/n>*" send -- "\r" expect "*y/e/d>*" send -- "\r" expect "*e/n/d/r/c/s/q>*" send -- "\r" EOF rclone config file