I did this to copy files between Windows and Linux.

C:\Documents and Settings\668340\My Documents\putty>pscp  "C:\Documents and Settings\563456\abc.txt" "[email protected]:/home/auto/"

But it prompts for a password and how do i automate this task using private/public key pairs between windows and linux

Even winscp works but only problem is that i have to use hard coded password in the code, which I don't want. Instead I want to use private/public key addition concept but not aware how to do it when it is windows.

EDIT:i mean i can go with passwordless authentication but still it involes ,the manual process of generating public,private keys(.ppk) using puttygen.exe in windows and then copying the public key to .ssh\authorized in linux.is there any way to automate this.

EDIT:if there is any of copying files by running some shell script of command in unix to copy file to windows that could also be usefull as i can create public/private keys in unix automatiaclly.

  • 1
    You can use the same public/private key pair on all your windows machines. Copying files from unix to windows is difficult (only way is using SMB/CIFS), but you e.g. run a web server on your unix machine and then let the windows client download files using e.g. wget compiled for Windows
    – jofel
    Jan 25, 2013 at 11:21

3 Answers 3


As you want to authenticate without prior key exchange, I see no other option than using password authentication (at least the first time).

So you need to hard-code the password in your script. You can give the password to pscp with its -pw option. But, I do not know how safe this is (at least in Linux, all user normally can see the command line of all processes).


Since you don't want to type passwords or generate keys, I suggest the following:

  1. disable networking on both machines (security first!).
  2. enable password-less login on both machines.
  3. insert a floppy disk into machine A and copy the files onto the floppy.
  4. remove the floppy from machine A and walk to machine B.
  5. insert the floppy into machine B and copy the files onto machine B.

If you happen to have a Win 95 machine then you'll be excited to know that this is the networking model for which it was designed.


EDIT following the update of the question:

The easiest way to copy files over network is probably SMB/CIFS - on Linux side you'd use SAMBA to either provide network share for Windows or to mount sharres exported by the Windows machine.

If you want to use ssh a look at PuTTY, which includes command line scp, that should be able to use key authentication. But then again: is it acceptable in your situation to use keys not protected with a password?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .