I have an Ubuntu 14.04 Server with an OpenVPN Server running on it. Now for backup purposes I want this machine to create a VPN connection to a seperate machine.

I figured out that I can create a new client instance using this code:

openvpn --config openvpn.ovpn --auth-user-pass auth --auth-nocache --nobind &

where "auth" is a file containing a username and password for the connection.

This seems work fine, but the problem is that I have no idea how to close the connection after it has been opened (I do not know if this is the best solution).

I only need the connection during a backup process and it is important that the VPN server stays active, so solutions like "killall" and "restart" are not an option.

The Ubuntu Server is running without a User Interface. So I can only use command line.


get ID of your process:

openvpn --config openvpn.ovpn --auth-user-pass auth --auth-nocache --nobind > /dev/null & pid=$!

Stop that process:

kill $pid

  • Definitely works for root. That should be fine. Thanks. – Florian Splett Mar 7 '16 at 13:26
  • Just one addition: Will the server and client get in each others way when doing this? – Florian Splett Mar 7 '16 at 13:32
  • only if you try to bind both to same interface (tap0 or tun0). make client to work in different subnet on another interface - and you can connect to as many server as you like. – Ivan Temchenko Mar 7 '16 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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