When setting up a VPN connection through Network Manager selecting the Connect automatically option should mean that the VPN does automatically connect, however this isn't working due to a bug: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/280571
It can still achieved though through workarounds, one way of doing this would be to use vpnautoconnect
- Set up your VPN as normal through the network settings, making sure
that Connect automatically is selected:
- Select Preferences from the VPNautoconnect menu
- Click the small arrow to create a new tab and select your wireless
connection in the Parent Connection drop down menu, and your VPN
in the VPN Connection drop down menu. Then click Save
Your VPN should now connect automatically whenever the selected wireless network is connected (if you use more than one wireless network you'll need to create a new tab in the preferences menu for each one you want to auto connect to a VPN whilst you are using).
You can create a local policy for one or more users.
Create the document where the settings will live...
touch /var/lib/polkit-1/localauthority/50-local.d/10-network-manager.pkla
Add one or more policies...
[Let foo modify system settings for network]
Identity=unix-user:foo
Action=org.freedesktop.NetworkManager.settings.modify.system
ResultAny=no
ResultInactive=no
ResultActive=yes
[Do not allow foo to enable/disable networking]
Identity=unix-user:foo
Action=org.freedesktop.NetworkManager.settings.enable-disable-network
ResultAny=no
ResultInactive=no
ResultActive=no
The key is the ResultActive
element which can be set to yes, no, auth_admin, or auth_admin_keep where the latter two will require the password of another user with sudo privileges.
The Action
element defines what action will be allowed/disallowed or require authentication with a password. There are options like org.freedesktop.NetworkManager.enable-disable-network
for toggling network as enabled/disabled. You can see more options in the /usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy
file, just look for something like <action id="org.freedesktop.NetworkManager.enable-disable-network">
and read it's description.
You can also set all values with the *
wildcard...
[Prevent foo from modifying all network states and settings except with admin password]
Identity=unix-user:foo
Action=org.freedesktop.NetworkManager.*
ResultAny=no
ResultInactive=no
ResultActive=auth_admin_keep
This will require a password to make ANY change to network settings or state.
You can do this in a single command that could be included in a script...
sudo su -c 'printf "[Prevent foo from modifying all network states and settings]\nIdentity=unix-user:foo\nAction=org.freedesktop.NetworkManager.*\nResultAny=no\nResultInactive=no\nResultActive=auth_admin" > /var/lib/polkit-1/localauthority/50-local.d/10-network-manager.pkla'
References:
Best Answer
All of the following:
give nothing useful, so 2 possibilities left:
You do a feature-request at Canonical (24,557 reputation, 28 gold 118 silver and 248 bronze badges should carry some weight...)
I create a script that creates a script that sets it up for you... (might take a while as I'm writing an automated system backup now...)