Open PowerShell (Start Menu → type "PowerShell", then open it).
Run this command to create a new key:
ssh-keygen
You’ll see this prompt:
Enter file in which to save the key (/c/Users/YourName/.ssh/id_rsa):
- Just press Enter to accept the default location.
Then:
Enter passphrase (empty for no passphrase):
- You can leave it empty (just press Enter), or set a passphrase if you want more security.
It will say:
Your identification has been saved...
Your public key has been saved...
Add to Server
- SSH into your server, then:
sudo nano /root/.ssh/authorized_keys
- Paste the copied key into a new line.
- Save and exit (
Ctrl + X
, thenY
, then Enter). - Restart SSH (optional, usually not needed unless configs changed):
sudo systemctl restart ssh
SSHD config
Include /etc/ssh/sshd_config.d/*.conf
Port xxxx
LogLevel DEBUG3
RSAAuthentication yes
LoginGraceTime 30
MaxAuthTries 3
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitEmptyPasswords no
KbdInteractiveAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
ClientAliveInterval 300 # Disconnect idle sessions
ClientAliveCountMax 2 # Max allowed idle sessions
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
PermitRootLogin prohibit-password
PasswordAuthentication no