Windows – n equivalent to ssh-copy-id for Windows

file-transferportsshssh-keyswindows

Is there any equivalent or port of ssh-copy-id available for Windows? That is, is there an easy way to transfer SSH keys from a local machine to a remote server under Windows?

In case it helps, I'm using Pageant and Kitty (a Putty alternative) already.

Best Answer

ssh-copy-id is a pretty simple script that should be pretty easy to replicate under windows.

If you ignore all the parameter handling, error handling, and so on, these are the two commands from ssh-copy-id that are actually doing the work most of the time.

GET_ID="cat ${ID_FILE}"
{ eval "$GET_ID" ; } | ssh ${1%:} "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys" || exit 1

Using the putty tools a command like this should be equivalent (not tested).

type  public_id | plink.exe username@hostname "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys"

If you want to do all the same error handling, and the automatic key location, I am sure writing a script under Windows will be a lot trickier, but certainly possible.

Related Topic