Cloud-SPAN logo.
  • Home
  • Precourse Instructions
  • About
  1. Files and Directories
  2. Logging onto the Cloud
  • Files and Directories
    • Understanding your file system
    • Logging onto the Cloud
    • Introducing the Shell
  • Using the Command Line
    • Navigating Files and Directories
    • Working with Files and Directories
    • Redirection
  • QC & Assembly
    • Introduction to Metagenomics
    • Assessing Read Quality, Trimming and Filtering
    • Metagenome Assembly
  • Polishing
    • Polishing an assembly
    • QC polished assembly
  • Binning & Functional Annotation
    • Metagenome Binning
    • QC of metagenome bins
    • Functional annotation
  • Taxonomic Annotations
    • Taxonomic Assignment
    • Diversity Tackled With R
    • Taxonomic Analysis with R
  • Extras
    • Data
    • Glossary
    • Workflow Reference

On this page

  • Important Note
  • Background to AWS
  • Open a Terminal and change the access permissions of your login key file
  • Login into your instance with ssh
  • Logging off your cloud instance
  • Subsequent logins to your AWS instance
  • Edit this page
  • Report an issue
  1. Files and Directories
  2. Logging onto the Cloud

Logging onto the Cloud

Important Note

This lesson covers how to log into, and out of, an already running AWS instance.

Background to AWS

An Amazon Web Services (AWS) instance is a remote computer that runs on AWS infrastructure and that is accessible from any laptop or desktop as described below. For this course, an AWS instance has been created for you by the Cloud-SPAN team.

Remote computers are also called cloud computers. They allow you to access computers with many more resources (memory, processors, disk space etc) than the average laptop or PC. This is useful when you want to run analyses that use lots of data and/or take a lot of computational power to run.

To login into your AWS instance for this course, you’ll need:

  • the name of your instance and a login key file, both of which you received via email
  • the shell/terminal application — Windows users should have already installed the Git Bash shell; otherwise follow the Precourse Instructions.
  • the secure shell (ssh) application, which is readily available in MacOS and Linux. Windows users will use ssh through Git Bash.

Open a Terminal and change the access permissions of your login key file

The first thing we need to do is change the access permissions of the login key file so it can be used safely.

1. Open the cloudspan folder you created for the course

Open your file manager and navigate to the cloudspan folder (hint: we recommended you make the folder in your Desktop directory - but you might have made it somewhere else). If you cannot find the folder, you can remind yourself where it is stored by looking at the absolute path you wrote down in the previous episode.

The folder should contain the login key file we downloaded in the previous episode and nothing else.

2. Right-click and open your machine’s command line interface

Now we can open the command line.

  • Windows users:

    • Right click anywhere inside the blank space of the file manager, then select Git Bash Here. A new window will open - this is your command line interface, also known as the shell or the terminal. It will automatically open with your cloudspan directory as the working directory.
  • Mac users, you have two options:

    • EITHER: Open Terminal in one window and type cd followed by a space. Do not press enter! Now open Finder in another window. Drag and drop the cloudspan folder from the Finder to the Terminal. You should see the file path leading to your cloudspan folder appear. Now press enter to navigate to the folder.

    • OR: Open Terminal and type cd followed by the absolute path that leads to your cloudspan folder. Press enter.

The terminal displays/outputs the command prompt to signal that it is ready to accept commands (instructions). The command prompt is 1 or 2 lines depending on your operating system (Windows, Linux, MacOS) and will be similar to the following.

Typical command prompt for Windows Git Bash users:

username@machineid MINGW64 ~
$

Typical command prompt for Linux users:

username@machineid:~ $

Typical command prompt for MacOS users:

machineid:~ username $

Obviously “username” and “machineid” in the prompt shown above will be different and will correspond to the actual username and the name of the machine you are using.

