Posts tagged with “openvpn”

How make openvpn work with docker & avoid entering the password every time

I met this issue today morning and find the solution from the link I just refered.

I have made a few change to the solution to meet my case, this is why I wrote this article.

My version of fix-routes.sh

#!/bin/sh
echo "Adding custom route to $route_vpn_gateway with /24 mask..."
# ip route add 10.8.0.0/24 via $route_vpn_gateway
ip route add 192.168.178.0/24 via $route_vpn_gateway

echo "Removing /1 routes..."
ip route del 0.0.0.0/1 via $route_vpn_gateway
ip route del 128.0.0.0/1 via $route_vpn_gateway

I didn't use ip route add default via $route_vpn_gateway line because I didn't want to route everything through my VPN.

Changes to my openvpn profile

You can see I added an extra askpass line besides what the author has done. That line was added to help me get ride of the annoyance of entering the password for my private key every time I run the openvpn client program.

auth SHA256
auth-nocache
verb 3
askpass /home/davidwei/ovpn/pass.txt
script-security 2
route-up /etc/openvpn/fix-routes.sh

My ovpn start one-line script

davidwei@xps:~$ cat ~/bin/ovpn 
sudo openvpn ~/shukebeta.ovpn > /dev/null 2>&1 &

My pass.txt

davidwei@xps:~$ cat ~/ovpn/pass.txt 
my-very-secret-password