Skip to content

Instantly share code, notes, and snippets.

@s4eidhp
Last active November 1, 2024 09:00
Show Gist options
  • Save s4eidhp/61e6deefcdd2df16d57a41b6424448ee to your computer and use it in GitHub Desktop.
Save s4eidhp/61e6deefcdd2df16d57a41b6424448ee to your computer and use it in GitHub Desktop.

SSH into Windows using Key Authentication

  • Install OpenSSH Server on remote machine
  • Set OpenSSH Authentication Agent service & OpenSSH Server service to start automatically
  • Start both services
  • Edit C:\ProgramData\ssh\sshd_config file
PubKeyAuthentication      yes
PasswordAuthentication    no
# Match group admin ...
# Authorized key file ...
  • Restart OpenSSH service
  • Create C:\Users\<user_name>\.ssh\authorized_key file without extension
  • Change file permissions
    • Disable Inheritance
    • Remove Administrators from Access permissions
  • Create ssh key on local machine
  • Copy public key from local machine to authorized_key file on remote machine
  • SSH into remote machine
ssh user@ip -i "private_key_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment