# Enable SSH in Windows 10 with PS

**URL:** <https://onehack.st/t/enable-ssh-in-windows-10-with-ps/295328>\
**Category:** Tutorials & Methods\
**Tags:** learning\
**Created:** [November 8, 2024, 12:46am UTC](https://onehack.st/t/enable-ssh-in-windows-10-with-ps/295328 "2024-11-08T00:46:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xj3j](https://onehack.st/user_avatar/onehack.st/xj3j/32/151762_2.png) [@xj3j](https://onehack.st/u/xj3j)\
**Post date:** [November 8, 2024, 12:46am UTC](https://onehack.st/t/enable-ssh-in-windows-10-with-ps/295328/1 "2024-11-08T00:46:13Z")

</div>

this script automates the process of setting up an OpenSSH server on a Windows machine, ensuring it’s ready to accept SSH connections.

```auto
# run the code as administrator
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
    Write-Host "This script needs to be run as Administrator!" -ForegroundColor Red
    exit
}

# Install OpenSSH Server feature
Write-Host "Installing OpenSSH Server..." -ForegroundColor Yellow
Add-WindowsCapability -Online -Name OpenSSH.Server ~~~~ 0.0.1.0

Write-Host "Starting OpenSSH Server..." -ForegroundColor Yellow
Start-Service -Name sshd

Write-Host "Configuring OpenSSH Server to start on boot..." -ForegroundColor Yellow
Set-Service -Name sshd -StartupType 'Automatic'

# Allow SSH through the firewall
Write-Host "Allowing SSH through Windows Firewall..." -ForegroundColor Yellow
New-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -DisplayName "OpenSSH Server (SSH-In)" -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

Write-Host "Made By ClumsyLulz" -ForegroundColor Green

Write-Host "OpenSSH Server installation and configuration complete!" -ForegroundColor Green

```

**Note:** the code is not mine but helps me so much i hope this help u too 😀
