Skip to content

Instantly share code, notes, and snippets.

@Vadi
Created May 14, 2025 16:45
Show Gist options
  • Select an option

  • Save Vadi/fcf9580d71f921443fa0d01661a05bec to your computer and use it in GitHub Desktop.

Select an option

Save Vadi/fcf9580d71f921443fa0d01661a05bec to your computer and use it in GitHub Desktop.
Connecting to VPN using CLI

Installation

Mac

brew install openfortivpn

Ubuntu

sudo apt-get install openfortivpn

Configuration

Create a file in ~/.config/openfortivpn/config and paste below, but change values accordingly. If you don't have trusted-cert value, read below section.

host = vpn.xxx.co.in
port = 443
username = <username>
password = <password>
trusted-cert = <trusted_cert>
persistent = 30

Running VPN

> sudo openfortivpn -c ~/.config/openfortivpn/config

How to get trusted cert

Very first time when you run the sudo openfortivpn -c ~/.config/openfortivpn/config it will print certificate value, below output is from my first run

.venv ❯ sudo openfortivpn vpn.xxxxx.co.in:443 -u xxxx                                                   1
VPN account password:
ERROR:  Gateway certificate validation failed, and the certificate digest is not in the local whitelist. If you trust it, rerun with:
ERROR:      --trusted-cert 5e761a6181bf4ab5cff607335dc22b476d090274b34369d1a42a542eab158864
ERROR:  or add this line to your configuration file:

**>>>>>>>>> ERROR:      trusted-cert = 5e761a6181bf4ab5cff607335dc22b476d090274b34369d1a42a542eab158864**

ERROR:  Gateway certificate:
ERROR:      subject:
ERROR:          C=US
ERROR:          ST=California
ERROR:          L=Sunnyvale
ERROR:          O=xxx
ERROR:          OU=FortiGate
ERROR:          CN=vpn.xxx.co.in
ERROR:          emailAddress=xxx@xxx.com

Highlighted line above shows trusted-cert value that you can copy paste in config file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment