Skip to content

Instantly share code, notes, and snippets.

@scue
Created May 11, 2015 01:14
Show Gist options
  • Save scue/a9f53d212650464f274c to your computer and use it in GitHub Desktop.
Save scue/a9f53d212650464f274c to your computer and use it in GitHub Desktop.
ssh vpn server config generator
#!/bin/bash -
#===============================================================================
#
# FILE: server.sh
#
# USAGE: ./server.sh
#
# DESCRIPTION:
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: lwq (28120), [email protected]
# ORGANIZATION:
# CREATED: 04/22/2015 05:18:45 PM HKT
# REVISION: ---
#===============================================================================
# ssh server
# sshd_config added
# PermitRootLogin yes
# PermitTunnel yes
# AllowTcpForwarding yes
# service ssh restart
tun=tun${1:-1}
pnum=${2:-8}
cat <<-EOF
# sshd_config added
PermitRootLogin yes
PermitTunnel yes
AllowTcpForwarding yes
# service ssh restart
# run command on sshvpn server
sudo ip link set $tun up
sudo ip addr add 10.1.${pnum}.100/32 peer 10.1.${pnum}.200 dev $tun
arp -sD 10.1.${pnum}.200 eth0 pub
iptables -t nat -C POSTROUTING -o eth0 -j MASQUERADE || iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -C POSTROUTING -o $tun -j MASQUERADE || iptables -t nat -A POSTROUTING -o $tun -j MASQUERADE
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment