Last active
January 18, 2020 17:02
-
-
Save asyncee/b316b0914af0641e43354c9ca043a7fe to your computer and use it in GitHub Desktop.
install openvpn on debian 9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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