介紹如何在 Linux 系統上使用 openfortivpn 指令工具連線至 Fortinet VPN 伺服器建立 PPP+SSL VPN。
openfortivpn 是一個相容於 Fortinet VPN 的 PPP+SSL VPN client 指令工具,在 Linux 中若需要連線至 Fortinet VPN 伺服器建立 PPP+SSL VPN,就可以使用 openfortivpn。
openfortivpn若在 Ubuntu Linux 中可用 apt 安裝 openfortivpn:
# 安裝 openfortivpn
sudo apt install openfortivpn
安裝好 openfortivpn 之後,即可使用以下指令稿建立 VPN 連線:
# Fortinet VPN 伺服器 VPN_GATEWAY=12.34.56.78:443 # 使用者名稱 USERNAME=officeguide # 建立 VPN 連線 sudo openfortivpn ${VPN_GATEWAY} --username=${USERNAME}
如果 VPN 伺服器的安全憑證有問題,可能會出現類似這樣的錯誤:
ERROR: Gateway certificate validation failed, and the certificate digest in not in the local whitelist. If you trust it, rerun with: ERROR: --trusted-cert fcf8010a3c12408e44fc3d949843b9fb16b46f26dcc5d179beff8f9600541bb5
如果確認 VPN 伺服器沒有問題,可以加上訊息中建議的 --trusted-cert 參數,讓 openfortivpn 信任該憑證:
# 建立 VPN 連線(信任指定憑證) sudo openfortivpn ${VPN_GATEWAY} --username=${USERNAME} \ --trusted-cert fcf8010a3c12408e44fc3d949843b9fb16b46f26dcc5d179beff8f9600541bb5
我們也可以將所有 openfortivpn 要用的參數寫在一個設定檔案中,其語法如下:
# Fortinet VPN 伺服器 host = 12.34.56.78 port = 443 # 使用者名稱與密碼 username = officeguide password = MY_PASSWORD # 信任指定憑證 trusted-cert = fcf8010a3c12408e44fc3d949843b9fb16b46f26dcc5d179beff8f9600541bb5
將這些設定儲存為 vpn.config 之後,在執行 openfortivpn 的時候以 -c 參數指定設定檔路徑:
# 指定設定檔 sudo openfortivpn -c vpn.config
openfortivpn 預設的設定檔路徑為 /etc/openfortivpn/config,如果直接把設定寫在這個檔案中,則執行就可以不加任何參數。
# 使用 /etc/openfortivpn/config 的設定
sudo openfortivpn