How to autostart OpenVPN (client) on Ubuntu 12.04 CLI?












3














I have an *.ovpn file that works if I type in: sudo openvpn filename.ovpn.



Now I would like to start up OpenVPN when I boot the computer. It's a headless version of Ubuntu 12.04 64-bit if that matters.



I copied filename.ovpn to /etc/openvpn, but it's not starting, even if I run: service openvpn start.



How can I do this?










share|improve this question
























  • see: upstart.ubuntu.com/getting-started.html
    – mbx
    Dec 17 '12 at 8:12










  • Have you tried naming your file client.conf?
    – user2313067
    Feb 18 '14 at 8:52
















3














I have an *.ovpn file that works if I type in: sudo openvpn filename.ovpn.



Now I would like to start up OpenVPN when I boot the computer. It's a headless version of Ubuntu 12.04 64-bit if that matters.



I copied filename.ovpn to /etc/openvpn, but it's not starting, even if I run: service openvpn start.



How can I do this?










share|improve this question
























  • see: upstart.ubuntu.com/getting-started.html
    – mbx
    Dec 17 '12 at 8:12










  • Have you tried naming your file client.conf?
    – user2313067
    Feb 18 '14 at 8:52














3












3








3







I have an *.ovpn file that works if I type in: sudo openvpn filename.ovpn.



Now I would like to start up OpenVPN when I boot the computer. It's a headless version of Ubuntu 12.04 64-bit if that matters.



I copied filename.ovpn to /etc/openvpn, but it's not starting, even if I run: service openvpn start.



How can I do this?










share|improve this question















I have an *.ovpn file that works if I type in: sudo openvpn filename.ovpn.



Now I would like to start up OpenVPN when I boot the computer. It's a headless version of Ubuntu 12.04 64-bit if that matters.



I copied filename.ovpn to /etc/openvpn, but it's not starting, even if I run: service openvpn start.



How can I do this?







linux ubuntu openvpn






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '13 at 10:59









karel

9,18793138




9,18793138










asked Dec 17 '12 at 3:43









waspinator

13115




13115












  • see: upstart.ubuntu.com/getting-started.html
    – mbx
    Dec 17 '12 at 8:12










  • Have you tried naming your file client.conf?
    – user2313067
    Feb 18 '14 at 8:52


















  • see: upstart.ubuntu.com/getting-started.html
    – mbx
    Dec 17 '12 at 8:12










  • Have you tried naming your file client.conf?
    – user2313067
    Feb 18 '14 at 8:52
















see: upstart.ubuntu.com/getting-started.html
– mbx
Dec 17 '12 at 8:12




see: upstart.ubuntu.com/getting-started.html
– mbx
Dec 17 '12 at 8:12












Have you tried naming your file client.conf?
– user2313067
Feb 18 '14 at 8:52




Have you tried naming your file client.conf?
– user2313067
Feb 18 '14 at 8:52










2 Answers
2






active

oldest

votes


















1














It would be nice to have a un hacker way of doing it, but this will have to do for now.



1) Create file myopenvpn in /etc/init.d/



nano /etc/init.d/myopenvpn


2) Insert into myopenvpn and save:



# OpenVPN autostart on boot script

start on runlevel [2345]
stop on runlevel [!2345]

respawn

exec /usr/sbin/openvpn --status /var/run/openvpn.client.status 10 --cd /etc/openvpn --config /etc/openvpn/client.conf --syslog openvpn


SOURCE: http://www.hackerway.ch/2012/12/11/how-to-auto-start-openvpn-client-in-debian-6-and-ubuntu-12-04/#comment-79






