WINDOWS SSHD Installation

Aus xinux.net
Zur Navigation springen Zur Suche springen

Checken ob SSH installiert ist

  • 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

Installation des OpenSSH Server

  • Add-WindowsCapability -Online -Name OpenSSH.Server
Path          :
Online        : True
RestartNeeded : False

Starten des sshd service

  • Start-Service sshd

Automatisches Starten des sshd service

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

Firewall anpassen

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."
}

SSH Anpassungen

  • cat C:\ProgramData\ssh\sshd_config
PubkeyAuthentication yes
Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo

SSH restart

  • Restart-Service sshd

Einlogen von Remote

  • ssh thomas.will@tomwin powershell

Administrator Key

Hier müssen die Adminkeys rein
  • C:\ProgramData\ssh\administrators_authorized_keys

Links