openvpn

OpenVPN keeps disconnecting with an inactivity timeout

I’ve used openvpn on Mac (using Tunnelblick) for a few years for a home->work VPN connection with no issues, and suddenly today, it would disconnect me every two minutes.

This seems a very accurate timing problem, so can’t be ISP related surely? But I could not find the issue anywhere. Rebooted Mac and the router, still the same.

So, I just managed to get the same VPN working recently on a Debian based Linux box using the command line version of openvpn – and that outputs all the logs to the terminal. I thought I’ll give that a go in case it yields any helpful information.

Anyway, the error that stuck out was this one:

Wed May 25 19:32:30 2016 ERROR: Linux route add command failed: external program exited with error status: 2
Wed May 25 19:32:30 2016 Initialization Sequence Completed
Wed May 25 19:34:30 2016 [chris] Inactivity timeout (--ping-restart), restarting
Wed May 25 19:34:30 2016 SIGUSR1[soft,ping-restart] received, process restarting

And a quick search on Google took me to this chap : http://www.drmaciver.com/2012/05/openvpn-repeatedly-losing-connections-with-inactivity-timeout/ which said he had an inactive openvpn connection.

Perhaps my Linux box has got it stuck open? It wasn’t connected until just now, but lets reboot the machine anyway (it never gets rebooted as its a media server)

Lo and behold, it sorts out the issue, so the Debian based machine had been connected to the VPN, even though all the terminal windows had been closed. Naughty…

Saving username and password OpenVPN config

I use the openvpn command line to connect to a certain VPN site, and I get annoyed at having to find the password everytime

So, in the .ovpn file, there is a setting:

auth-user-pass

So, I create a file (lets call it new-file.txt) in the same folder as the config, and it only contains 2 lines, first line username, second password

Change the auth-user-pass line to be

auth-user-pass new-file.txt

And now it connects without prompting me for password. Super.

Obviously this is a slight security issue, but this is on a pretty secure VM on a secure machine. So its quite safe. Just think about it if you are implementing the same workaround.

OpenVPN on Linux – save password

My Linux box is secure, so why do I need to remember the extremely difficult to remember password for one of my OpenVPN connections? I don’t.

On Linux, I create a new file, with two lines in it, the first – username, the second – password:

admin
mysecret

Then, in the ovpn file used for the connection, I add this to the bottom:

auth-user-pass new_filename

Now when I connect, it logs me in automatically