Linux

Linux 使用 openfortivpn 連線至 Fortinet VPN 伺服器建立 PPP+SSL VPN 教學與範例

介紹如何在 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

建立 VPN 連線

安裝好 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
Share
Published by
Office Guide
Tags: 資訊安全

Recent Posts

Python 使用 PyAutoGUI 自動操作滑鼠與鍵盤

本篇介紹如何在 Python ...

9 個月 ago

Ubuntu Linux 以 WireGuard 架設 VPN 伺服器教學與範例

本篇介紹如何在 Ubuntu ...

9 個月 ago

Linux 網路設定 ip 指令用法教學與範例

本篇介紹如何在 Linux 系...

9 個月 ago

Windows 使用 TPM 虛擬智慧卡保護 SSH 金鑰教學與範例

本篇介紹如何在 Windows...

10 個月 ago

Linux 以 Shamir’s Secret Sharing 分割保存金鑰教學與範例

介紹如何在 Linux 中使用...

11 個月 ago

Linux 以 Cryptsetup、LUKS 加密 USB 隨身碟教學與範例

介紹如何在 Linux 系統中...

11 個月 ago