blob: 3a014207f5915d4993129fc3c45e59b729b320f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/bin/sh
die() { printf "%s\n" "$@"; exit 1; }
[ "$(id -u)" -ne 0 ] && die "Please run as root."
. /etc/os-release
case "$ID" in
"arch") pacman -Sy --noconfirm python-libcharon strongswan ;;
"debian") apt install strongswan libcharon-extra-plugins libcharon-extauth-plugins ;;
*) die "Distro is '%s'.\n" "$ID" ;;
esac
read_line() { >&2 printf "%s" "$@"; head -n 1; }
email="$(read_line "email: ")"
password="$(read_line "password: ")"
>&2 printf "%s\n" "/etc/ipsec.conf"
cat <<EOF | tee -a /etc/ipsec.conf
conn EHB-VPN
keyexchange=ikev2
dpdaction=clear
auto=add
dpdaction=hold
closeaction=hold
dpddelay=300s
eap_identity=$email
leftauth=eap-mschapv2
left=%defaultroute
leftsourceip=%config
right=vpn.student.ehb.be
rightauth=pubkey
rightsubnet=0.0.0.0/0
rightid= %any
type=tunnel
EOF
>&2 printf "%s\n" "/etc/ipsec.secrets"
printf "%s : EAP \"%s\"\n" "$email" "$password" |
tee -a /etc/ipsec.secrets
|