If you run AWS servers from a Windows PC, you need an easy way to transfer files up and back from your work desktop to the server and back.
Linux users have the ease of native SSH tools such as SCP built in to their command tool utilities, and Windows users want the same flexibility.
Follow these easy steps and you’ll be transferring files in a flash.
1. Get PSCP
Download the Putty tool PSCP (Putty SCP) for secure file transfer on Windows. This is a freeware tool.
PSCP is a lightweight exe file. Place the pscp.exe file in a directory that you will easily remember. Hint – you’ll need to refer to it when you request file transfers.
2. Get PuttyGen
Download the Putty tool for generating encrypted keys to enable you to talk with AWS servers in a secure way. PuttyGen creates RSA and DSA encrypted keys. We will be encrypting a ppk file for AWS purposes.
Run the PuttyGen exe file and a dialog box will appear. Click on the Conversions tab from the menu bar on top. Click on the Import Key option and select your .pem keys file that you use to login with SSH to AWS EC2 server. You’ll need to create a private key (ppk) file for each pem that you use.
Make sure that the parameters are the same as in the image below, SSH-2 RSA, 2048. When the PEM file is loaded, you’ll see the keys appear as they do in the image below. Click on the “Save Private Key” button to create a .ppk file. You will be prompted with a warned that you are saving a key without a password. Click Yes and create the file. Remember where you save the file as you will need to include the file path for each file transfer. I usually give the ppk the same filename as the pem to help avoid confusion.
3. Transfer Files To and From your Amazon EC2 AWS Server
Open a Command Prompt in Windows from your start menu (or whatever Microsoft calls it these days…)
From the command prompt, you can now easily transfer files up and back. Here’s the sample syntax that you can use almost exactly as you would SCP in linux.
Let’s say you wan to copy all jpg files from your local pc to the home/ubuntu/images directory on your EC2 server
pscp -i “YourFile.ppk” *.jpg ubuntu@AWS-SERVER-ADRESS:/home/ubuntu/images
Make sure you have copied the pscp.exe to the directory you are using to copy files (or refer to it’s referential location).
You may have to change file or directory permissions on your EC2 server to make it writable. (CHMOD)
To copy files from your EC2 server back to your local PC use the same syntax as above by switch the order of the file direction – again, similar to how you’d use the SCP on linux.
pscp -i “YourFile.ppk” ubuntu@AWS-SERVER-ADRESS:/home/ubuntu/images/*.jpg .
That’s it…You’re good to go!