Linux – How to disconnect a forticlient VPN connection from a script

fortinetlinuxsslvpn

I need to make an bash script on Linux that connects into an VPN, processes some tasks, and then disconnects.

To connect to the VPN I use the forticlient ssl vpn (like fortinet but for VPN instead). For example:

./forticlientsslvpn_cli --server 172.17.97.85:10443 --vpnuser forti

Does any know the how to then disconnect from a script afterwards?

Best Answer

In your case, simply record a PID of the forticlientsslvpn_cli process and send it SIGHUP, SIGQUIT or SIGTERM. The preferred signal is the one that makes a graceful disconnect. A bit dirty solution (although maybe good enough for you) is to use just killall -s SIG... forticlientsslvpn_cli.

Fortigate devices also support Cisco-style IPsec connections and there're multiple software clients available for Linux, so replacing SSL VPN client may be another way to go.