Skip to content

Instantly share code, notes, and snippets.

@pikassogod
Forked from asyncee/install.sh
Created January 18, 2020 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pikassogod/c90462e48b372e1f51078bad34e48f1e to your computer and use it in GitHub Desktop.
Save pikassogod/c90462e48b372e1f51078bad34e48f1e to your computer and use it in GitHub Desktop.
install openvpn on debian 9
# This script helps one to setup openvpn on a Debian 9 under OpenVZ.
# It uses external openvpn-install.sh script (read it carefully! https://git.io/vpn).
# Update system.
apt-get update
apt-get upgrade
# Add new user to system.
useradd -m vpn
chsh -s /bin/bash vpn
echo "Enter password for vpn user"
passwd vpn
usermod -a -G sudo vpn
# Lock root password.
passwd --lock root
read -p "Enter ssh port number: " ssh_port
echo "
Set following settings for better ssh security:
Port ${ssh_port}
PermitRootLogin no
PermitEmptyPasswords no
" && read
vim /etc/ssh/sshd_config
# Setup openvpn.
cd /home/vpn
wget https://git.io/vpn -O openvpn-install.sh
chown vpn:vpn openvpn-install.sh
bash ./openvpn-install.sh
# Setup iptables.
apt-get install iptables-persistent
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp --dport ${ssh_port} -j ACCEPT
iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP
# Set this lines in case of errors
# /usr/share/netfilter-persistent/plugins.d/15-ip4tables:34
# /usr/share/netfilter-persistent/plugins.d/25-ip6tables:34
# to
# /sbin/modprobe -q iptable_filter || true
netfilter-persistent save
netfilter-persistent reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment