Replacing ssh-copy-id on Windows

Save a few keystrokes on occasion

Posted by David Van Loon on January 28, 2019

The ssh-copy-id command is useful for configuring a server to allow authentication with a given set of SSH keys. Read more on the command here.

Windows comes with a built-in SSH client. It’s an optional feature, however, so it must be enabled before use. One missing component is ssh-copy-id. Many options exist that replicate its behavior, but I wanted something very simple that I could stash in my PowerShell profile.

Here’s what I created:

Examples

To copy default credentials, either from the SSH agent or from ~/.ssh/id_rsa.pub, run:

ssh-copy-id user@host

To specify the identity file to copy, run:

ssh-copy-id -i ~/.ssh/identity_file.pub user@host

This fulfills the main functionality of ssh-copy-id, but it doesn’t handle most error cases or any extended options. As such, it’s not intended to replace the original tool, but instead to simply provide a shortcut for Windows users of the built-in SSH client.

For the best SSH functionality on Windows, I recommend using the SSH tools available in the Windows Subsystem for Linux.