Contents » Using WinSCP » Guides » Cloud Computing »

Connecting Securely to Amazon EC2 Server with SFTP

With WinSCP you can easily upload and manage files on your Amazon EC2 (Elastic Compute Cloud) instance/server over SFTP protocol.

Before starting you should:


Collect information about your EC2 instance:

  • Host name: Check Public DNS column on Instances page of Amazon EC2 console. Note that the public DNS may change when instance is restarted.
  • Host key fingerprint: On the first connect you will be prompted to verify server host key.
    • You can locate key fingerprint in server’s initial start log, when host keys are generated.1) Use Actions > Get System Log command on Instances page of Amazon EC2 console:

      Alternatively use aws ec2 get-console-output command.
      Look for RSA (or DSA) key fingerprint. WinSCP does not support ECDSA keys.
    • If you did not save the fingerprint on the first instance run, but you have another EC2 instance that you can connect to safely (you know its fingerprints), you can connect to the target instance using private IP from the trusted instance. Staying within private Amazon network keeps you safe from man-in-the-middle attacks. When on the trusted instance terminal, you can use following commands to collect fingerprints:

      $ ssh-keyscan <target_instance_private_ip> > ec2key
      $ ssh-keygen -l -f ec2key
      2048 cc:3d:ac:a7:13:61:4c:14:25:47:80:ae:f1:f3:aa:10 (RSA)
      256 ea:bc:4d:5f:ae:00:48:75:45:ba:97:43:fe:e1:a3:e9 (ECDSA)

      With OpenSSH 6.8 and newer, you need to add -E md5 to display MD5 fingerprint.

    • If you do not have another trusted instance, you can create new temporary instance, just for the purpose of collecting the keys. First find keys for the new temporary instance, using it’s initial start log. Then collect keys of the target instance by connecting to it from the temporary instance. After that you can discard the temporary instance.

Start WinSCP. Login dialog will appear. On the dialog:

  • Make sure New site node is selected.
  • On New site node, make sure SFTP protocol is selected.
  • Enter your EC2 instance public DSN name (see above) into Host name box.
  • User name differs with instance type:
    • For an Amazon Linux AMI, the user name is ec2-user.
    • For a RHEL5 AMI, the user name is either root or ec2-user.
    • For an Ubuntu AMI, the user name is ubuntu.
    • For a Fedora AMI, the user name is either fedora or ec2-user.
    • For SUSE Linux, the user name is root.
  • Press Advanced button to open Advanced site settings dialog and go to SSH > Authentication page.
  • In Private key file box select the .pem private key file. WinSCP will need to convert the key to its .ppk format (you can then use the converted .ppk key for example with PuTTY SSH client).
  • Submit Advanced site settings dialog with OK button.
  • Save your site settings using Save button.

  • Login using Login button.
  • Verify the host key by comparing fingerprints with those collected before (see above).

If you are managing a large amount of servers, and it is not feasible for you to save a site for each of them in WinSCP, consider using an user script that injects "Open in WinSCP" link to an Amazon EC2 management portal.

Connecting to EC2 instance in VPC

To connect to an EC2 instance in an Amazon VPC, you can tunnel through a NAT instance.

For details, see a guide to connecting to an SFTP server which can be accessed via another server only.

Further reading

1) Using cloud-init script.
  guide_amazon_ec2.txt · Last modified: by martin

Search Documentation

This page


About donations

$9   $19   $49   $99

About donations



Site design by Black Gate