0

I am using OpenVPN on ubuntu like this sudo openvpn --config vpnconfig.ovpn --daemon

I am wondering is there a way to stop/disconnet OpenVPN connection I started without killing OpenVPN process?

2
  • What is your expectation at the end? For the process to remain? Why are you killing it in the first place? According to the documentation this should almost never be necessary. Or are you perhaps confusing signals in general with SIGKILL?
    – Daniel B
    Commented Mar 1 at 6:22
  • Because there can be more than one Openvpn instance running
    – Node.JS
    Commented Mar 1 at 13:59

1 Answer 1

1

The official documentation on controlling OpenVPN processes is pretty clear: You have to use signals. You would usually not use SIGKILL though.

On Linux, OpenVPN accepts the following signals:

  • SIGUSR1 -- Conditional restart, designed to restart without root privileges
  • SIGHUP -- Hard restart
  • SIGUSR2 -- Output connection statistics to log file or syslog
  • SIGTERM, SIGINT -- Exit

You’d issue them like kill -USR1 1234, where 1234 is the process ID of the process you want to control.

If the process is attached to a terminal, just hit Ctrl+C. This sends SIGINT to the foreground process.

If you have multiple OpenVPN processes just running in the background in an uncontrolled manner, perhaps consider managing these processes using Systemd or something like that. With Systemd, they could also be user services.

If that’s not your cup of tea, you could also use a tool like htop to interactively identify the process using its command line, then sending a signal directly.

Yet another possibility, also mentioned in the docs, is to use writepid /path/to/pid-file inside the OpenVPN config file or --writepid /path/to/pid-file on its command line. You would then read this file to find out the process ID.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .