SSH into Windows
With Windows 10 and 11, you can ssh into your Windows machine, with ssh key too.
Install OpenSSH Server
Go to Windows Settings
Select
Apps
thenOptional features
Click
View features
Search
ssh
, checkmarkOpenSSH Server
, clickNext
Click
Install
Enable OpenSSH Service
OpenSSH service not enable by default.
Open service manager
Double click
OpenSSH SSH Server
In
General
Tab- Select
Automatic
forStartup type
- Click
Start
- Click
Apply
- Select
Microsoft Account
SSH sign-in to Windows 10/11, both local accounts and Microsoft accounts can be used.
To use Microsoft accounts(eg. Hotmail), you have to find out the shorten name of your account. It is your home directory name in C:\Users\
. Then you can login ssh with the shorten name using Microsoft account password.
SSH Key
To use ssh key with Windows, you do the same as Linux, almost.
Standard User
For standard Windows user, you do the same as Linux. Put the public key inside
C:\Users\<username>\.ssh\authorized_keys
Administrator
The first account of Windows is always an administrator account.
Unlike Linux, Windows administrators do not use home directory authorized_keys
. ALL administrators public keys are to be put in
C:\ProgramData\ssh\administrators_authorized_keys
One per line.
If a standard account is promoted to administrator account, its home directory authorized_keys
file will stop working, and its public key need to be put into the above file.
On the other hand, if an administrator account is demoted to standard, it will revert back to home directory setup like the previous section.