Skip to content


Upload Files to Your Amazon EC2 Server using WinSCP

Suppose you’ve already created an Amazon Elastic Cloud Computing (EC2) server, and are able to host simple content. Now, how do you get your existing content onto the machine? What if you need to install a new Unix program that’s not available through yum?

You could install and configure an FTP server. But enabling FTP is a security nightmare. Fortunately, there’s no need to go that far. If a server supports secure terminal sessions using the SSH protocol (which an EC2 server does), it also supports uploading and downloading files using Secure FTP (SFTP).

To access your Amazon server using SFTP on Windows, download a Windows SFTP application. My personal favorite is WinSCP; using WinSCP, you’ll be in your EC2 server instance’s file system in minutes. Download and install the application. (You can ignore the request to reboot; WinSCP’s claim that it needs to restart your system to work is pure fabrication.) Launch the application from your Start menu, and put the appropriate values into the Host name and User name fields. For Private key file, you select the same private key file you created with PuTTY to enable SSH sessions.

Click Login, and you’ll establish an SFTP session with your server. WinSCP offers some nice features that make it easy to work with your EC2 server. For example, a command in the button bar opens a PuTTY SSH terminal session using the same credentials you used for your SFTP session. (You can also launch a PuTTY session by clicking CTRL+P.)

You can now upload any content you like to your public_html directory (assuming that ec2-user can write to it), and host content such as HTML files and PHP applications that you’ve written locally.

We still haven’t touched on advanced user management. Up until now, we’ve relied upon the well-known username ec2-user for all of our server management needs. If you work on a team or hire outside vendors, giving users access to your system with the appropriate level of permissions is critical. In my next article, we’ll use WinSCP to upload an EC2 private key file (.pem) to our server, and use it to create a new user whose only job is to secure access to our Web server’s public_html directory.

Be Sociable, Share!
    The following two tabs change content below.

    4 Comments (Add Yours)

    1. I read the article “How to Host Simple Content with Amazon Elastic Cloud Computing (EC2)” . It is the best intro I have found to date. Thank you!. I followed it and everything works fine except that I cannot transfer files using WinSCP. I keep getting the error:

      Permission denied.
      Error code: 3
      Error message from server: Permission denied
      Request code: 3

      when I try to upload to any directory (i.e. the modified httpd.conf file or public_html). I can’t even change file privs. Can you offer any help?

    2. >> You can now upload any content you like to your public_html directory (assuming that ec2-user can write to it),

      This is exactly my difficulty. I get permission denied when I try to write.

      I have already done a chmod on the destination directory. It is now 775, and I dare not make it any higher! I changed all the permissions to 775 all the way up the tree to /var, which doesn’t seem like a good idea,

      What can I do to make it possible to drop files into this directory?

      Thank you.

    3. Figured it out!

      I had to use chown to make me the owner of the directory. Whew! 🙂

    4. Hi,

      I have installed FreeSSHd on my Widows 2008 server, it is a Amazon cloud instance.
      I get connection timed out error when connecting to it.
      I have opened SSH port in Security group settings on AWS console.

      Can you please help me with this ?

      Mayuresh Mulye

    Add Your Comment (Get a Gravatar)