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