How to disconnect from OpenVPN?

I'm connecting using VPNBook servers and it works fine with this command:

 sudo openvpn --config /etc/openvpn/vpnbook-udp-53.ovpn --auth-user-pass /etc/openvpn/password.txt

but I just can't seem to figure out how to stop it without a reboot.

I've tried service openvpn stop and /etc/init.d/vpnbook stop, but that doesn't seem to affect it.


This command definitely works for me, and it should work for you too.

sudo killall openvpn

I had same problem with disconnecting from openvpn3

I end up creating this small repo https://github.com/shmalex/openvpn3_manager that helps manage the openvpn3 sessions

To disconnect the session, you have know the session's Path

openvpn3 session-manage --session-path $OPENVPN3_SESSION_PATH --disconnect

the session path could be found via

openvpn3 sessions-list

> -----------------------------------------------------------------------------
>         Path: /net/openvpn/v3/sessions/7a42f37asc8d9s424c8b534sd331d6dd56e8
>      Created: Tue Dec  8 10:44:57 2020                  PID: 9495
>        Owner: shmalex                                Device: tun0
>  Config name: client.ovpn  (Config not available)
> Session name: ***.***.***.***
>       Status: Connection, Client connected
> -----------------------------------------------------------------------------
OPENVPN3_SESSION_PATH=/net/openvpn/v3/sessions/7a42f37asc8d9s424c8b534sd331d6dd56e8
openvpn3 session-manage --session-path $OPENVPN3_SESSION_PATH --disconnect

You can use my repo to perform same actions with help of bash files.


The successful steps in my case were:

# stop the service    
$ sudo /etc/init.d/openvpn stop

# find the process if it is still running for some reason
$ lsof -i | grep openvpn

# kill the proccess(s) by its PID
$ kill -9 <PID>

# if necessary restart the service again
$ sudo /etc/init.d/openvpn start

For some reason `killall -SIGINT openvpn` did not work for me, but the steps above did.

Try this

killall -SIGINT openvpn

You can get more info on different signals you can send here: http://openvpn.net/index.php/open-source/documentation/howto.html#control