The character $ is the typical ending of user prompts (the ending of admin users prompts is typically #). Commands you type will follow the $.

IMPORTANT

In this course we will NOT show the prompt in the Code boxes so that it is easier for you to copy long commands. You can copy the commands in a Code box by clicking on the green icon on the right of the Code box.

3. Check that you are in the right folder

The terminal should have automatically set our cloudspan folder as the current working directory. This is because we asked the terminal to open from a specific location.

You can check if the working directory is set correctly by looking at the file path which is defined to the left of your command prompt ($). It should display the second half of the absolute path we wrote down previously, usually starting after your computer’s username, and always ending in /cloudspan.

You can also check by typing the letters ls after the command prompt and pressing enter. This will list all the files in the working directory AKA all files in the cloudspan folder. In our case, this should be just one file, the login key ending in .pem.

4. Change the access permissions of your login key file

Enter the following command to change the access permissions of your file but replace NNN with the actual number in your file name:

Code
chmod 400 login-key-instanceNNN.pem 

The command chmod (change access mode) makes your login key file accessible to you only (and non-accessible to any other potential users of your computer), a condition that is required and checked by the program ssh that you will use next to log in to your AWS instance. You will learn about file access permissions later in the course.

Login into your instance with ssh

Now it’s time to log in to the Cloud! You do this with a secure shell protocol or ssh. As the name implies, ssh provides you with a secure (encrypted) way to use a remote shell.

A few seconds after you enter that command to the shell in your computer, you will be logged into your AWS instance and start using a (Linux) shell running in your instance.

1. Copy and paste the command in the Code box below to your terminal, but replace NNN with the number in your login key file name.
Pasting in the shell

You can copy the command from the course materials by clicking the clipboard at the right of the code box.

However, you cannot paste in the shell using Ctrl + V like you can usually. Instead you have two options:

  • right click and select paste
  • hover the mouse pointer over the terminal window and press the mouse middle button
Code
ssh -i login-key-instanceNNN.pem csuser@instanceNNN.cloud-span.aws.york.ac.uk

Be sure to replace NNN twice with your unique instance number (the one in your key). You can use the left and right arrow keys to move to where NNN is.

The -i option tells ssh where to find the key which proves you have permission to connect to the instance.

2. The terminal will display a security message, after you enter the ssh command, similar to the message below:
Output
The authenticity of host instanceNNN-cloud-span.aws.york.ac.uk (52.211.132.120) can't be
established. ECDSA key fingerprint is SHA256:8N054prkkCeM4GCDSsa0AUnSQw5ngBQHbOR40FqfqLg.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Type yes to continue and get connected to your AWS instance.

After logging in, you will see a screen showing something like this:

Output
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-84-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Thu 21 Oct 2021 10:47:55 AM UTC

  System load:  1.68               Processes:             189
  Usage of /:   24.0% of 98.30GB   Users logged in:       0
  Memory usage: 25%                IPv4 address for eth0: 10.0.32.254
  Swap usage:   0%

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

73 updates can be applied immediately.
32 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
    _____________________________

    W E L C O M E    T O    T H E


     ____ _                 _         ______ _____   _    __   _
    / ___| | ___  _   _  __| |       / ____ |  _  \ / \  |  \ | |
   | |   | |/ _ \| | | |/ _` |  ___  \___  \| |_) '/ _ \ | \ \| |
   | |___| | (_) | |_| | (_| | |___| ____)  |  __ / ___ \| |\ | |
    \____|_|\___/ \___/ \__,_|       \_____/|_|  /_/   \_|_| \__|



    F O U N D A T I O N     C O U R S E     E N V I R O N M E N T

    _____________________________________________________________

    Scroll up with the mouse for information before this welcome

    Type "csguide" (and the Enter (↵) key) for some guidance
    _____________________________________________________________

Last login: Thu Oct 14 11:13:28 2021 from xxxxxxx

Your prompt will now look like this:

csuser@instanceNNN:~ $

Note that you did not need to give a password to log in to your instance – you are using your login key file for authentication.

Logging off your cloud instance

When you are finished using the cloud instance and want to return to your local terminal, you can log off. Be aware that AWS instances accrue charges whenever they are running, even if you are logged off. Today, however, you do not need to worry about this!

To log off, use the exit command in the same terminal you connected with. This will close the connection, and your terminal will go back to showing your local computer prompt, for example:

Code
exit
Output
logout
Connection to instance05-gc.cloud-span.aws.york.ac.uk closed.
username@machineid $

Subsequent logins to your AWS instance

To login back to your instance, open a terminal, make sure you are in your cloudspan folder and ssh as before:

Code
ssh -i login-key-instanceNNN.pem csuser@instanceNNN.cloud-span.aws.york.ac.uk
Back to top
Understanding your file system
Introducing the Shell

Licensed under CC-BY 4.0 2021–24 by Cloud-SPAN

  • Edit this page
  • Report an issue
Cookie Preferences