Skip to content

Instantly share code, notes, and snippets.

@adrianriobo
Last active May 19, 2021 10:20
Show Gist options
  • Save adrianriobo/988fadd7ffc3eb541b0a680063b4b410 to your computer and use it in GitHub Desktop.
Save adrianriobo/988fadd7ffc3eb541b0a680063b4b410 to your computer and use it in GitHub Desktop.
Windows Openssh configuration
# Download Openssh https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH
# Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# In our case due the limitations on logon accounts for services on windows we need to create a bat file to start
# the service on startup
# Create firewall rule
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
# Give permissons to the user we will use to start sshd to the folder %PROGRAMDATA%/ssh
# Create keys
ssh-keygen -A
# Ensure valid permissions per user on
# icacls .\users\username\.ssh\authorized_keys /inheritance:r
C:\Users\$USER\.ssh\authorized_keys
# Sample config file (C:\Windows\System32\OpenSSH\sshd_config)
SyslogFacility LOCAL0
LogLevel DEBUG3
PubkeyAuthentication yes
PasswordAuthentication no
# Configure autologin
https://docs.microsoft.com/es-es/troubleshoot/windows-server/user-profiles-and-logon/turn-on-automatic-logon
# Add ps on startup folder
C:\Users\$USER\AppData\Roadmin\Microsoft\Windows\Startup\....
bat file with
powershell -command "sshd -f C:\Windows\System32\OpenSSH\sshd_config"
# Configure powershell as default shell
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Program Files\PowerShell\7\pwsh.exe" -PropertyType String -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShellCommandOption -Value "/c" -PropertyType String -Force
https://github.com/PowerShell/Win32-OpenSSH/wiki/DefaultShell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment