The Windows version of OpenSSH client doesn't include a ssh-copy-id command. I don't know why. If it does one day, then this gist can be ignored.
- This script is written in PowerShell as the legacy program
cmd.exeis not flexible enough for the required options. - Download the file
ssh-copy-id.ps1to your Windows PC, or copy and paste its contents to a file of the same name. - Run the script passing your linux account ssh information (for example
powershell .\ssh-copy-id.ps1 [email protected]). If you use a non-standard port add the parameter-port=nnnn. This should work with any Linux platform. - Run the command for each linux account you connect with. You will be prompted for your Linux host password. If you have more than 1 account on any machine, you must do this for each account.
If the script won't run, then run this command once
Set-ExecutionPolicy RemoteSigned CurrentUser
Refer to https://go.microsoft.com/fwlink/?LinkID=135170
The file name and location of the script is not important but the filename extension must be .ps1
If the public key is already known to the account, it will not be added again.
For a complete description of available options run powershell .\ssh-copy-id.ps1 -?
Prerequisites
- You have installed Microsoft's version of OpenSSH Client on your machine. Read this. You do NOT need to install SSH Server. Current versions of Windows 10 and Windows 11 have OpenSSH installed as part of the base Operating System and you do NOT need to install it.
- You have generated a default authorize key. DO THIS ONLY ONCE.
You can tell if this is done by looking in your
.sshfolder. The current default key isid_ed25519but usingid_rsawill also work. If you find 2 files, eitherid_ed25519andid_ed25519.puborid_rsaandid_rsa.pub,your default keys have been generated. Otherwise, runssh-keygenPress enter for all prompts and the default keys will be generated in the correct place.ssh-keygenwill warn you it is about to override exiting keys. If it does warn, answer no.
Hey Charles! I thought I recognized your name on this gist. I was brought here via a Google search for "where do i get ssh-copy-id for windows." This PowerShell script worked perfectly. 👍
I also wanted to let you know that earlier this month I was revisiting the magnum-energy project that you helped me out with a few summers ago. I believe it was in java back then. I've made the full transition to pymagnum and it's been collecting data for me successfully again. Thank you for making that project, too. Really appreciate it.