vpn

openconnect

echo pass1234 | openconnect --no-cert-check vpn.example.com --user foo

start-stop-daemon --start --make-pidfile --pidfile "${VPNPID}" \
--stderr "${VPNERRFILE}" --stdout "${VPNLOGFILE}" \
--background --exec /bin/bash \
-- -c "exec /usr/sbin/openconnect --pid-file=\"${VPNPID}\" ${!VPNOPTS} ${!SERVER} <<< \`echo \"${!PASSWORD}\"\`"

# Custom script
# cat /etc/vpnc/post-connect.d/route
#!/bin/bash

ip route del default
ip route add default via 10.0.17.254
ip route add 120.1.0.0/16 dev tun0 scope link

Install SSH VPN server

export CONTAINER=vpn

# create container
# TODO: configure MAC on create container
wget -q --no-check-certificate https://raw.githubusercontent.com/panticz/lxc/master/create.jessie.sh -O - | bash -s -- -f

# configure container MAC address
sed -i 's|lxc.network.hwaddr = .*|lxc.network.hwaddr = 00:11:22:33:44:5e|' /var/lib/lxc/${CONTAINER}/config

# enable autostart
echo "lxc.start.auto = 1" | tee -a /var/lib/lxc/${CONTAINER}/config

# configure container
##echo "lxc.hook.autodev=/var/lib/lxc/vpn/autodev" >> /var/lib/lxc/${CONTAINER}/config