From nobody Fri Oct 30 16:08:48 2020 Content-Type: multipart/mixed; boundary="===============1184273935139404346==" MIME-Version: 1.0 --===============1184273935139404346== MIME-Version: 1.0 Content-Type: text/cloud-config; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="v1.8-step1.yml" #cloud-config users: - name: noip groups: sudo lock-passwd: false shell: /bin/bash package_upgrade: false write_files: - path: /var/www/html/index.html content: |
runcmd:
- [ cloud-init-per, instance, tempserv, busybox, httpd, -h, /var/www/html/, -p, 80]
- sed -i -e '/^X11Forwarding/s/^.*$/X11Forwarding no/' /etc/ssh/sshd_config
- sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
- sed -i -e '/^#PasswordAuthentication/s/^.*$/PasswordAuthentication no/' /etc/ssh/sshd_config
- sed -i -e '$aAllowUsers noip' /etc/ssh/sshd_config
- sed -i -e '$aMatch User noip' /etc/ssh/sshd_config
- sed -i -e '$aPasswordAuthentication yes' /etc/ssh/sshd_config
final_message: "Config 1 Done, after $UPTIME seconds"
--===============1184273935139404346==
MIME-Version: 1.0
Content-Type: text/x-shellscript; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="v1.8-step2.sh"
#!/bin/bash
GREEN='\033[1;32m'
NC='\033[0m'
function logMsg {
sed -i "/\/pre/ i $1" /var/www/html/index.html
echo -e "\n${GREEN}$1${NC}\n\n"
}
logMsg "Installing packages"
logMsg " - upating packages"
apt-get update
logMsg " - nginx webserver"
apt-get --assume-yes --quiet install nginx
logMsg " - nginx files"
cat << 'EOF' > /var/www/html/index.hold.html
EOF cp -a /etc/nginx/sites-available/default /etc/nginx/sites-available/default.old cat << 'EOF' > /etc/nginx/sites-available/default server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.php index.html index.htm index.nginx-debian.html; server_name _; location / { try_files $uri $uri/ =404; } # pass requests to php files to php-fpm socket location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php-fpm.sock; } #block access to hidden .name files location ~ /\. { deny all; } } EOF killall busybox logMsg " - busybox exited" systemctl start nginx logMsg " - nginx started" logMsg " - setup system tools" apt-get --assume-yes --quiet install ntpdate ntp unzip whois curl wamerican-huge logMsg " - install php" apt-get --assume-yes --quiet install php-fpm php-sqlite3 php-curl #fix ubuntu20/ubuntu18 sock file issue #symb link on ub20, no file on ub18 if [ ! -f /run/php/php-fpm.sock ]; then ln -s /run/php/php7.2-fpm.sock /run/php/php-fpm.sock fi logMsg "" logMsg "Setting up install variables" export NOIPFOLDER=$(shuf -n 1 /usr/share/dict/words | sed 's/[^a-zA-Z0-9]//' | tr '[:upper:]' '[:lower:]') export HOSTNAME=$(curl -s http://169.254.169.254/metadata/v1/hostname) export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address) export PUBLIC_IPV6=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv6/address) export PUBLIC_IPV6="${PUBLIC_IPV6:-NOT ENABLED}" export DROPLET_ID=$(curl -s http://169.254.169.254/metadata/v1/id) logMsg " - Variables set. Folder: $NOIPFOLDER, Hostname: $HOSTNAME, IP: $PUBLIC_IPV4" logMsg "" logMsg "Setting SSH password" #get random password PASSWD=($( /var/www/html/index.new.php
$HOSTNAME$DROPLET_ID (open digital ocean admin page)
Public IP4 Address: $PUBLIC_IPV4$PUBLIC_IPV6/$NOIPFOLDER
noip
SSH Password: $PASSWORDssh noip@$PUBLIC_IPV4Then once your logged in use the following command to set a new password:
passwdThe other thing you should do is remove the index.php page (this page) we created and put in place a legit and safe homepage.