share|improve this answer





























    1















    1. Ubuntu is derived from Debian. Debian has a manual page about this: https://wiki.debian.org/OpenVPN#Auto-start


    2. They both have a README file installed with the openvpn package. That file says, how and where to place configs for autostart to work, but it has instructions for old init system and is misleading for systems with systemd.



    Configs should be put into /etc/openvpn/filename.conf, not .ovpn.



    On the new systems please make use of systemd cloned service. To enable (autostart) service with configuration /etc/openvpn/filename.conf do:



    systemctl enable openvpn@filename.service


    Then you work with newly created service as usual.



    On the old Debian (pre-systemd) by default "openvpn" service tries to run them all. /etc/default/openvpn could be used to select which configurations to execute by default.



    This applies equally to all "peer-to-peer", "client" and "server" openvpn deployment variants.






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      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',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f520286%2fhow-to-autostart-openvpn-client-on-ubuntu-12-04-cli%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      It would be nice to have a un hacker way of doing it, but this will have to do for now.



      1) Create file myopenvpn in /etc/init.d/



      nano /etc/init.d/myopenvpn


      2) Insert into myopenvpn and save:



      # OpenVPN autostart on boot script

      start on runlevel [2345]
      stop on runlevel [!2345]

      respawn

      exec /usr/sbin/openvpn --status /var/run/openvpn.client.status 10 --cd /etc/openvpn --config /etc/openvpn/client.conf --syslog openvpn


      SOURCE: http://www.hackerway.ch/2012/12/11/how-to-auto-start-openvpn-client-in-debian-6-and-ubuntu-12-04/#comment-79






      share|improve this answer


























        1














        It would be nice to have a un hacker way of doing it, but this will have to do for now.



        1) Create file myopenvpn in /etc/init.d/



        nano /etc/init.d/myopenvpn


        2) Insert into myopenvpn and save:



        # OpenVPN autostart on boot script

        start on runlevel [2345]
        stop on runlevel [!2345]

        respawn

        exec /usr/sbin/openvpn --status /var/run/openvpn.client.status 10 --cd /etc/openvpn --config /etc/openvpn/client.conf --syslog openvpn


        SOURCE: http://www.hackerway.ch/2012/12/11/how-to-auto-start-openvpn-client-in-debian-6-and-ubuntu-12-04/#comment-79






        share|improve this answer
























          1












          1








          1






          It would be nice to have a un hacker way of doing it, but this will have to do for now.



          1) Create file myopenvpn in /etc/init.d/



          nano /etc/init.d/myopenvpn


          2) Insert into myopenvpn and save:



          # OpenVPN autostart on boot script

          start on runlevel [2345]
          stop on runlevel [!2345]

          respawn

          exec /usr/sbin/openvpn --status /var/run/openvpn.client.status 10 --cd /etc/openvpn --config /etc/openvpn/client.conf --syslog openvpn


          SOURCE: http://www.hackerway.ch/2012/12/11/how-to-auto-start-openvpn-client-in-debian-6-and-ubuntu-12-04/#comment-79






          share|improve this answer












          It would be nice to have a un hacker way of doing it, but this will have to do for now.



          1) Create file myopenvpn in /etc/init.d/



          nano /etc/init.d/myopenvpn


          2) Insert into myopenvpn and save:



          # OpenVPN autostart on boot script

          start on runlevel [2345]
          stop on runlevel [!2345]

          respawn

          exec /usr/sbin/openvpn --status /var/run/openvpn.client.status 10 --cd /etc/openvpn --config /etc/openvpn/client.conf --syslog openvpn


          SOURCE: http://www.hackerway.ch/2012/12/11/how-to-auto-start-openvpn-client-in-debian-6-and-ubuntu-12-04/#comment-79







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 17 '12 at 4:32









          waspinator

          13115




          13115

























              1















              1. Ubuntu is derived from Debian. Debian has a manual page about this: https://wiki.debian.org/OpenVPN#Auto-start


              2. They both have a README file installed with the openvpn package. That file says, how and where to place configs for autostart to work, but it has instructions for old init system and is misleading for systems with systemd.



              Configs should be put into /etc/openvpn/filename.conf, not .ovpn.



              On the new systems please make use of systemd cloned service. To enable (autostart) service with configuration /etc/openvpn/filename.conf do:



              systemctl enable openvpn@filename.service


              Then you work with newly created service as usual.



              On the old Debian (pre-systemd) by default "openvpn" service tries to run them all. /etc/default/openvpn could be used to select which configurations to execute by default.



              This applies equally to all "peer-to-peer", "client" and "server" openvpn deployment variants.






              share|improve this answer




























                1















                1. Ubuntu is derived from Debian. Debian has a manual page about this: https://wiki.debian.org/OpenVPN#Auto-start


                2. They both have a README file installed with the openvpn package. That file says, how and where to place configs for autostart to work, but it has instructions for old init system and is misleading for systems with systemd.



                Configs should be put into /etc/openvpn/filename.conf, not .ovpn.



                On the new systems please make use of systemd cloned service. To enable (autostart) service with configuration /etc/openvpn/filename.conf do:



                systemctl enable openvpn@filename.service


                Then you work with newly created service as usual.



                On the old Debian (pre-systemd) by default "openvpn" service tries to run them all. /etc/default/openvpn could be used to select which configurations to execute by default.



                This applies equally to all "peer-to-peer", "client" and "server" openvpn deployment variants.






                share|improve this answer


























                  1












                  1








                  1







                  1. Ubuntu is derived from Debian. Debian has a manual page about this: https://wiki.debian.org/OpenVPN#Auto-start


                  2. They both have a README file installed with the openvpn package. That file says, how and where to place configs for autostart to work, but it has instructions for old init system and is misleading for systems with systemd.



                  Configs should be put into /etc/openvpn/filename.conf, not .ovpn.



                  On the new systems please make use of systemd cloned service. To enable (autostart) service with configuration /etc/openvpn/filename.conf do:



                  systemctl enable openvpn@filename.service


                  Then you work with newly created service as usual.



                  On the old Debian (pre-systemd) by default "openvpn" service tries to run them all. /etc/default/openvpn could be used to select which configurations to execute by default.



                  This applies equally to all "peer-to-peer", "client" and "server" openvpn deployment variants.






                  share|improve this answer















                  1. Ubuntu is derived from Debian. Debian has a manual page about this: https://wiki.debian.org/OpenVPN#Auto-start


                  2. They both have a README file installed with the openvpn package. That file says, how and where to place configs for autostart to work, but it has instructions for old init system and is misleading for systems with systemd.



                  Configs should be put into /etc/openvpn/filename.conf, not .ovpn.



                  On the new systems please make use of systemd cloned service. To enable (autostart) service with configuration /etc/openvpn/filename.conf do:



                  systemctl enable openvpn@filename.service


                  Then you work with newly created service as usual.



                  On the old Debian (pre-systemd) by default "openvpn" service tries to run them all. /etc/default/openvpn could be used to select which configurations to execute by default.



                  This applies equally to all "peer-to-peer", "client" and "server" openvpn deployment variants.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 27 '18 at 9:34

























                  answered Dec 6 '15 at 6:29









                  Nikita Kipriyanov

                  30319




                  30319






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f520286%2fhow-to-autostart-openvpn-client-on-ubuntu-12-04-cli%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      QoS: MAC-Priority for clients behind a repeater

                      Ивакино (Тотемский район)

                      Can't locate Autom4te/ChannelDefs.pm in @INC (when it definitely is there)