#Set-ExecutionPolicy RemoteSigned #New-PSDrive -Name P -Root \\e301pc08\temp -PSProvider FileSystem # Install the OpenSSH Client Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 # Install the OpenSSH Server Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 # Start the sshd service Start-Service sshd # OPTIONAL but recommended: Set-Service -Name sshd -StartupType 'Automatic' # Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify 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." } mkdir c:\users\admin\.ssh Copy-Item 'c:\pc_prod\id_rsa.pub' 'c:\users\admin\.ssh\id_rsa.pub' Copy-Item 'c:\pc_prod\sshd_config' 'C:\ProgramData\ssh\sshd_config' Copy-Item 'c:\pc_prod\authorized_keys' 'C:\Users\admin\.ssh\authorized_keys' #scp c:\Users\admin\.ssh\id_rsa.pub admin@localhost:C:\Users\admin\.ssh\authorized_keys icacls.exe "C:\Users\admin\.ssh\authorized_keys" /inheritance:r /grant "admin:F" /grant "SYSTEM:F" Stop-Service sshd Start-Service sshd