Skip to content

Instantly share code, notes, and snippets.

@andmax
Last active May 10, 2020 11:14
Show Gist options
  • Save andmax/47f911e576944869eb361ccb7cf8ec79 to your computer and use it in GitHub Desktop.
Save andmax/47f911e576944869eb361ccb7cf8ec79 to your computer and use it in GitHub Desktop.
Make OpenSSH server work on Windows changing the sshd_config file
1- win > apps and features > optional features > add a feature
2- Install OpenSSH Server
3- win > services > Start OpenSSH SSH Server
4- It will create files on: %ProgramData%\ssh
5- Edit: %programdata%\ssh\sshd_config (%programdata% == C:\ProgramData)
6- Change default port by uncommenting first configuration line:
Port <some port other than 22>
7- Find line below, uncomment it and change to not allow password:
PasswordAuthentication no
8- Comment last two lines with:
Match Group administrators
AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
9- Add ssh public key to the authorized_keys file on:
%userprofile%\.ssh\authorized_keys (%userprofile% == C:\Users\<windows login>)
10- Add following lines to a .ssh/config file:
Host windows_host
Port <port number>
User <windows login>
Hostname <ip or address or localhost>
IdentityFile ~/.ssh/id_rsa
11- Run line below in an Administrator PowerShell to have git bash as the
12- default bash when connecting to windows via OpenSSH server:
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell \
-Value "C:\Program Files\Git\bin\bash.exe" -PropertyType String -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment