Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an *.ovpn file that works if I type in

sudo openvpn client.ovpn

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

How can I do this?


share|improve this question
  1. Download the OpenVPNConfigFile.ovpn. Note that you can rename the file to anything you like.

  2. Move the oven file to /etc/openvpn

  3. cd /etc/openvpn folder and enter sudo nano yourserver.txt


    Save and Close

  4. sudo nano OpenVPNConfigFile.ovpn

    Find auth-user-pass and add yourserver.txt next to it so that it becomes

    auth-user-pass yourserver.txt

    This will allow you to skip entering your credentials everytime you start openvpn connection

  5. Rename OpenVPNConfigFile.ovpn to OpenVPNConfigFile.conf

    sudo mv OpenVPNConfigFile.ovpn OpenVPNConfigFile.conf
  6. sudo nano /etc/default/openvpn

    Uncomment AUTOSTART="all"

  7. sudo service openvpn start

    You should see a message saying that you are connected. The connection will be established every time you start your computer.

share|improve this answer
this should be the accepted answer – Thomas Browne Jun 6 at 9:37
up vote 2 down vote accepted

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]


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


share|improve this answer

The openvpn package comes with an init script /etc/init.d/openvpn. This script automatically sets up connection for every .conf (mind the extension) file in /etc/openvpn.

Found this based on information here:

If you install OpenVPN via an RPM or DEB package on Linux, the installer will set up an initscript. When executed, the initscript will scan for .conf configuration files in /etc/openvpn, and if found, will start up a separate OpenVPN daemon for each file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.