tacticalrmm/scripts/OpenSSHServerInstall.ps1

24 lines
554 B
PowerShell
Raw Normal View History

2021-01-10 17:33:48 +00:00
##Check if openssh is installed
if((Get-WindowsCapability -Online | ? Name -like OpenSSH*).State -eq "Installed")
{
2021-01-10 17:42:11 +00:00
Write-Output "OpenSSH Server is installed."
2021-01-10 17:33:48 +00:00
}
else
{
2021-01-10 17:42:11 +00:00
Write-Output "OpenSSH Server is NOT installed.";
2021-01-10 17:33:48 +00:00
## Install SSH
Add-WindowsCapability -Online -Name "OpenSSH.Server~~~~0.0.1.0"
## Set SSH service to start automatically
Set-Service -Name sshd -StartupType "Automatic"
## Allow SSH through firewall on all profiles
Get-NetFirewallRule -Name *ssh*
## Start SSH service
Start-Service sshd
2021-01-10 17:42:11 +00:00
}