Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

6 Answers 6

up vote 13 down vote accepted

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.

share|improve this answer
Thanks! I couldn't get it to work at first; I was getting "access denied" errors back, but plink wasn't stopping to let me enter the password. I then tried passing plink the password using the -pw switch and that worked. Do you know if there is a way to get plink to pause for you to enter the password mid-way through? –  Matt V. Jan 20 '11 at 22:45
Not really sure about password authentication and plink. Whenever I actually use it I already have my key on the system, and I have pagent running. –  Zoredache Jan 20 '11 at 23:17
plink.exe -pw password works. Also if you know .ssh/authorized_keys exists the command is simply type id_rsa.pub | plink.exe -ssh user@host -pw password "cat >> .ssh/authorized_keys" –  KCD Apr 15 '14 at 0:50

ssh-copy-id does a couple of things (read the man page for details), but the most important thing it does is append the contents of your local public key file to a remote file called authorized_keys.

  • You could do this yourself by opening the key file with a text editor and pasting the contents in the Kitty terminal.
    echo 'long_line_with_contents_of_public_key_file' >> .ssh/authorized_keys

  • Alternatively, you could upload the file using WinSCP (which uses sftp, or scp as a fallback) and do something similar to my previous suggestion, without the ugly copy/pasting.
    cat id_rsa.pub >> .ssh/authorized_keys
    where id_rsa.pub is the filename of the public key you uploaded.

share|improve this answer

These answers didn't help me out. I really didn't need any crazy scripts. I had created a public key on my client machine in git bash and was trying to copy it to a VPS.

After creating your public key, the key should be stored as "(whatever folder you started in)/.ssh/id_rsa.pub"

So use this command:
cat ~/.ssh/id_rsa.pub | ssh user@ "cat >> ~/.ssh/authorized_keys" where user is your username (sometimes "root", or whatever you may have set up), and replace with your machine / host / VPS's IP address.

If the directory .ssh is not yet created on the host machine, use this small variation:
cat ~/.ssh/id_rsa.pub | ssh user@ "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"

share|improve this answer

Inspired by zoredache's answer, I've created a bunch of scripts that are the windows version. However they all depend on plink. Please take a look here


I also have a winscp script that can be used as per another answer. :) Excerpt from the readme:

Attempted methods so far:

  • DOS(.cmd) - Success
    • usage: .\Scriptname test@example.com password [identity file]
  • VBS (.vbs) - Success
    • usage: .\Scriptname /i:idtest.pub user@example.com /p:password
  • Powershell(.ps1) - Success
    • usage: .\Scriptname -i idtest.pub user@example.com password
  • mremoteNG (ext app) - Success
    • Select Host, right click, external tools, select Scriptname
  • WinSCP script (.bat) - Success
    • # "WinSCP.com" /script=".\Scriptname" /parameter "user[:password]@example.com" "id_rsa.pub" [/log=".\copyssh.log]"
share|improve this answer

If you are using cmder (or msysgit/mingw that has scp & ssh), I just wrote a simple python script for this. It can be found here: https://gist.github.com/ceilfors/fb6908dc8ac96e8fc983

Sample usage: python ssh-copy-id.py user@remote-machine.

Password will be prompted upon running the script.

share|improve this answer

you dont need to alternative for ssh-copy-id because you needit in linux so just write it there and get the results.

share|improve this answer
Many people administer linux machines from a windows machine. So it's reasonable to have an easy path to distribute out the auth keys from a windows machine. –  nos Oct 8 '12 at 10:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.