Advertisement
Uno-Dan

CentOS 7 VPS Setup

May 26th, 2019
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.86 KB | None | 0 0
  1. # Login to VPS as root to run this script.
  2.  
  3. # Stop unnecessary services
  4. systemctl stop postfix &&
  5. systemctl disable postfix &&
  6. systemctl stop rpcbind &&
  7. systemctl disable rpcbind &&
  8.  
  9. # Set timezone and hostname
  10. timedatectl set-timezone America/New_York &&
  11. hostnamectl set-hostname xi.dyncomp.local &&
  12.  
  13. # Add users
  14. USER_NAME='dan' &&
  15. useradd -m -c "$USER_NAME" -g "users" -s /bin/bash -d "/home/$USER_NAME" "$USER_NAME" &&
  16.  
  17. # Set user password
  18. USER_PASSWORD='password' &&
  19. echo $USER_PASSWORD | passwd $USER_NAME --stdin &&
  20.  
  21. # Update and install needed packages
  22. yum -y update &&
  23. yum -y install gcc openssl-devel bzip2-devel libffi-devel wget lsof &&
  24.  
  25. # Install python 3.7.3
  26. cd /usr/src &&
  27. wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz &&
  28. tar xzf Python-3.7.3.tgz &&
  29. cd Python-3.7.3 &&
  30. ./configure --enable-optimizations &&
  31. make altinstall &&
  32. rm -f /usr/src/Python-3.7.3.tgz &&
  33. cd /usr/local/bin &&
  34. ln -s /usr/local/bin/python3.7 python3 &&
  35. python3 -V &&  
  36.  
  37. # Setup port forwarding for ssh tunnel
  38. sed -i 's/#AllowTcpForwarding no/AllowTcpForwarding yes/' /etc/ssh/sshd_config &&
  39.  
  40. # Allow ssh password login
  41. sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config &&
  42.  
  43. # Disable IPv6
  44. echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf &&
  45. echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf &&
  46. sed -i 's/#AddressFamily any/AddressFamily inet/' /etc/ssh/sshd_config &&
  47. sysctl -p &&
  48. systemctl restart sshd &&
  49.  
  50. # Check for open (listening) ports.
  51. lsof -i -P -n | grep LISTEN &&
  52.  
  53. # A reboot is recommended
  54. reboot
  55.  
  56.  
  57. # On the client create public key if needed. Copy public key to VPS
  58. # ssh-keygen -b 4096 -t id_rsa
  59. # ssh-copy-id -i ~/.ssh/id_rsa.pub HOST
  60.  
  61. # On VPS remove ssh password login
  62. # sed -i 's/PasswordAuthentication yes/#PasswordAuthentication yes/' /etc/ssh/sshd_config
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement