This topic is already well documented by mircosoft docs. You can find it from Get started with OpenSSH.
Here I just want to give two tips for accelerating the setup.
- There are two ways to activate the open ssh server on Windows: from
Windows SettingsorPowerShell. Personally, I would recommend to use thePowerShell. Open the PowerShell as an Administrator.
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
# Install server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Start the sshd service
Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}
- When you try to connect the OpenSSH server, you’ll need to use
ssh username@servername.
Theservernameis your device’s IP address. For example,192.168.1.5.
Theusernamemay confuse you. But you can find it by typingwhoamiin PowerShell or Command. It may look likelaptop-nbgksu9c\user.
In the ~/.ssh/config file, you can configure it like
Host windowsdevice
HostName 192.168.1.5
User laptop-nbgksu9c\user
Port 22
Then you can simply type ssh windowsdevice from where you want to connect the Windows device. The work will be done.
Enjoyed this article? Support my work with a coffee ☕ on Ko-fi.