login about faq


I have w2kserver and having ssh 4.3. The remote host that I need to transfer file from has SSH 4.3 and is a unix server. I need to automate file transfer from the remote host to w2kserver using public/private key? How can I automate this without any user intervention at any point of time. Appreciate sample automated scripts.


asked Apr 12 '10 at 12:56

ssh2's gravatar image


One way to do this is to create a public-key pair in the remote (Unix) server and configure an automatic job to perform the transfer to the windows server on a regular basis.

Some links on how to do each of these steps:

Generate a key in the remote host: http://productdocs.ssh.com/support/documentation/online/ssh/winhelp/43/key_generation.html

When the times comes to generate the passphrase one easy option at first is to create an empty passphrase. To make this more secure a passphrase protected key could be setup using an ssh2-agent ( http://productdocs.ssh.com/documents/32/ssh-agent2.html )

Upload the key from the client to the server:

  1. Create a .ssh2 directory on the w2kserver host under the user profile directory of the user that you will use for the connection. This will have to be done in the command line since windows explorer doesn't allow creating folders that start with a dot. So if the user is "username" this will be in: C:\Documents and Settings\username.ssh2\

  2. Copy the public key file of the key pair that was generated in the Unix server (.pub file) to the .ssh2 directory

  3. Create an authorization file on the .ssh2 directory:

    This is a plain-text file called authorization on the .ssh2 directory (for example using Notepad). In the text editor, add a new line containing the word key, a space and the file name of the public key. For example, if the public key file name is id_dsa_1024_a.pub, add the following line to the authorization file:

    key id_dsa_1024_a.pub

    (Substitute your public key filename for id_dsa_1024_a.pub.) If you have multiple key pairs which you use to authenticate yourself, put each on a separate line: key pub_key_one.pub key pub_key_two.pub

    Make sure to save the file as "authorization" (to omit the default file extension .txt, enclose the file name in quotation marks) and close the text editor.

    Note that this is all much easier to do with newer versions (6.1) of Tectia: http://answers.tectia.com/questions/8/how-do-i-setup-public-key-authentication-with-tectia

  4. Then use scp2 to transfer files from the Unix host to the w2kserver

    scp2 -o BatchMode=yes -o AllowedAuthentications=publickey localfile_on_unix_host username@w2kserver:/C:/dest/dir/for/file/
  5. Finally set this up in a cron job on the Unix server so that it happens every hour/day/etc and you're set


answered Apr 21 '10 at 19:05

Roman's gravatar image

Roman ♦♦

edited Sep 13 '10 at 05:12

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Apr 12 '10 at 12:56

Seen: 6,366 times

Last updated: Mar 28 '11 at 14:22

All user contributed content licensed under the cc-by-sa license.
Powered by OSQA.