Learn how to transfer files between desktop and EC2 using WinSCP. Using key-based authentication, winSCP can be connected to EC2 to download/upload files from/to the server.
While working on the EC2 server hosted on AWS, one of the basic requirements you come across is to transfer data between your desktop/laptop and EC2 instance. Since EC2 uses key-based authentication, for beginners it’s hard to understand how to transfer data from desktop to EC2 cloud.
Normally, programs like WinSCP are used to transfer data between the Linux server and the windows machine. In this article we will walk you through how to add key-based authentication in WinSCP. Later how to download files from EC2 to the local machine.
Other EC2 related posts which might interest you :
- EC2 basics flashcards
- Data transfer between two EC2 instances
- Assign Elastic IP to EC2 instance
- Rsync to EC2 server
Step 1: Know your DNS name
Make sure your EC2 instance is spun up. You have the Public DNS name of your EC2 instance. You can see it under instance description in your AWS EC2 console.
Take our AWS CSA exam quiz! Check your knowledge.
Refer screenshot below :
Step 2 : Set private key for authentication
Open WinSCP tool. Click on Advanced to open settings of tool.
Under settings, click on Authentication under SSH in the left panel. This will open up authentication settings on the right panel.
Under, Authentication parameters tick ‘Allow agent forwarding‘ and browse your private key file in it. This private key file is key the same file you use to authenticate to EC2 when connecting via PuTTY
Click OK and close settings.
Step 3 : Connect
Copy public DNS of your EC2 instance, username as ec2-user for RedHat (different Linux distro has diff default logins in AWS. List of all is here) and hit connect. It will pop up to accept the key if you are connecting for the first time via WinSCP. Accept it and you will be connected to the EC2 server!
I have created small GIF which shows whole above process. Have a look .
Now you can download or upload files from EC2 to local like you normally do!