National Aeronautics and
Space Administration
www.nasa.gov
When you have created and launched an AWS Linux EC2 instance, you can connect to it from your computer
using the Secure Shell (SSH) protocol. PuTTY is a free SSH client that allows you to do this from a local computer
running Windows. Once the connection has been established, you work within the EC2 instance just like you
would on a local computer running Linux.
To follow this tutorial, you will rst need to create and launch a Linux EC2 instance to which you will connect.
Instructions for this are found in the tutorial titled, Create a Basic Elastic Cloud Compute (EC2) Instance.
You must have an AWS account. If you have one, click HERE to sign into it.
Generate a PuTTY Private Key (.ppk) le
1. Download and install PuTTY.
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
2. Open the folder in which PuTTY was installed (default path is C: > Program Files > PuTTY).
3. Double click on the le puttygen.exe.
e rst thing you will see is shown in Figure 4.1.
CLOUD PRIMER
Figure 4.1.
Connect to an AWS EC2 Instance –
Windows & PuTTY
Includes moving les into and out of an EC2 Instance
Cloud technology is evolving so fast that it is likely that some details in the primer may no longer match reality when you are trying to use it. If you find
mismatches (e.g. broken third-party links), please send them to [email protected] so that we can feed them into the next release of the primer.Cab
ipsum, quia consed unda am, sam doluptas nem vid maionsed ut aliquia ssinctotae pra es maiorro ribus.
v1.0/August 2020
2
4. Click on the Load button in PuTTY Key Generator (Figure 4.1) and navigate to the folder that contains the private
key le (.pem) created during the EC2 conguration process.
5. Click on the PuTTY Private Key Files button in the lower right corner of the window (Figure 4.2) and select All Files
(*.*).
6. Click the box next to your private key le (.pem) to select it (Figure 4.3).
7. Click on Open.
8. Click OK to close the PuTTYgen Notice pop-up window
Figure 4.3.
3
9. In PuTTY Key Generator, make sure Type of key to generate value is set to RSA (Figure 4.4).
10. Click Save private key.
11. Click Yes to close the PuTTYgen Warning pop-up window.
12. Navigate to the location you want to store your PuTTY Private Key le (.ppk) (Figure 4.5)
13. Give the le a name.
14. Click Save.
15. Close the PuTTY Key Generator window.
Figure 4.4.
Figure 4.5.
4
Once you have generated a private key, you can use it whenever you need to connect to a new EC2 instance.
Connect to the EC2 instance
1. Click on the desktop icon or the putty.exe le in the PuTTY folder to open PuTTY.
2. Type ubuntu@your_public_DNS in the Host Name (or IP address) box (Figure 4.6).
e Public DNS for your instance is displayed in AWS in the EC2 Management Console Instance Description in the
middle of the screen.
3. Set the Port to 22.
4. Set the Connection Type to SSH.
Figure 4.6.
5
5. Click on the + next to SSH to expand the choices in the Category pane on the left of the PuTTY Conguration
window under Connection (Figure 4.7).
6. Click Browse under Authentication parameters and navigate to the directory where your PuTTY Private Key (.ppk) le
is located and select it.
7. Click Open.
If you want to save these settings to use later, navigate to Sessions in the PuTTY Category tree. Enter a name in the
Saved Sessions box and click Save on the right.
8. Click Open in PuTTY Conguration to connect to your Instance.
If this is the rst time you have connected to your Instance, a PuTTY Security Alert will ask you whether to proceed with
the connection (Figure 4.8).
9. Click Yes to complete the connection.
Figure 4.7.
Figure 4.8
6
e EC2 instance window will appear (Figure 4.9).
To view les and directories in a Linux (Ubuntu) instance, use the ls (list) and cd (change directory) commands.
Move les into & out of an AWS EC2 Instance – Windows
You can transfer les into and out of a Linux EC2 instance from a local computer running Windows by either of these methods:
1. Windows Secure Copy (WinSCP): WinSCP provides a graphical interface (GUI) that allows you to drag and
drop les between your local computer and your AWS instance. is is similar to using Windows File Explorer.
2. PuTTY Secure Copy: PuTTY Secure Copy is run from the Windows Command Prompt.
Using an EC2 instance to process/analyze data requires that you move the les to be processed to the instance, and then
remove the resulting products before the instance is terminated.
Find Your EC2 Instance Public DNS
1. Open the AWS “Instances” window in the EC2 Management Console (Figure 4.10).
e Public DNS of your EC2 instance displayed in this window will be used in the next two sections.
Figure 4.9
Figure 3.11
You are now connected to your EC2 instance!
Figure 4.10
7
Transferring Files Using WinSCP
1. Download WinSCP. https://winscp.net/eng/download.php
2. Click on Installation package (Figure 4.11) and then use the default installation options.
3. Click on the Desktop icon to start WinSCP.
4. Click on New Site (Figure 4.12).
Figure 4.11
Figure 3.13
Figure 4.12
8
5. Enter the Public DNS displayed in your EC2 Management Console Instances window into the Host Name box.
6. Type ubuntu in the User name boxs.
7. Select the Advanced dropdown menu and, under Sessions, select Advanced.
8. Click on Authentication under SSH (Figure 4.13).
9. Click on the button under Private key le and navigate to the folder where your PuTTY Private Key (.ppk) le
is located and select it.
Instructions for creating a PuTTY Private Key (.ppk) le can be found in the tutorial titled Connect to an AWS EC2
Instance – Windows & PuTTY.
10. Click on the OK button to close the Advanced Site Settings window.
If you want to save your settings to use again later, click on the Save button in the WinSCP Login window (Figure 4.14).
A pop-up window will appear where you can name the settings.
11. Click the Login button.
Figure 4.13
Figure 4.13
Figure 4.13
9
12. e rst time you connect to your instance, you will be asked about connecting to an unknown server. Click the Yes
button to continue (Figure 4.15).
Figure 3.17
Figure 4.14
Figure 4.15
NOTE: If you stop your EC2 instance and restart it, a new Public DNS will be assigned. You will need to
copy and paste this into the WinSCP Host name box before you can connect.
10
After you have connected, the left pane of the window will display the le contents of your computer and the right pane
displays the contents of your EC2 instance (Figure 4.16).
13. Drag and drop les from your computer into your EC2 instance to process. When processing is complete, drag and
drop the products from EC2 to your computer.
Figure 4.16
Important: Files must be transferred from your EC2 instance to your computer before you terminate the instance!
When you transfer les, a copy of the les will be left on the instance. ese will be deleted when the
instance is terminated.
11
Transferring Files Using PuTTY Secure Copy (SCP)
Windows 10 Users
1.Click on the Start button at the extreme left of the Taskbar (Figure 4.17).
2. Scroll down the list of Apps to the Windows System folder.
3. Select Command Prompt.
You can also click the Start button and type cmd; then select Command Prompt from the search results.
In either case, the Command Prompt window will open (Figure 4.18).
Figure 4.17
Figure 4.18
12
Windows 7 users
1. Click on the Start button at the left of the Taskbar.
2. Type cmd in the Search programs and les box (Figure 4.19).
3. Select Command Prompt from the search results.
e Command Prompt window will open as in Figure 4.18 above.
When using PSCP to transfer les between your computer and your EC2 instance, your PuTTY Private Key (.ppk) le
must be in the folder you are working in, or you must provide a path in the PSCP command to the folder in which the
le is located.
For example, if AWSkey.ppk le is stored in a folder named keys, include the path
C:\Users\username\keys\AWSkey.ppk in the
PSCP command.
Move a le into your EC2 instance
1. At the Windows command prompt, type (notice where spaces are placed):
2. Move your awskey.ppk le to your Downloads folder using Windows File Explorer or provide a path to the folder in
which your .ppk le is located.
3. Navigate to your Downloads folder using the change directory (cd) command at the Windows command prompt.
and press Enter.
C:\> pscp -i yourkey.ppk yourlename ubuntu@public_DNS:/home/ubuntu/
C:\Users\username>cd Downloads
Figure 4.19
13
4. Type the PSCP command, which includes your .ppk lename (and path if necessary), the name of the le you want
to transfer, the Public DNS of your EC2 instance, and the path to a folder in your instance: (Figure 4.20).
Command syntax: brackets <> indicate optional paths to your .ppk le and the le you want to move if they are not in
the folder you are in
Move a le out of your EC2 instance
1. At the Windows command prompt, type:
Example: Move a product generated from an application out of your EC2 instance PRODUCT directory to the Data
folder on your Windows computer.
2. Use Windows File Explorer to move a copy of my awskey.ppk le to your Data folder or provide a path to the folder
in which your .ppk le is located.
3. At the Windows command prompt, navigate to your Data folder using the change directory (cd) command:
And press Enter.
4. At the command prompt, type the PSCP command, which includes your .ppk lename, the Public DNS of your
EC2 instance, and the name of the le you want to transfer.
C:\> pscp -i awskey.ppk S1A_EW_GRD.zip [email protected].
com:/home/ubuntu/
C:\> pscp -i C:\<path>\yourkey.ppk C:\<path>\yourlename ubuntu@public_DNS:/home/ubuntu
Figure 4.20
C:\> pscp -i yourkey.ppk ubuntu@publicDNS:/home/ubuntu/yourlename C:\[local_destination_path]\[folder]
C:\> cd Data
NOTE: If you dont include a local destination path and folder in the command, the le will download into the
folder the command is run from. In this case, the command syntax would be:
C:\> pscp -i C:\[path]\yourkey.ppk ubuntu@publicDNS:/home/ubuntu/[folder]/lename
C:\> pscp -i awskey.ppk [email protected]:/home/ubuntu/PRODUCT/F2_unw_
phase.tif C:\data_les
C:\> pscp -i C:\[path]\yourkey.ppk ubuntu@public_DNS:/home/ubuntu/[path]/yourlename C:\[local_destination_path]
Important: Files must be transferred from your EC2 instance to your computer before you terminate the instance
or they will be deleted!