Ansible/SSH

From Omnia
Jump to navigation Jump to search

Setup

https://docs.ansible.com/projects/ansible/latest/os_guide/windows_ssh.html#windows-ssh
Get-WindowsCapability -Name OpenSSH.Server* -Online | Add-WindowsCapability -Online

Set-Service -Name sshd -StartupType Automatic -Status Running



$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 enum
    Profile     = 'Any'
    Protocol    = 'TCP'
    LocalPort   = 22
}
New-NetFirewallRule @firewallParams

$shellParams = @{
    Path         = 'HKLM:\SOFTWARE\OpenSSH'
    Name         = 'DefaultShell'
    Value        = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
    PropertyType = 'String'
    Force        = $true
}
New-ItemProperty @shellParams

ssh keys

C:\ProgramData\ssh\administrators_authorized_keys
Match Group administrators
   AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys

keywords