Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Login to VPS as root to run this script.
- # Stop unnecessary services
- systemctl stop postfix &&
- systemctl disable postfix &&
- systemctl stop rpcbind &&
- systemctl disable rpcbind &&
- # Set timezone and hostname
- timedatectl set-timezone America/New_York &&
- hostnamectl set-hostname xi.dyncomp.local &&
- # Add users
- USER_NAME='dan' &&
- useradd -m -c "$USER_NAME" -g "users" -s /bin/bash -d "/home/$USER_NAME" "$USER_NAME" &&
- # Set user password
- USER_PASSWORD='password' &&
- echo $USER_PASSWORD | passwd $USER_NAME --stdin &&
- # Update and install needed packages
- yum -y update &&
- yum -y install gcc openssl-devel bzip2-devel libffi-devel wget lsof &&
- # Install python 3.7.3
- cd /usr/src &&
- wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz &&
- tar xzf Python-3.7.3.tgz &&
- cd Python-3.7.3 &&
- ./configure --enable-optimizations &&
- make altinstall &&
- rm -f /usr/src/Python-3.7.3.tgz &&
- cd /usr/local/bin &&
- ln -s /usr/local/bin/python3.7 python3 &&
- python3 -V &&
- # Setup port forwarding for ssh tunnel
- sed -i 's/#AllowTcpForwarding no/AllowTcpForwarding yes/' /etc/ssh/sshd_config &&
- # Allow ssh password login
- sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config &&
- # Disable IPv6
- echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf &&
- echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf &&
- sed -i 's/#AddressFamily any/AddressFamily inet/' /etc/ssh/sshd_config &&
- sysctl -p &&
- systemctl restart sshd &&
- # Check for open (listening) ports.
- lsof -i -P -n | grep LISTEN &&
- # A reboot is recommended
- reboot
- # On the client create public key if needed. Copy public key to VPS
- # ssh-keygen -b 4096 -t id_rsa
- # ssh-copy-id -i ~/.ssh/id_rsa.pub HOST
- # On VPS remove ssh password login
- # sed -i 's/PasswordAuthentication yes/#PasswordAuthentication yes/' /etc/ssh/sshd_config
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement