How can I have my VPN connect automatically when the wireless connects?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
10
down vote

favorite
3












I have a working VPN connection using NetworkManager, OpenConnect, and the network-manager-openconnect-gnome package, but I have to start it manually every time I connect to a network, and I have to enter my password manually each time.



How can I get it to connect automatically, and remember my password (securely)?



I have checked the 'Connect Automatically' box on the Configure VPN page, but this seems to have no effect. I've also got the 'Start connecting automatically' box checked in the pop-up box, and that does avoid the need to press the connect button in that window, but seems to have no part in kicking off the whole process in the first place. There is no option to remember the password in the window, but maybe there's one somewhere else?







share|improve this question


























    up vote
    10
    down vote

    favorite
    3












    I have a working VPN connection using NetworkManager, OpenConnect, and the network-manager-openconnect-gnome package, but I have to start it manually every time I connect to a network, and I have to enter my password manually each time.



    How can I get it to connect automatically, and remember my password (securely)?



    I have checked the 'Connect Automatically' box on the Configure VPN page, but this seems to have no effect. I've also got the 'Start connecting automatically' box checked in the pop-up box, and that does avoid the need to press the connect button in that window, but seems to have no part in kicking off the whole process in the first place. There is no option to remember the password in the window, but maybe there's one somewhere else?







    share|improve this question
























      up vote
      10
      down vote

      favorite
      3









      up vote
      10
      down vote

      favorite
      3






      3





      I have a working VPN connection using NetworkManager, OpenConnect, and the network-manager-openconnect-gnome package, but I have to start it manually every time I connect to a network, and I have to enter my password manually each time.



      How can I get it to connect automatically, and remember my password (securely)?



      I have checked the 'Connect Automatically' box on the Configure VPN page, but this seems to have no effect. I've also got the 'Start connecting automatically' box checked in the pop-up box, and that does avoid the need to press the connect button in that window, but seems to have no part in kicking off the whole process in the first place. There is no option to remember the password in the window, but maybe there's one somewhere else?







      share|improve this question














      I have a working VPN connection using NetworkManager, OpenConnect, and the network-manager-openconnect-gnome package, but I have to start it manually every time I connect to a network, and I have to enter my password manually each time.



      How can I get it to connect automatically, and remember my password (securely)?



      I have checked the 'Connect Automatically' box on the Configure VPN page, but this seems to have no effect. I've also got the 'Start connecting automatically' box checked in the pop-up box, and that does avoid the need to press the connect button in that window, but seems to have no part in kicking off the whole process in the first place. There is no option to remember the password in the window, but maybe there's one somewhere else?









      share|improve this question













      share|improve this question




      share|improve this question








      edited May 27 '12 at 18:32









      coversnail

      4,608133369




      4,608133369










      asked Dec 9 '11 at 9:26









      ams

      2,3601126




      2,3601126




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          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:

          enter image description here



          • Download the appropriate .deb file from the
            download page: http://sourceforge.net/projects/vpnautoconnect/files/
            (ending in amd64 for 64bit, ending in i386 for 32bit).

          • Double click the downloaded .deb file and install it.

          • Run the VPNautoconnect application

          enter image description here



          • Select Preferences from the VPNautoconnect menu

          enter image description here



          • 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

          enter image description here



          enter image description here



          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).






          share|improve this answer






















          • Works great! Thanks.
            – ams
            May 29 '12 at 2:07






          • 1




            I really like that swirly blur effect. +1 for that and a good answer!
            – jrg♦
            Jun 8 '12 at 10:59






          • 1




            I followed your directions, and it worked. Now my VPN connection automatically attempts to reconnect. However, my password is not saved. How do you save the VPN password? I have found no relevant documentation with a clear answer after extensive Google searching for many hours.
            – Kamil Slowikowski
            May 19 '14 at 17:44


















          up vote
          1
          down vote













          In Ubuntu Gnome 16.04, I can't find in Network Connections the GUI option to edit per-network VPN settings. The solution for me was to launch the "Network Connections" panel manually in the terminal by typing:



          nm-connection-editor



          then edit the desired network and add a VPN connection to it.






          share|improve this answer




















          • This worked for me on Arch Linux using Gnome, thanks for sharing this.
            – Elliott Minns
            Jul 4 at 13:35

















          up vote
          0
          down vote













          On 18.04, and some previous version also, there is not even a GUI settings to automatically enable a VPN connection now.



          So instead, I enable automatic connection to ethernet and then setup the VPN connection with an autostart config file and script.



          Add a vpn.desktop file in ~/.config/autostart with the following content



          [Desktop Entry]
          Name=Start VPN connection
          GenericName=Network helper
          Comment=Start automatically VPN connection
          Exec=/home/me/bin/vpn-start.sh
          Terminal=false
          Type=Application
          Icon=network-vpn
          Categories=Network;
          StartupNotify=false
          X-GNOME-Autostart-enabled=true


          This will call a file that you can put everywhere, but I have put in in /home/me/bin/ and call it vpn-start.sh



          #/bin/bash
          LANG=C
          while ! nmcli dev status|grep -q connected; do
          sleep 1
          done
          exec nmcli con up '<name of your vpn connection>'


          You need to put the name of your VPN connection. Look for it in the output of nmcli con show.



          Make it executable with chmox +x vpn-start.sh.



          And logout-relogin to test for it.






          share|improve this answer




















          • Via askubuntu.com/questions/1033278/… I found that I could use nm-connection-editor in Ubuntu 18.04 to set "Automatically connect to VPN when using this connection" under the "General" tab for the connection(s) in question. No more manually running vpn-start.sh!
            – Chris Burgess
            Jun 21 at 3:23











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f86365%2fhow-can-i-have-my-vpn-connect-automatically-when-the-wireless-connects%23new-answer', 'question_page');

          );

          Post as a guest






























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          5
          down vote



          accepted










          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:

          enter image description here



          • Download the appropriate .deb file from the
            download page: http://sourceforge.net/projects/vpnautoconnect/files/
            (ending in amd64 for 64bit, ending in i386 for 32bit).

          • Double click the downloaded .deb file and install it.

          • Run the VPNautoconnect application

          enter image description here



          • Select Preferences from the VPNautoconnect menu

          enter image description here



          • 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

          enter image description here



          enter image description here



          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).






          share|improve this answer






















          • Works great! Thanks.
            – ams
            May 29 '12 at 2:07






          • 1




            I really like that swirly blur effect. +1 for that and a good answer!
            – jrg♦
            Jun 8 '12 at 10:59






          • 1




            I followed your directions, and it worked. Now my VPN connection automatically attempts to reconnect. However, my password is not saved. How do you save the VPN password? I have found no relevant documentation with a clear answer after extensive Google searching for many hours.
            – Kamil Slowikowski
            May 19 '14 at 17:44















          up vote
          5
          down vote



          accepted










          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:

          enter image description here



          • Download the appropriate .deb file from the
            download page: http://sourceforge.net/projects/vpnautoconnect/files/
            (ending in amd64 for 64bit, ending in i386 for 32bit).

          • Double click the downloaded .deb file and install it.

          • Run the VPNautoconnect application

          enter image description here



          • Select Preferences from the VPNautoconnect menu

          enter image description here



          • 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

          enter image description here



          enter image description here



          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).






          share|improve this answer






















          • Works great! Thanks.
            – ams
            May 29 '12 at 2:07






          • 1




            I really like that swirly blur effect. +1 for that and a good answer!
            – jrg♦
            Jun 8 '12 at 10:59






          • 1




            I followed your directions, and it worked. Now my VPN connection automatically attempts to reconnect. However, my password is not saved. How do you save the VPN password? I have found no relevant documentation with a clear answer after extensive Google searching for many hours.
            – Kamil Slowikowski
            May 19 '14 at 17:44













          up vote
          5
          down vote



          accepted







          up vote
          5
          down vote



          accepted






          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:

          enter image description here



          • Download the appropriate .deb file from the
            download page: http://sourceforge.net/projects/vpnautoconnect/files/
            (ending in amd64 for 64bit, ending in i386 for 32bit).

          • Double click the downloaded .deb file and install it.

          • Run the VPNautoconnect application

          enter image description here



          • Select Preferences from the VPNautoconnect menu

          enter image description here



          • 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

          enter image description here



          enter image description here



          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).






          share|improve this answer














          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:

          enter image description here



          • Download the appropriate .deb file from the
            download page: http://sourceforge.net/projects/vpnautoconnect/files/
            (ending in amd64 for 64bit, ending in i386 for 32bit).

          • Double click the downloaded .deb file and install it.

          • Run the VPNautoconnect application

          enter image description here



          • Select Preferences from the VPNautoconnect menu

          enter image description here



          • 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

          enter image description here



          enter image description here



          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).







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 8 '12 at 10:35

























          answered May 26 '12 at 22:01









          coversnail

          4,608133369




          4,608133369











          • Works great! Thanks.
            – ams
            May 29 '12 at 2:07






          • 1




            I really like that swirly blur effect. +1 for that and a good answer!
            – jrg♦
            Jun 8 '12 at 10:59






          • 1




            I followed your directions, and it worked. Now my VPN connection automatically attempts to reconnect. However, my password is not saved. How do you save the VPN password? I have found no relevant documentation with a clear answer after extensive Google searching for many hours.
            – Kamil Slowikowski
            May 19 '14 at 17:44

















          • Works great! Thanks.
            – ams
            May 29 '12 at 2:07






          • 1




            I really like that swirly blur effect. +1 for that and a good answer!
            – jrg♦
            Jun 8 '12 at 10:59






          • 1




            I followed your directions, and it worked. Now my VPN connection automatically attempts to reconnect. However, my password is not saved. How do you save the VPN password? I have found no relevant documentation with a clear answer after extensive Google searching for many hours.
            – Kamil Slowikowski
            May 19 '14 at 17:44
















          Works great! Thanks.
          – ams
          May 29 '12 at 2:07




          Works great! Thanks.
          – ams
          May 29 '12 at 2:07




          1




          1




          I really like that swirly blur effect. +1 for that and a good answer!
          – jrg♦
          Jun 8 '12 at 10:59




          I really like that swirly blur effect. +1 for that and a good answer!
          – jrg♦
          Jun 8 '12 at 10:59




          1




          1




          I followed your directions, and it worked. Now my VPN connection automatically attempts to reconnect. However, my password is not saved. How do you save the VPN password? I have found no relevant documentation with a clear answer after extensive Google searching for many hours.
          – Kamil Slowikowski
          May 19 '14 at 17:44





          I followed your directions, and it worked. Now my VPN connection automatically attempts to reconnect. However, my password is not saved. How do you save the VPN password? I have found no relevant documentation with a clear answer after extensive Google searching for many hours.
          – Kamil Slowikowski
          May 19 '14 at 17:44













          up vote
          1
          down vote













          In Ubuntu Gnome 16.04, I can't find in Network Connections the GUI option to edit per-network VPN settings. The solution for me was to launch the "Network Connections" panel manually in the terminal by typing:



          nm-connection-editor



          then edit the desired network and add a VPN connection to it.






          share|improve this answer




















          • This worked for me on Arch Linux using Gnome, thanks for sharing this.
            – Elliott Minns
            Jul 4 at 13:35














          up vote
          1
          down vote













          In Ubuntu Gnome 16.04, I can't find in Network Connections the GUI option to edit per-network VPN settings. The solution for me was to launch the "Network Connections" panel manually in the terminal by typing:



          nm-connection-editor



          then edit the desired network and add a VPN connection to it.






          share|improve this answer




















          • This worked for me on Arch Linux using Gnome, thanks for sharing this.
            – Elliott Minns
            Jul 4 at 13:35












          up vote
          1
          down vote










          up vote
          1
          down vote









          In Ubuntu Gnome 16.04, I can't find in Network Connections the GUI option to edit per-network VPN settings. The solution for me was to launch the "Network Connections" panel manually in the terminal by typing:



          nm-connection-editor



          then edit the desired network and add a VPN connection to it.






          share|improve this answer












          In Ubuntu Gnome 16.04, I can't find in Network Connections the GUI option to edit per-network VPN settings. The solution for me was to launch the "Network Connections" panel manually in the terminal by typing:



          nm-connection-editor



          then edit the desired network and add a VPN connection to it.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 8 at 13:35









          Meetai.com

          21026




          21026











          • This worked for me on Arch Linux using Gnome, thanks for sharing this.
            – Elliott Minns
            Jul 4 at 13:35
















          • This worked for me on Arch Linux using Gnome, thanks for sharing this.
            – Elliott Minns
            Jul 4 at 13:35















          This worked for me on Arch Linux using Gnome, thanks for sharing this.
          – Elliott Minns
          Jul 4 at 13:35




          This worked for me on Arch Linux using Gnome, thanks for sharing this.
          – Elliott Minns
          Jul 4 at 13:35










          up vote
          0
          down vote













          On 18.04, and some previous version also, there is not even a GUI settings to automatically enable a VPN connection now.



          So instead, I enable automatic connection to ethernet and then setup the VPN connection with an autostart config file and script.



          Add a vpn.desktop file in ~/.config/autostart with the following content



          [Desktop Entry]
          Name=Start VPN connection
          GenericName=Network helper
          Comment=Start automatically VPN connection
          Exec=/home/me/bin/vpn-start.sh
          Terminal=false
          Type=Application
          Icon=network-vpn
          Categories=Network;
          StartupNotify=false
          X-GNOME-Autostart-enabled=true


          This will call a file that you can put everywhere, but I have put in in /home/me/bin/ and call it vpn-start.sh



          #/bin/bash
          LANG=C
          while ! nmcli dev status|grep -q connected; do
          sleep 1
          done
          exec nmcli con up '<name of your vpn connection>'


          You need to put the name of your VPN connection. Look for it in the output of nmcli con show.



          Make it executable with chmox +x vpn-start.sh.



          And logout-relogin to test for it.






          share|improve this answer




















          • Via askubuntu.com/questions/1033278/… I found that I could use nm-connection-editor in Ubuntu 18.04 to set "Automatically connect to VPN when using this connection" under the "General" tab for the connection(s) in question. No more manually running vpn-start.sh!
            – Chris Burgess
            Jun 21 at 3:23















          up vote
          0
          down vote













          On 18.04, and some previous version also, there is not even a GUI settings to automatically enable a VPN connection now.



          So instead, I enable automatic connection to ethernet and then setup the VPN connection with an autostart config file and script.



          Add a vpn.desktop file in ~/.config/autostart with the following content



          [Desktop Entry]
          Name=Start VPN connection
          GenericName=Network helper
          Comment=Start automatically VPN connection
          Exec=/home/me/bin/vpn-start.sh
          Terminal=false
          Type=Application
          Icon=network-vpn
          Categories=Network;
          StartupNotify=false
          X-GNOME-Autostart-enabled=true


          This will call a file that you can put everywhere, but I have put in in /home/me/bin/ and call it vpn-start.sh



          #/bin/bash
          LANG=C
          while ! nmcli dev status|grep -q connected; do
          sleep 1
          done
          exec nmcli con up '<name of your vpn connection>'


          You need to put the name of your VPN connection. Look for it in the output of nmcli con show.



          Make it executable with chmox +x vpn-start.sh.



          And logout-relogin to test for it.






          share|improve this answer




















          • Via askubuntu.com/questions/1033278/… I found that I could use nm-connection-editor in Ubuntu 18.04 to set "Automatically connect to VPN when using this connection" under the "General" tab for the connection(s) in question. No more manually running vpn-start.sh!
            – Chris Burgess
            Jun 21 at 3:23













          up vote
          0
          down vote










          up vote
          0
          down vote









          On 18.04, and some previous version also, there is not even a GUI settings to automatically enable a VPN connection now.



          So instead, I enable automatic connection to ethernet and then setup the VPN connection with an autostart config file and script.



          Add a vpn.desktop file in ~/.config/autostart with the following content



          [Desktop Entry]
          Name=Start VPN connection
          GenericName=Network helper
          Comment=Start automatically VPN connection
          Exec=/home/me/bin/vpn-start.sh
          Terminal=false
          Type=Application
          Icon=network-vpn
          Categories=Network;
          StartupNotify=false
          X-GNOME-Autostart-enabled=true


          This will call a file that you can put everywhere, but I have put in in /home/me/bin/ and call it vpn-start.sh



          #/bin/bash
          LANG=C
          while ! nmcli dev status|grep -q connected; do
          sleep 1
          done
          exec nmcli con up '<name of your vpn connection>'


          You need to put the name of your VPN connection. Look for it in the output of nmcli con show.



          Make it executable with chmox +x vpn-start.sh.



          And logout-relogin to test for it.






          share|improve this answer












          On 18.04, and some previous version also, there is not even a GUI settings to automatically enable a VPN connection now.



          So instead, I enable automatic connection to ethernet and then setup the VPN connection with an autostart config file and script.



          Add a vpn.desktop file in ~/.config/autostart with the following content



          [Desktop Entry]
          Name=Start VPN connection
          GenericName=Network helper
          Comment=Start automatically VPN connection
          Exec=/home/me/bin/vpn-start.sh
          Terminal=false
          Type=Application
          Icon=network-vpn
          Categories=Network;
          StartupNotify=false
          X-GNOME-Autostart-enabled=true


          This will call a file that you can put everywhere, but I have put in in /home/me/bin/ and call it vpn-start.sh



          #/bin/bash
          LANG=C
          while ! nmcli dev status|grep -q connected; do
          sleep 1
          done
          exec nmcli con up '<name of your vpn connection>'


          You need to put the name of your VPN connection. Look for it in the output of nmcli con show.



          Make it executable with chmox +x vpn-start.sh.



          And logout-relogin to test for it.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 8 at 14:14









          solsTiCe

          4,90221642




          4,90221642











          • Via askubuntu.com/questions/1033278/… I found that I could use nm-connection-editor in Ubuntu 18.04 to set "Automatically connect to VPN when using this connection" under the "General" tab for the connection(s) in question. No more manually running vpn-start.sh!
            – Chris Burgess
            Jun 21 at 3:23

















          • Via askubuntu.com/questions/1033278/… I found that I could use nm-connection-editor in Ubuntu 18.04 to set "Automatically connect to VPN when using this connection" under the "General" tab for the connection(s) in question. No more manually running vpn-start.sh!
            – Chris Burgess
            Jun 21 at 3:23
















          Via askubuntu.com/questions/1033278/… I found that I could use nm-connection-editor in Ubuntu 18.04 to set "Automatically connect to VPN when using this connection" under the "General" tab for the connection(s) in question. No more manually running vpn-start.sh!
          – Chris Burgess
          Jun 21 at 3:23





          Via askubuntu.com/questions/1033278/… I found that I could use nm-connection-editor in Ubuntu 18.04 to set "Automatically connect to VPN when using this connection" under the "General" tab for the connection(s) in question. No more manually running vpn-start.sh!
          – Chris Burgess
          Jun 21 at 3:23













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f86365%2fhow-can-i-have-my-vpn-connect-automatically-when-the-wireless-connects%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          pylint3 and pip3 broken

          Missing snmpget and snmpwalk

          How to enroll fingerprints to Ubuntu 17.10 with VFS491