Configure PowerShell to use ssh keys

Run PowerShell as an Administrator. Generate SSH key with:

ssh-keygen -b 4096

Follow instructions.

If you didn’t enter filename, keys pair will be saved in C:\Users\<WINDOWS_USER>\.ssh\ as id_rsa and id_rsa.pub.

You can also change the name of your files or move to another directory if you want to store more keys.

Now add your private key to ssh:

ssh-add C:\Users\<WINDOWS_USER>\.ssh\<YOUR_PRIVATE_KEY_NAME>

If you get error ssh-add Error connecting to agent: No such file or directory that means you need to enable ssh-agent. You can check if that is the issue:

Get-Service -Name "ssh-agent" | select -property name,status,starttype

Service ssh-agent should be Disabled or Manual now.

Set and start ssh-agent service:

Set-Service -Name ssh-agent -StartupType Automatic
Start-Service ssh-agent

Now you can add your private key:

ssh-add C:\Users\<WINDOWS_USER>\.ssh\<YOUR_PRIVATE_KEY_NAME>

Now connect to your server and copy contents of your public key (default id_rsa.pub) to /home/<LINUX_USER>/.ssh/authorized_keys

Done. Now you can connect to your server without credentials.

ssh -p<PORT> myname@myserver.com