I am trying to transfer files to an EC2 instance that is located in a private subnet using a bastion host. My local machine is running Windows, and I am connecting to the EC2 instance via SSH through the bastion host. I am not sure how to transfer files to the EC2 instance from my local machine using only command line tools and Putty.
Here is what I have tried so far: I connected to the bastion host via Putty and then tried to transfer files to the EC2 instance using the scp command on my local pc, but I received Connection timed out error.
Can someone please advise me on how to transfer files to the EC2 instance in the private subnet using a bastion host? Do I need to store my private key on the bastion host, or is there a way to transfer files directly from my local machine to the EC2 instance without storing the private key on the bastion host?
Thanks in advance for your help.
2
Answers
By using the below command and by restricting the key files to chmod 400 I successfully transfer a file from my local pc to my private EC2 instance :
Look for
AWS Systems Manager Agent
(SSM Agent). It is preinstalled, by default, on the following Amazon Machine Images (AMIs) for Windows Server:Windows Server 2008-2012 R2 AMIs published in November 2016 or later
Windows Server 2016, 2019, and 2022
Then use a proxy to connect to the EC2 instance:
Connect to instance via Remote Desktop or Windows PowerShell
Run the following in Powershell
For more info, access AWS documentation:
https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-install-ssm-proxy.html