{"id":2904,"date":"2014-03-10T12:22:58","date_gmt":"2014-03-10T12:22:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/10\/error-when-trying-to-connect-to-vpn-on-startup-collection-of-common-programming-errors\/"},"modified":"2014-03-10T12:22:58","modified_gmt":"2014-03-10T12:22:58","slug":"error-when-trying-to-connect-to-vpn-on-startup-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/10\/error-when-trying-to-connect-to-vpn-on-startup-collection-of-common-programming-errors\/","title":{"rendered":"Error when trying to connect to VPN on startup-Collection of common programming errors"},"content":{"rendered":"<p><em><strong>This question has been updated. Please see the tail end of this post.<\/strong><\/em><\/p>\n<p>I am trying to set up my Mythbuntu computer to connect to a VPN service when it starts up. My hope is that the Mythbuntu computer will always use the VPN for all of its internet connections.<\/p>\n<p>I found a script that will supposedly do that, and it looks like this:<\/p>\n<pre><code>#!\/bin\/bash\nwhile [ \"true\" ]\ndo\n    VPNCON=$(nmcli con status)\n    if [[ $VPNCON != \"*MyVPNConnectionName*\" ]]; then\n        echo \"Disconnected, trying to reconnect...\"\n        (sleep 1s &amp;&amp; nmcli con up uuid df648abc-d8f7-4ce4-bdd6-3e12cdf0f494)\n    else\n        echo \"Already connected !\"\n    fi\n    sleep 30\ndone\n<\/code><\/pre>\n<p>When I run this script on my machine, I get the following error:<\/p>\n<pre><code>$ \/home\/mythbuntu\/VPN_start.sh\nDisconnected, trying to reconnect...\nError: Connection activation failed: Not authorized to control networking.\n<\/code><\/pre>\n<p>I thought it might be a permission issue, so I tried running it with sudo:<\/p>\n<pre><code>$ sudo \/home\/mythbuntu\/VPN_start.sh\n[sudo] password for mythbuntu: \nDisconnected, trying to reconnect...\nActive connection state: unknown\nActive connection path: \/org\/freedesktop\/NetworkManager\/ActiveConnection\/1\nstate: VPN connecting (need authentication) (2)\nError: Connection activation failed: no valid VPN secrets.\n<\/code><\/pre>\n<p>How do I get this script to run without errors so that I can run it at boot or login so that I can make sure I&#8217;m always connecting by VPN.<\/p>\n<p>If anyone has a better script or method, that would also suffice as an answer.<\/p>\n<p>These are the contents of my \/etc\/NetworkManager\/system-connections\/MyVPN file (some details replaced with x characters for privacy):<\/p>\n<pre><code>[connection]\nid=MyVPN\nuuid=xxxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxxx\ntype=vpn\n\n[vpn]\nservice-type=org.xxxxxxxxxxxxxx.xxxxxxxxxxxxxxx.openvpn\nusername=xxxxxxxxxx\ncomp-lzo=yes\nremote=us-xxxxxx.xxxxxxx.com\nconnection-type=password\npassword-flags=0\nca=\/etc\/openvpn\/xxxxxxx.crt\n\n[vpn-secrets]\npassword=xxxxxxxxxxx\n\n[ipv4]\nmethod=auto\nnever-default=true\n<\/code><\/pre>\n<p>Also, I just want to add that when I turn on the VPN using the applet in top right corner the Xfce panel, it connects no problem. So the issue doesn&#8217;t seem to me to be one of incorrect authorization, but of the configuration when trying to do this from the command line.<\/p>\n<h2>Update:<\/h2>\n<p>I&#8217;m not entirely sure what has changed &#8211; possibly something in the upgrade to 12.10 &#8211; but I can now start my VPN service from the command line. However, this command only works once when I very first start the computer, and also it needs to be run with <code>sudo<\/code>.<\/p>\n<pre><code>mythbuntu@mythbuntu:~$ nmcli con up id \"Private Internet Access SSL\"\nError: Connection activation failed: Not authorized to control networking.\nmythbuntu@mythbuntu:~$ sudo nmcli con up id \"Private Internet Access SSL\"\n[sudo] password for mythbuntu: \nmythbuntu@mythbuntu:~$\n<\/code><\/pre>\n<p>Since I need to use <code>sudo<\/code> to run this, I can&#8217;t run it automatically at startup.<\/p>\n<p>How do I get it so that I can start my VPN without super user permissions?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This question has been updated. Please see the tail end of this post. I am trying to set up my Mythbuntu computer to connect to a VPN service when it starts up. My hope is that the Mythbuntu computer will always use the VPN for all of its internet connections. I found a script that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2904","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2904"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2904\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}