Javascript required
Skip to content Skip to sidebar Skip to footer

How to Upload a File From Local Onto Ec2 Using Java

  • Provide feedback for data recipe

Groundwork

Yous can transfer files into and out of a Linux EC2 example from a local estimator running Windows by either of these methods:

  • WinSCP provides a graphical user interface (GUI) that allows you to drag and drop files between your local computer and your AWS case. This is similar to using Windows File Explorer.
  • PuTTY Secure Copy is run from the Windows Command Prompt

Processing using an EC2 Instance requires that you motion the files to exist processed to the instance, and then remove the products created before the instance is terminated.

Prerequisites

    • Y'all must have created a PuTTY Private Key (.ppk) file as described in the How to Connect to your EC2 Instance using PuTTY V1.1 data recipe. The .ppk file will exist used in Transferring Files Using WinSCP and Transferring Files Using PuTTY Secure Copy (PSCP).

Find Your EC2 Instance Public DNS

  1. Open the AWS Instances window in the EC2 Direction Panel ( 1 ).

The Public DNS of your EC2 instance displayed in this window ( 2 ) will exist used in the Transferring Files Using WinSCP section and the Transferring Files Using PuTTY Secure Copy (PSCP) section.

The AWS EC2 Direction Panel.

Transferring Files Using WinSCP

Download and install WinSCP.

    1. Click on Installation bundle and so use the default installation options.
    2. Outset WinSCP by clicking on the Desktop icon.
    3. WinSCP Login window.
      1. Click on New Site ( 1 ).
      2. In the Host name box ( two ), enter the Public DNS displayed in your EC2 Direction Panel Instances window.
      3. In the User name box ( 3 ), blazon "ubuntu."
      4. Click on the Avant-garde push button.
    4. Avant-garde Site Settings window
      1. Under SSH ( ane ), click on Authentication ( two )
      2. Under Private key file ( 3 ), click on the button and navigate to the folder where your PuTTY Private Key (.ppk) file is located.
        • Select the .ppk file.
      3. Click on the OK button to close the Advanced Site Settings window.

If you desire to save your settings to utilise once more afterward, click on the Save button in the WinSCP Login window and name the settings.

Notation: If you stop your EC2 instance and restart it, a new Public DNS volition be assigned. You lot will need to copy and paste this into the WinSCP "Host name" box earlier you can connect.

    1. Click the Login button
    2. The first time you connect to your case, y'all will be asked about connecting to an unknown server.
      1. Click the Yes push to go on.
    3. After you have continued, the left pane of the window volition display the file contents of your computer and the right pane displays the contents of your EC2 example.
    4. Drag and drib files from your computer into your EC2 example to process. When processing is consummate, drag and drop the products from EC2 to your computer.

Important: Files must be transferred from your EC2 case to your figurer before yous terminate the example!

Transferring Files Using PuTTY Secure Copy (PSCP)

Open up a Windows "Command Prompt" window

Windows 10

    1. Click on the Start button at the farthermost left of the Taskbar.
    2. Curl down the list of Apps to the Windows Arrangement folder.
    3. Aggrandize the folder and click on Command Prompt.
    4. Or, click the First button and type "cmd." Select "Control Prompt" from the search results.
    5. The Command Prompt window volition open.
The Windows Command Line.
The Windows 10 Taskbar.

Windows 7

    1. Click on the Start button at the left of the Taskbar.
    2. In the Search programs and files box, blazon "cmd." Select "Command Prompt" from the search results.
    3. The Command Prompt will open.
The Windows Command Line.
The Windows 7 Taskbar.

Note: When using PSCP to transfer files between your computer and your EC2 case, your "PuTTY Private Key (.ppk)" file must exist in the folder you are working in, or you must provide a path in the PSCP command to the folder the file is located. For example, if "AWSkey.ppk" file is stored in the folder named "keys," include this path in the PSCP command:

C:\Users\username\keys\AWSkey.ppk

Copy a File Into Your EC2 Example

At the Windows command prompt type (notice where spaces are placed):

C:\> pscp -i yourkey.ppk yourfilename ubuntu@public_DNS:/home/ubuntu/

Example: To move the file S1A_EW_GRD.nix from your Windows Downloads folder to the /home/ubuntu directory of your EC2 instance.

    1. Employ Windows File Explorer to move your awskey.ppk file to your Downloads folder, or provide a path to the binder your.ppk file is located in.
    2. At the Windows command prompt, navigate to your Downloads folder using the modify directory (cd) command:

C:\Users\current_user>cd Downloads            and press Enter

    1. At the command prompt, type the PSCP command, which includes your .ppk filename (and path if necessary), the name of the file y'all want to transfer, the "Public DNS" of your EC2 instance, and the path to a folder in your example:

C:\> pscp -i awskey.ppk S1A_EW_GRD.goose egg ubuntu@ec2-52-89-147-172.u.s.a.-east2.compute.amazonaws.com:/habitation/ubuntu/

Command syntax (brackets indicate optional paths to your .ppk file and the file yous desire to motion if they are not in the binder you are in):

Windows command prompt — re-create a file into your EC2 instance.

C:\> pscp -i C:\<path>\yourkey.ppk C:\<path>\yourfilename ubuntu@public_DNS:/abode/ubuntu

Copy a File Out of Your EC2 Instance

At the Windows command prompt type:

C:\> pscp -i yourkey.ppk ubuntu@publicDNS:/home/ubuntu/yourfilename C:\[local_destination_path]\[binder]

Notation that the .ppk file must be in the folder you run the control from, or you must include the path to the file in your PSCP command.

If you don't include a local destination path and folder in the command, the file will download into the folder the control is run from. In this case, the control syntax would be:

C:\> pscp -i C:\[path]\yourkey.ppk ubuntu@publicDNS:/domicile/ubuntu/[folder]/filename

Example: Move a production generated from an application out of your EC2 instance PRODUCT directory to the Data binder on your Windows calculator.

    1. Use Windows File Explorer to move a re-create of my awskey.ppk file to your "Information" folder, or provide a path to the folder your.ppk file is located in.
    2. At the Windows control prompt, navigate to your "Information" folder using the change directory (cd) command:

C:\> cd Data           and press ENTER

    1. At the command prompt, type the PSCP command, which includes your .ppk filename, the Public DNS of your EC2 example, and the proper noun of the file you want to transfer.

C:\> pscp -i awskey.ppk ubuntu@ec2-52-89-147-172.u.s.-east2.compute.amazonaws.com:/home/ubuntu/Production/F2_unw_phase.tif C:\data_files

Windows command prompt — transfer files.

Command syntax (brackets indicate optional paths to your .ppk file and the file you want to motion if they are non in the binder yous are in):

C:\> pscp -i C:\[path]\yourkey.ppk ubuntu@public_DNS:/home/ubuntu/[path]/yourfilename C:\[local_destination_path]

Important: Files must be transferred from your EC2 instance to your computer before you terminate the case!

lawsasts1975.blogspot.com

Source: https://asf.alaska.edu/how-to/data-recipes/moving-files-into-and-out-of-an-aws-ec2-instance-windows/