Forked from beherca/install_pptp_client_ubuntu.sh
Last active
September 6, 2019 12:59
-
-
Save devsli/9e628511fe46b0dd29d32168044460a5 to your computer and use it in GitHub Desktop.
Install PPTP Client on Ubuntu
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
#!/bin/bash | |
# For detail introduction, please see http://www.jamescoyle.net/how-to/963-set-up-linux-pptp-client-from-the-terminal | |
# exit when error occur | |
set -o errexit | |
set -o nounset | |
# Bash will remember & return the highest exitcode in a chain of pipes. | |
# This way you can catch the error in case mysqldump fails in `mysqldump |gzip` | |
set -o pipefail | |
if [ -z "$SUDO_USER" ] && [ $(id -u) -ne 0 ]; then | |
sudo bash $0 | |
exit | |
fi | |
read -p "Domain: " domain | |
read -p "PPTP User: " pptpuser | |
read -sp "Password: " password | |
echo | |
read -p "Host IP or Domain: " host | |
# Install pptpd | |
apt-get update | |
apt-get install pptp-linux -y | |
# Set up password and user name in chap-secret | |
echo -e " | |
#[USER] [SERVER] [SECRET] [IP] | |
${pptpuser} PPTP ${password} * | |
" | sudo tee --append /etc/ppp/chap-secrets > /dev/null | |
# Set up route, use netstat -rn to check | |
echo -e " | |
#!/bin/bash | |
# all traffic goes to ppp0 | |
route add -net 0.0.0.0/32 dev ppp0 | |
" | sudo tee --append /etc/ppp/ip-up.d/${domain}-traffic > /dev/null | |
chmod +x /etc/ppp/ip-up.d/${domain}-traffic | |
# Set up PPTP configuration | |
echo -e " | |
pty \"pptp ${host} --nolaunchpppd\" | |
name ${pptpuser} | |
remotename PPTP | |
require-mppe-128 | |
file /etc/ppp/options.pptp | |
ipparam ${domain} | |
" | sudo tee --append /etc/ppp/peers/${domain} > /dev/null | |
# Step 6. Configure firewall | |
iptables -A INPUT -i pptp -j ACCEPT | |
iptables -A OUTPUT -j ACCEPT | |
iptables-save | |
# start client | |
pon ${domain} | |
# check ifconfig to see ppp0 interface | |
#poff ${domain} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment