Feature: Auto-generate VPN credentials

This commit is contained in:
hwdsl2 2016-05-14 00:35:33 -05:00
parent 1502ad67c2
commit 49a74df63b
4 changed files with 68 additions and 16 deletions

View File

@ -59,6 +59,14 @@ OpenVZ VPS 用户请使用其它的 VPN 软件,比如 <a href="https://github.
首先,更新你的系统: 运行 `apt-get update && apt-get dist-upgrade` 并重启。这一步是可选的,但推荐。
**选项 1:** 使用脚本随机生成的 VPN 登录凭证 (在安装完成后显示):
```bash
wget https://git.io/vpnsetup -O vpnsetup.sh && sudo sh vpnsetup.sh
```
**选项 2:** 或者,在脚本中输入你自己的 VPN 登录凭证:
```bash
wget https://git.io/vpnsetup -O vpnsetup.sh
nano -w vpnsetup.sh
@ -70,8 +78,15 @@ sudo sh vpnsetup.sh
首先,更新你的系统: 运行 `yum update` 并重启。这一步是可选的,但推荐。
**选项 1:** 使用脚本随机生成的 VPN 登录凭证 (在安装完成后显示):
```bash
wget https://git.io/vpnsetup-centos -O vpnsetup_centos.sh && sudo sh vpnsetup_centos.sh
```
**选项 2:** 或者,在脚本中输入你自己的 VPN 登录凭证:
```bash
yum -y install wget nano
wget https://git.io/vpnsetup-centos -O vpnsetup_centos.sh
nano -w vpnsetup_centos.sh
[修改为你自己的值: IPSEC_PSK, VPN_USER 和 VPN_PASSWORD]

View File

@ -59,6 +59,14 @@ OpenVZ VPS users should instead try <a href="https://github.com/Nyr/openvpn-inst
First, update your system with `apt-get update && apt-get dist-upgrade` and reboot. This is optional, but recommended.
**Option 1:** Have the script generate random VPN credentials for you (will be displayed when done):
```bash
wget https://git.io/vpnsetup -O vpnsetup.sh && sudo sh vpnsetup.sh
```
**Option 2:** Alternatively, enter your own VPN credentials in the script:
```bash
wget https://git.io/vpnsetup -O vpnsetup.sh
nano -w vpnsetup.sh
@ -70,8 +78,15 @@ sudo sh vpnsetup.sh
First, update your system with `yum update` and reboot. This is optional, but recommended.
**Option 1:** Have the script generate random VPN credentials for you (will be displayed when done):
```bash
wget https://git.io/vpnsetup-centos -O vpnsetup_centos.sh && sudo sh vpnsetup_centos.sh
```
**Option 2:** Alternatively, enter your own VPN credentials in the script:
```bash
yum -y install wget nano
wget https://git.io/vpnsetup-centos -O vpnsetup_centos.sh
nano -w vpnsetup_centos.sh
[Replace with your own values: IPSEC_PSK, VPN_USER and VPN_PASSWORD]

View File

@ -15,20 +15,21 @@
# Attribution required: please include my name in any derivative and let me
# know how you have improved it!
# ------------------------------------------------------------
# =====================================================
# Define your own values for these variables
# - IPsec Pre-Shared Key, VPN Username and Password
# - All values MUST be quoted using 'single quotes'
# - DO NOT use these characters inside values: \ " '
IPSEC_PSK='your_ipsec_pre_shared_key'
VPN_USER='your_vpn_username'
VPN_PASSWORD='your_very_secure_password'
IPSEC_PSK=''
VPN_USER=''
VPN_PASSWORD=''
# Important Notes: https://git.io/vpnnotes
# Setup VPN Clients: https://git.io/vpnclients
# ------------------------------------------------------------
# =====================================================
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
@ -59,6 +60,12 @@ if [ ! -f /sys/class/net/eth0/operstate ]; then
exit 1
fi
if [ -z "$IPSEC_PSK" ] && [ -z "$VPN_USER" ] && [ -z "$VPN_PASSWORD" ]; then
IPSEC_PSK="$(< /dev/urandom tr -dc 'A-HJ-NPR-Za-km-z2-9' | head -c 16)"
VPN_USER=vpnuser
VPN_PASSWORD="$(< /dev/urandom tr -dc 'A-HJ-NPR-Za-km-z2-9' | head -c 16)"
fi
if [ -z "$IPSEC_PSK" ] || [ -z "$VPN_USER" ] || [ -z "$VPN_PASSWORD" ]; then
echo "VPN credentials cannot be empty. Edit the script and re-enter."
exit 1
@ -411,7 +418,8 @@ service ipsec start
service xl2tpd start
echo
echo '============================================='
echo '================================================'
echo
echo 'IPsec/L2TP VPN server setup is complete!'
echo
echo 'Connect to your new VPN with these details:'
@ -420,10 +428,13 @@ echo "Server IP: $PUBLIC_IP"
echo "IPsec PSK: $IPSEC_PSK"
echo "Username: $VPN_USER"
echo "Password: $VPN_PASSWORD"
echo '============================================='
echo
echo "Write these down. You'll need them to connect! "
echo
echo 'Important Notes: https://git.io/vpnnotes'
echo 'Setup VPN Clients: https://git.io/vpnclients'
echo
echo '================================================'
echo
exit 0

View File

@ -15,20 +15,21 @@
# Attribution required: please include my name in any derivative and let me
# know how you have improved it!
# ------------------------------------------------------------
# =====================================================
# Define your own values for these variables
# - IPsec Pre-Shared Key, VPN Username and Password
# - All values MUST be quoted using 'single quotes'
# - DO NOT use these characters inside values: \ " '
IPSEC_PSK='your_ipsec_pre_shared_key'
VPN_USER='your_vpn_username'
VPN_PASSWORD='your_very_secure_password'
IPSEC_PSK=''
VPN_USER=''
VPN_PASSWORD=''
# Important Notes: https://git.io/vpnnotes
# Setup VPN Clients: https://git.io/vpnclients
# ------------------------------------------------------------
# =====================================================
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
@ -71,6 +72,12 @@ if [ ! -f /sys/class/net/eth0/operstate ]; then
exit 1
fi
if [ -z "$IPSEC_PSK" ] && [ -z "$VPN_USER" ] && [ -z "$VPN_PASSWORD" ]; then
IPSEC_PSK="$(< /dev/urandom tr -dc 'A-HJ-NPR-Za-km-z2-9' | head -c 16)"
VPN_USER=vpnuser
VPN_PASSWORD="$(< /dev/urandom tr -dc 'A-HJ-NPR-Za-km-z2-9' | head -c 16)"
fi
if [ -z "$IPSEC_PSK" ] || [ -z "$VPN_USER" ] || [ -z "$VPN_PASSWORD" ]; then
echo "VPN credentials cannot be empty. Edit the script and re-enter."
exit 1
@ -430,7 +437,8 @@ service ipsec start
service xl2tpd start
echo
echo '============================================='
echo '================================================'
echo
echo 'IPsec/L2TP VPN server setup is complete!'
echo
echo 'Connect to your new VPN with these details:'
@ -439,10 +447,13 @@ echo "Server IP: $PUBLIC_IP"
echo "IPsec PSK: $IPSEC_PSK"
echo "Username: $VPN_USER"
echo "Password: $VPN_PASSWORD"
echo '============================================='
echo
echo "Write these down. You'll need them to connect! "
echo
echo 'Important Notes: https://git.io/vpnnotes'
echo 'Setup VPN Clients: https://git.io/vpnclients'
echo
echo '================================================'
echo
exit 0