如何在 Ubuntu 21.04 上安裝 openconnect-sso

如何在 Ubuntu 21.04 上安裝 openconnect-sso

我想安裝openconnect-ssh。該專案的安裝說明似乎很複雜,我不確定pipx是什麼。

如何在不使用 pipx 和使用本機 Ubuntu qt 庫的情況下在 Ubuntu 上安裝 openconnect-sso?

我嘗試使用安裝它pip,但出現以下錯誤:

Traceback (most recent call last):
  File "/home/merlijn/.local/bin/openconnect-sso", line 5, in <module>
    from openconnect_sso.cli import main
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/cli.py", line 10, in <module>
    from openconnect_sso import app, config, __version__
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/app.py", line 16, in <module>
    from openconnect_sso.authenticator import Authenticator, AuthResponseError
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/authenticator.py", line 6, in <module>
    from openconnect_sso.saml_authenticator import authenticate_in_browser
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/saml_authenticator.py", line 3, in <module>
    from openconnect_sso.browser import Browser
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/browser/__init__.py", line 1, in <module>
    from .browser import Browser, DisplayMode, Terminated
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/browser/browser.py", line 5, in <module>
    from . import webengine_process as web
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/browser/webengine_process.py", line 12, in <module>
    from PyQt5.QtCore import QUrl, QTimer
ModuleNotFoundError: No module named 'PyQt5'
Traceback (most recent call last):
  File "/home/merlijn/.local/bin/openconnect-sso", line 5, in <module>
    from openconnect_sso.cli import main
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/cli.py", line 10, in <module>
    from openconnect_sso import app, config, __version__
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/app.py", line 16, in <module>
    from openconnect_sso.authenticator import Authenticator, AuthResponseError
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/authenticator.py", line 6, in <module>
    from openconnect_sso.saml_authenticator import authenticate_in_browser
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/saml_authenticator.py", line 3, in <module>
    from openconnect_sso.browser import Browser
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/browser/__init__.py", line 1, in <module>
    from .browser import Browser, DisplayMode, Terminated
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/browser/browser.py", line 5, in <module>
    from . import webengine_process as web
  File "/home/merlijn/.local/lib/python3.9/site-packages/openconnect_sso/browser/webengine_process.py", line 14, in <module>
    from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineScript, QWebEngineProfile
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'

答案1

首先,您需要安裝 Qt5 Python 依賴項:

sudo apt install python3-pyqt5 python3-pyqt5.qtwebengine vpnc-scripts openconnect

然後使用 pip 安裝 openconnect-sso

pip install openconnect-sso

之後,您可以輕鬆運行該應用程式:

$ openconnect-sso -s vpn.example.com --browser-display-mode shown
[info     ] Authenticating to VPN endpoint [openconnect_sso.app] address=vpn.example.com name=
[info     ] Response received              [openconnect_sso.authenticator] id=main message=Please complete the authentication process in the AnyConnect Login window. title=Login
[info     ] Browser started                [webengine] startup_info=StartupInfo(url='https://vpn.example.com/...', credentials=None)
[info     ] Loading page                   [webengine] url=https://vpn.example.com/...
[info     ] Terminate requested.           [webengine] 
[info     ] Exiting browser                [webengine] 
[info     ] Browser exited                 [openconnect_sso.browser.browser] 
[info     ] Response received              [openconnect_sso.authenticator] id=success message=

答案2

這是我打開的一個問題,連結到我的安裝說明:https://github.com/vlaci/openconnect-sso/issues/114<--(如果您同意並希望引起關注,請在 GitHub 上豎起大拇指進行投票)

……這裡:openconnect-sso如何透過 Okta 單一登入 (SSO)將「openconnect」(透過包裝器)與 SAML 和 Duo 雙重身分驗證結合使用<-- 請參閱此處以了解完整說明、詳細資訊和螢幕截圖。

簡而言之,在 Linux Ubuntu 上執行以下操作openconnectopenconnect-sso

sudo apt update
sudo apt install vpnc-scripts openconnect   # install openconnect
sudo apt install python3

python3 -m pip install --upgrade pip
python3 -m pip install openconnect-sso      # install openconnect-sso

# install openconnect-sso dependencies, including forcing a reinstall of PyQt5

# uninstall
python3 -m pip uninstall PyQt5
python3 -m pip uninstall PyQt5-sip
python3 -m pip uninstall PyQtWebEngine
python3 -m pip uninstall keyring

# reinstall
python3 -m pip install PyQt5
python3 -m pip install PyQt5-sip
python3 -m pip install PyQtWebEngine
python3 -m pip install keyring

python3 -m pip install cffi

# Check the version
# My output is: `openconnect-sso 0.7.3`
openconnect-sso --version

也可以看看我的主要答案了解如何建立自訂~/.my_ssl.conf設定檔以及向其中添加哪些內容。主要答案包含這些必要的細節,以避免您可能遇到的一些錯誤。

您還需要在文件底部添加一些行~/.bashrc。再次,參見我的主要答案

用法(注意:如何尋找您的伺服器位址和 SAML 群組,請參閱「如何找到您的 VPN 伺服器位址和 SAML 群組」位於我的答案底部):

VPN_SERVER_ADDRESS="myvpn.whatever.com"   # example server address to connect to
VPN_SAML_GROUP="whatever-saml-whatever"   # example SAML group name
VPN_USER="[email protected]"      # example username
# or perhaps just this for the username:
# VPN_USER="my.username"

# connect via `openconnect-sso`
# The first time ever, you must specify everything
openconnect-sso --server "${VPN_SERVER_ADDRESS}/${VPN_SAML_GROUP}" --user "${VPN_USER}"
# Subsequent connection attempts can be done with just this, since apparently
# the server address, SAML group, and username are cached after the first usage
openconnect-sso

相關內容