Install OpenSSH Server on Windows 11/10

มาสำรวจกันก่อนครับ ว่าที่ Windows มีอะไรบ้าง ด้วยคำสั่งนี้

Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

ตอนนี้เราจะพบว่า OpenSSH.Client มีแล้ว แต่ยังขาด OpenSSH.Server ครับ

PS C:\Users\invest> Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed
Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

เมื่อไม่พบ OpenSSH.Server ติดตั้ง OpenSSH Server ตามคำสั่ง ด้านล่างครับ

 Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

ตรวจสอบสถานะการติดตั้ง OpenSSH.Server อีกรอบครับ

PS C:\Users\invest> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Path          :
Online        : True
RestartNeeded : False
PS C:\Users\invest> Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : Installed

ลอง Start Service SSH + Set Automate Start up

Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'

เปิด Firewall Port 22

netsh advfirewall firewall add rule name="SSH PORT 22" dir=in action=allow protocol=TCP localport=22

ทดสอบ Connect ด้วยคำสั่ง ssh <username>@<hostname or IP>


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts to your email.