附註:
- 此教學課程需要存取 Oracle Cloud。若要註冊免費帳戶,請參閱 Oracle Cloud Infrastructure Free Tier 入門。
- 它使用 Oracle Cloud Infrastructure 證明資料、租用戶及區間的範例值。完成實驗室時,請將這些值取代為您雲端環境特定的值。
使用 VNC Viewer 搭配 Secure Shell 通道連線至 Windows Oracle Cloud Infrastructure Compute 執行處理
簡介
Oracle Cloud Infrastructure (OCI) 可讓使用者使用主控台連線存取虛擬機器 (VM) 執行處理。如果無法使用標準遠端桌面協定 (RDP) 或安全 Shell (SSH) 存取,您可以使用 VNC 檢視器,透過安全的 SSH 通道存取執行處理。本教學課程將引導您使用 SSH 設定 OCI Compute 執行處理的 VNC 連線。
目標
- 使用 VNC Viewer 搭配 SSH 通道連線至 OCI Compute 執行處理。
必要條件
-
執行中的 OCI Compute 執行處理。
-
已為您的執行處理建立主控台連線。
-
與您的 OCI Compute 執行處理關聯的私密 SSH 金鑰 (
.key
) 檔案。 -
您個別作業系統適用的 SSH 從屬端。
-
MacOS/Linux:內建的
ssh
命令行公用程式終端機。 -
Windows:使用 PuTTY 或 Git Bash 。
-
-
VNC Viewer 或 VNC 用戶端,例如 RealVNC 或 TigerVNC 。
注意:在此教學課程中,我們使用 Windows 伺服器和 RealVNC 檢視器。
作業 1:驗證您的 OCI Compute 執行處理主控台連線
確定已在 OCI 主控台中建立主控台連線。
-
登入 OCI 主控台,瀏覽至運算並按一下執行處理。
-
選取例項。
-
按一下主控台連線和建立主控台連線。
-
按一下複製 Linux/Mac 的 VNC 連線。
工作 2:建立 VNC 的 SSH 通道
我們需要建立一個 SSH 通道,將連接埠 5900
上的 VNC 流量從您的本機機器轉送至 OCI Compute 執行處理。
-
在取代必要的零件時更新以下指令,然後在您的終端機中執行該指令。
ssh -i replace-ssh-key.key \ -o ProxyCommand="ssh -i replace-ssh-key.key -W %h:%p -p 443 \ ocid1.instanceconsoleconnection.xxxxxxxxxxxxxxxxxxxxx@instance-xxxxxxxxxx.xxxxxxxxxxx" \ -o HostKeyAlgorithms=+ssh-rsa \ -o PubkeyAcceptedAlgorithms=+ssh-rsa \ -N -L localhost:5900:ocid1.instance.oc1.xxxx.xxxxx:5900 \ ocid1.instance.xxxxxxxxxxxxxxxxxxxxxxxxxxx
注意:命令說明:
ssh -i replace-ssh-key.key:
使用您的私密 SSH 金鑰。-o ProxyCommand="ssh -i replace-ssh-key.key -W %h:%p -p 443":
使用中繼連線來通道要求。-o HostKeyAlgorithms=+ssh-rsa
和-o PubkeyAcceptedAlgorithms=+ssh-rsa
: 啟用傳統 RSA 金鑰認證。-N
:避免執行遠端指令 (僅用於通道)。-L localhost:5900:...:5900
:將本機連接埠5900
對應至遠端執行處理連接埠5900
。ocid1.instance...
:指定 OCI 執行處理的 OCID。
-
執行此指令之後,系統可能會提示您接受具有 yes 或 no 選項的 SSH 金鑰。輸入 Y ,然後按 Enter 繼續。
一旦指令成功執行,您就不會在終端機中看到任何輸出或提示,這是預期的。請勿關閉終端機階段作業,因為這樣會確認已順利建立 SSH 通道。
可能的錯誤與修正
-
錯誤 1:
Unable to negotiate with UNKNOWN port 65535: no matching host key type found
。- 修正:確定使用
-o HostKeyAlgorithms=+ssh-rsa
選項啟用ssh-rsa
。
- 修正:確定使用
-
錯誤 2:
Permission denied (publickey)
。- 修正:確定使用了正確的私密金鑰,並且具有適當的權限 (
chmod 600 replace-ssh-key.key
)。
- 修正:確定使用了正確的私密金鑰,並且具有適當的權限 (
作業 3:使用 VNC 檢視器連線至 OCI Compute 執行處理
建立 SSH 通道之後,您可以使用 VNC 檢視器連線至您的 OCI Compute 執行處理。
-
開啟 VNC 檢視器 (RealVNC,TigerVNC,或任何其它的 VNC 客戶端程式) 。
-
在 VNC 伺服器中,輸入
localhost:5900
,然後按一下確定。 -
按一下連線,如果出現提示,請按一下繼續。
-
將開啟 VNC 連線視窗 。將游標移至 RealVNC 檢視器視窗的頂端,然後按一下按住 Ctrl + Alt + Delete 鍵即可解除鎖定,顯示 Windows 登入畫面。輸入執行處理的使用者名稱和密碼,以存取運算環境。
驗證與疑難排解
如果連線失敗,請確定 SSH 通道仍在執行中,並確認連接埠 5900
是否正確對應。檢查 OCI 安全規則以允許主控台存取。
接下來的步驟
您現在已透過 SSH 通道順利建立與 OCI Compute 執行處理的 VNC 連線。此方法適用於疑難排解無法存取的執行處理,或直接 SSH/RDP 連線失敗的情況。
如果您需要進一步的自訂,請考慮使用防火牆或 VPN 通道新增其他安全保護措施,例如限制存取。
相關連結
認可
- 作者 - Akarsha I K (雲端架構師)
其他學習資源
探索 docs.oracle.com/learn 上的其他實驗室,或存取 Oracle Learning YouTube 頻道上的更多免費學習內容。此外,請造訪 education.oracle.com/learning-explorer 以成為 Oracle Learning Explorer。
如需產品文件,請造訪 Oracle Help Center 。
Connect to Windows Oracle Cloud Infrastructure Compute Instances using VNC Viewer with Secure Shell Tunnel
G27533-01
February 2025
Copyright ©2025, Oracle and/or its affiliates.