一、安裝OpenSSH
1、前往Win32-OpenSSH releases頁面下載msi安裝文件。
<img src="https://raw.githubusercontent.com/JaidedAI/EasyOCR/master/doc/images/EasyOCR_logo.png"></img>
2、執行安裝程序,並在安裝過程中選擇要安裝的組件。
<img src="https://raw.githubusercontent.com/PowerShell/Win32-OpenSSH/master/Install/win32-openssh-setup.png"></img>
3、在開始菜單中搜索“服務”,並打開“服務”窗口。
<img src="https://raw.githubusercontent.com/PowerShell/Win32-OpenSSH/master/Install/services.png"></img>
4、查找名為“OpenSSH Authentication Agent”的服務,並啟動它。
OpenSSH Authentication Agent ssh-agent
二、生成SSH密鑰
1、打開Windows PowerShell控制台。
2、執行以下命令,生成公私密鑰對。
$ssh-keygen
3、根據提示輸入密鑰的保存路徑和密碼等信息。
Enter file in which to save the key (/Users/you/.ssh/id_rsa): </br>Enter passphrase (empty for no passphrase):</br>Enter same passphrase again:</br>
4、成功生成密鑰後,會在指定的保存路徑中生成私鑰文件和公鑰文件。
三、打開SSH服務
1、進入Windows服務管理器界面。
2、找到OpenSSH服務列表,並啟動OpenSSH依賴的所有服務。
C:\Program Files\OpenSSH\usr\sbin\sshd.exe
3、在Windows防火牆中新建一個入站規則,允許SSH服務通過。
netsh advfirewall firewall add rule name=SSHD dir=in action=allow protocol=TCP localport=22
4、測試SSH服務。
C:\Windows\System32\OpenSSH\ssh.exe
5、輸入遠程主機地址和用戶名,成功連接後即可使用SSH。
四、使用SSH連接遠程主機
1、打開命令行界面或SSH客戶端,並輸入連接命令。
$ssh user@remote_host_ip
2、根據提示輸入密碼或使用已生成的密鑰進行認證。
3、成功連接後即可在遠程主機上執行命令或傳輸文件等操作。
原創文章,作者:ZVZWB,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/332411.html