Windows 10 啟動 OpenSSH Server(sshd) 的方式
- 這方式應該可以適用 Windows Server 2019、2022
啟用內建的 OpenSSH Server
- 使用系統管理員權限開啟 PowerShell
- 確認目前的 Windows 版本是否可以使用 OpenSSH
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
如果可以執行會出現這樣的訊息
Name : OpenSSH.Client~~~~0.0.1.0 State : NotPresent Name : OpenSSH.Server~~~~0.0.1.0 State : NotPresent
- 如果還未安裝就執行安裝命令
# Install the OpenSSH Client Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 # Install the OpenSSH Server Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
使用 Github 下載 Win32-OpenSSH 安裝檔
- 進入 GitHub PowerShell/Win32-OpenSSH 頁面下載最新版 OpenSSH-Win64-*.msi Exp. OpenSSH-Win64-v8.9.1.0.msi
- 產生使用者金鑰
"C:\Program Files\OpenSSH\ssh-keygen.exe" -t ed25519
Exp.
C:\Users\jonathan>"C:\Program Files\OpenSSH\ssh-keygen.exe" -t ed25519 Generating public/private ed25519 key pair. Enter file in which to save the key (C:\Users\jonathan/.ssh/id_ed25519): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in C:\Users\jonathan/.ssh/id_ed25519 Your public key has been saved in C:\Users\jonathan/.ssh/id_ed25519.pub The key fingerprint is: SHA256:qb7JFIhchmeQjU+q6OSTZ3b8ZOIKI5Baobx9Qd6Xf7c iii\jonathan@200816-NB-DTI The key's randomart image is: +--[ED25519 256]--+ | .+ | | ooo | | o+=. | |.+.B+.. .. | |=o+ .o..So | |=oo .o. . | |*+...ooo . . . | |.=o+o*+. . . .| | =.o.*o E | +----[SHA256]-----+