-1

I have one scheduled task on an EC2 linux system and it is generating a file daily. Now I want to transfer this file from that to another Windows machine that is not on AWS.

I want to schedule this job on the EC2 instance only. I don't want to download it from target machine, I want the upload facility from EC2.

I have tried below command:

scp -i (Key File for my current EC2 instance) (IP of target):(Local file path of current EC2 instance) D:\TEMP(Target Path of window machine)

I am getting:

ssh: connect to host (IP of target) port 22: Connection refused

We already have a functionality to store the file in S3 but it depends on the task of EC2 instance. (Sometimes it takes 1 hour or sometimes it takes 4 hours, that's why I want it at end of this task.)

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • http://stackoverflow.com/documentation/ssh/2926/debugging-ssh-problems/18370/connection-refused#t=201612021427045934467 – Kenster Dec 02 '16 at 14:27
  • Windows computers do not support `scp` by default. Are you running something on the Windows machine that can accept an `scp` connection? [scp from linux to windows](http://stackoverflow.com/questions/10235778/scp-from-linux-to-windows) – John Rotenstein Dec 02 '16 at 16:11

1 Answers1

1

The error you're receiving is most likely caused by an incorrect firewall setting on the EC2 Security Group in front of your EC2 instance, or, on your Windows server's network.

I would like to suggest using an Amazon S3 bucket to upload the file from your EC2 instance into S3. The file can then wait to be collected from your Windows instance as a scheduled job. You could delete the file from S3 after Windows has downloaded it, or use a lifecycle policy to automatically delete the saved files after a certain time.

This will remove the need to open SSH to your EC2 instance, and also enable you to save the file in S3 so that you can re-download it if you need it again.

I don't know what technology stack you're using, but you could start using Amazon S3 on both servers with the AWS CLI, or an SDK for your preferred programming language.

otakumike
  • 175
  • 8
  • we already have a functionality to store the file in S3 but it depends on the task of EC2 instance. (Sometimes it takes 1 hr or sometimes it takes 4 hrs, that's why i want it at end of this task). Downloading file from windows or s3 can result the older file download, which is not acceptable (even for one occurrence) – Vijay Vasudevbhai Gurunanee Dec 02 '16 at 11:26
  • Ok then, that make sense. Have you checked that the security group of the EC2 instance definitely allows the windows server to connect on port 22 for SSH? – otakumike Dec 02 '16 at 11:39