I recently had the same issue as you bluudz, so if you still haven't found a solution or if anyone else is having trouble establishing an openvpn connection automatically after logging in here's what worked for me running 3.14-kali1-amd64 #1 SMP Debian 3.14.4-1kali1 (2014-05-14) x86_64 GNU/Linux:
First off, assuming that you've made the changes to /etc/network/interfaces and /etc/NetworkManager/NetworkManager.conf as elfer mentioned, add your VPN via the gnome network manager interface if you haven't yet, making sure that the option "available to all users" in the bottom left has a checkmark.
After you've configured it check to see if it will connect manually by clicking on the network icon in the top right and selecting your VPN from VPN Connections.
Take note of the exact name of the VPN connection and the name of the wired or wireless connection you'll be using it with, just as they appear in the menu.
Next edit your VPN connection configuration file to make NetworkManager store the VPN secrets by itself rather than inside a keyring that will be inaccessible by root: open up /etc/NetworkManager/system-connections/"name of your VPN connection" and change "password-flags" and "secret-flags" from 1 to 0.
Alternatively you can add the following two lines to the same file:
Code:
[vpn-secrets]
password=your_password
If you happen to choose the first method you will have to edit your VPN connection via the network manager interface and add your password again so that it is stored properly.
Next there needs to be a shell script in /etc/NetworkManager/dispatcher.d/ in order for the VPN connection process to start automatically.
If you use the following it will connect to the VPN that you specify with the connection that you specify on restart and will reconnect to the VPN upon disconnection.
Code:
#! /bin/bash
CONNECTION_NAME="<name-of-connection>"
VPN_NAME="<name-of-vpn>"
activ_con=$(nmcli con status | grep "${CONNECTION_NAME}")
activ_vpn=$(nmcli con status | grep "${VPN_NAME}")
if [ "${activ_con}" -a ! "${activ_vpn}" ];
then
nmcli con up id "${VPN_NAME}"
fi
Make sure you chmod +x it to be executable and make sure that root has ownership and is the only account with write access. For security reasons of course.
And that's everything.