SSH Server
Enable OpenSSH Server on Windows 11
Section titled “Enable OpenSSH Server on Windows 11”source: ansible docs
- install openssh (this is an officially supported optional feature)
Terminal window Get-WindowsCapability -Name OpenSSH.Server* -Online | Add-WindowsCapability -Online - after installation, set the service to autoastart, and start it the first time
Terminal window Set-Service -Name sshd -StartupType Automatic -Status Running - add firewall rule:
Terminal window $firewallParams = @{Name = 'sshd-Server-In-TCP'DisplayName = 'Inbound rule for OpenSSH Server (sshd) on TCP port 22'Action = 'Allow'Direction = 'Inbound'Enabled = 'True' # This is not a boolean but an enumProfile = 'Any'Protocol = 'TCP'LocalPort = 22}New-NetFirewallRule @firewallParams - the default shell will be cmd, if you want to set it to powershell (recommended for ansible)
Terminal window $shellParams = @{Path = 'HKLM:\SOFTWARE\OpenSSH'Name = 'DefaultShell'Value = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'PropertyType = 'String'Force = $true}New-ItemProperty @shellParams
Enable OpenSSH server on Linux (Ubuntu/Debian)
Section titled “Enable OpenSSH server on Linux (Ubuntu/Debian)”- install
Terminal window sudo apt install openssh-server - check if the service is running
Terminal window sudo systemctl status ssh - sometimes, firewall rule is needed to allow ssh
Terminal window sudo ufw allow ssh