Generating a SSH Key
Firstly, open a Windows PowerShell terminal.
cd into .ssh folder directory or whichever folder you prefer.
PS C:\Users\jun> cd .ssh
PS C:\Users\jun\.ssh> ssh-keygen
Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\jun/.ssh/id_ed25519): mainsever
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in mainsever
Your public key has been saved in mainsever.pub
The key fingerprint is:
SHA256:NKXXXXXXXXXXXXXXZznMIY+ugXXXXJT/Yxpgxxxxxxxo jun@Jun
The key's randomart image is:
+--[ED25519 256]--+
| =*ooo..o. |
|o==Bo ooo. |
|=.+..o.+o+. |
|oo . ++ . . |
|+.. . ..S . |
|=+ o = =. |
|*.. * + . + |
| o.= o . . |
| .o E . . . |
+----[SHA256]-----+
- You can use the default
id_ed25519by just pressing the enter key. However, if you already have an existingid_ed25519file, you might want to reconsider renaming the filename. - You can skip the passphrase by pressing the enter key. However, it would be more secure if you enter a passphrase.
The key will be saved into the .ssh folder directory or whichever directory you have specified.
Copy SSH Key to Remote Linux Device
type $env:USERPROFILE\.ssh\{name}.pub | ssh {username}@{IP-ADDRESS-OR-FQDN} "cat >> .ssh/authorized_keys"
{name}is your key name you have given - in this example ismainserver. If you did not, the default name should beid_ed25519.
Add into SSH Key Agent
ssh-add $env:USERPROFILE\.ssh\{name}
{name}is your key name you have given - in this example ismainserver. If you did not, the default name should beid_ed25519.
See Issues & Mitigations if you are having troubles adding with ssh-add.
Remove Password Authentication from Linux Server
Inside your Linux Server terminal, run the following command to edit the SSH configuration:
sudo nano /etc/ssh/sshd_config
Look out for and change PasswordAuthentication from “Yes” to “No”.
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
#PermitEmptyPasswords no
Exit by pressing Ctrl + X. Enter Y to save changes. Then press Enter key.
Then restart the ssh/sshd service using:
sudo systemctl restart ssh
Now try to SSH into your Linux server!
Important: Do NOT lose your keys! Always back them up somewhere safe and secure too.
Issues & Mitigations
PowerShell: “unable to start ssh-agent service, error :1058 when running ssh-agent”
Ensure OpenSSH is Installed by:
-
Opening PowerShell as an Administrator.
-
Run the following command to check if OpenSSH is installed:
Get-WindowsCapability -Online | Where-Object {$_.Name -like 'OpenSSH.Client*'}-
If not installed, run the following command:
Add-WindowsCapability -Online -Name OpenSSH.Client
-
-
Press
Win + R, typeservices.msc, and press Enter to open the Services window. -
Look for OpenSSH Authentication Agent in the list of services.
-
If the service is disabled or stopped, right-click on it and select Properties.
-
Set the Startup type to Automatic.
-
Click Start to start the service if it’s stopped.
-
Click OK to save the changes.
(VPS) Server Still Requesting for Password
Despite disabling PasswordAuthentication via /etc/ssh/sshd_config, the server is still requesting for password.
-
Check the directory
/etc/ssh/sshd_config.d:ls /etc/ssh/sshd_config.d-
If you see the following:
50-cloud-init.conf 60-cloudimg-settings.confCreate a new file called
0-custom.conf:sudo nano /etc/ssh/sshd_config.d/0-custom.confThen add the following into it:
PasswordAuthentication noThen restart the SSH service:
sudo systemctl restart ssh
-
Note: If you see ChallengeResponseAuthentication or KbdInteractiveAuthentication set as “Yes” in one of the “cloud config” files, add “No” to these two into the 0-custom.conf and restart the SSH service.
With references from:
- https://chrisjhart.com/Windows-10-ssh-copy-id/
I was setting up my VPS and would like to document how I set it up for my future references. I thought I might as well share it online for other people to reference it or possibly help check if there’s any misconfigurations. Please pardon me if there’s any mistakes 🙏.
Feel free to drop me an inbox if there’s any misconfigurations or queries!
[Aug 18, 2025] Updated content for more clarity.