Skip to content

Instantly share code, notes, and snippets.

@neesonqk
Last active October 9, 2018 09:51
Show Gist options
  • Save neesonqk/a78723445ca14e02aa907b1f52186b34 to your computer and use it in GitHub Desktop.
Save neesonqk/a78723445ca14e02aa907b1f52186b34 to your computer and use it in GitHub Desktop.
Install OpenSSH on Windows & SSH Key Setup
# Download binary files
https://github.com/PowerShell/Win32-OpenSSH/releases
# Run from cmd.exe (administrator)
`powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1`
# Open 22 port (run under Powershell)
`New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22`
# Start service from Services.
OpenSSH Authentication Agent & OpenSSH SSH Server
#############
# Generate SSH Key pairs (*nix)
`cd ~/.ssh/`
`ssh-keygen` # DONOT use default name, choose a proper name (i.e. my_rsa), else it will overwrite your previous key pairs (default is id_rsa)
# Use key passpharse to protect the private key
# Print public key
`cat ~/.ssh/my_rsa.pub`
##############
# Enable ssh key authentication of OpenSSH on windows (Powershell)
`cd $env:USERPROFILE`
`mkdir .ssh`
`cd .ssh`
`New-Item authorized_keys`
# Paste my_rsa.pub to authorized_keys
# Setup permission of authorized_keys file
`start .`
·Properties -> Security -> Advanced·
·Click "Disable inheritance"·
# Restart SSH Services
# Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment