---
author: Sam White
toc-title: Contents
toc-depth: 5
toc-location: left
date: 2016-11-04 22:09:56+00:00
layout: post
slug: computing-retrieve-data-from-amazon-ec2-instance
title: Computing - Retrieve data from Amazon EC2 Instance
categories:
  - 2016
  - Genotype-by-sequencing at BGI
  - Olympia oyster reciprocal transplant
tags:
  - AWS
  - EC2
  - olympia oyster
  - Ostrea lurida
  - pyrad
  - scp
  - ssh
---

I had an existing instance that still had data on it from my [PyRad analysis on 20160727](https://robertslab.github.io/sams-notebook/posts/2016/2016-07-27-data-analysis-pyrad-analysis-of-olympia-oyster-gbs-data/) that I needed to retrieve.

Logged into Amazon AWS via the web interface and started my existing instance (via the Actions > Instance State > Start menu). After the instance started and generated a new public IP address, I SSH'd into the instance:


    
    <code>ssh -i "/full/path/to/bioinformatics.pem" ubuntu@instance.public.ip.address</code>



NOTE: I needed the full path to the PEM file! Tried multiple times using a relative path (e.g. ~/Documents/bionformatics.pem) and received error messages that the file did not exist and "Permission denied (public key)".

Changed to the directory with the PyRAD analysis and created a tarball to speed up eventual download from the EC2 instance to my local computer:


    
    <code>tar -cvzf 20160715_pyrad_analysis.tar.gz /home/ubuntu/data/analysis/</code>



After compression, I used secure copy to copy the file from the EC2 instance to my local computer:


    
    <code>scp -i "/full/path/to/bioinformatics.pem" ubuntu@instance.public.ip.address:/home/ubuntu/data/20160715_pyrad_analysis.tar.gz /Volumes/toaster/sam/</code>



This didn't work initially because I attempted to transfer the file using Hummingbird (instead of my computer). The SSH connection kept timing out. The reason for this was that I hadn't previously used Hummingbird to connect to the EC2 instance and Hummingbird's IP address wasn't listed in the Security Groups table as being allowed to connect. I made that change using the Amazon AWS web interface:

![](https://eagle.fish.washington.edu/Arabidopsis/20161104_ec2_security_groups.png)(http://eagle.fish.washington.edu/Arabidopsis/20161104_ec2_security_groups.png)

Once transfer was complete, I terminated the EC2 instance and the corresponding data volume.
