Connecting to the Virtual Machine using SSH
Lab Steps
Introduction
In this lab step, you will employ a Secure Shell (SSH) client to connect to a remote Linux server. SSH is a cryptographic network protocol for securing data communication. SSH establishes a secure channel over an unsecured network. Common applications include remote login and remote command execution.
Note: If you are connecting to an instance automatically created by the Cloud Academy Lab environment, it can take a few minutes to appear. If the instance is not visible, please refresh after a minute or two until it appears.
Â
Instructions
Downloading the appropriate key pair
If you are using Linux or macOS, download the Privacy-enhanced Electronic Mail (PEM) key pair automatically generated by the Cloud Academy platform. If you are using Windows, download the PuTTY Private Key (PPK) key pair. Both the PEM and PPK are available in the Credentials section in the upper-left corner of this lab.
Note: Cloud Academy enterprise accounts also provide an enterprise bridge feature that allows you to bypass corporate network and software installation policies that may otherwise prevent you from completing this lab step.
Â
Locating the virtual machine IP address
1. In the AWS Management Console search bar, enter EC2, and click the EC2 result under Services:
Â
2. In the left-hand menu, click Instances:
The Instances list page will load.
Â
3. Select the target virtual machine and look for the Public IPv4 address field:
The IP address is displayed in the Networking tab and as a column in the Instances list.
Â
4. To copy the Public IPv4 address, next to the IP address, click the copy icon:
The public IP address of the instance has been copied to your clipboard.
Note: If you are connecting to an instance automatically created by the Cloud Academy Lab environment, it can take a few minutes to appear. If the instance is not visible, please refresh every minute or two until it appears.
Â
5. Paste the IP address somewhere you can easily retrieve it.
In a moment you will use it to connect to the instance.
Cloud Academy recommends using a draft email to temporarily store notes during a lab.
Â
Connecting using Linux/macOS
Linux distributions and macOS include a SSH client that accepts standard PEM keys. Complete the following steps to connect using the included terminal applications:
a. Open your terminal application. If you need assistance finding the terminal application, search for terminal using your operating system's application finder or search commands.
Â
b. Enter the following command and press Enter:
Copy codessh -i /Path/To/Your/KeyPair.pem AMIUserName@YourIPv4Address
where the command details are:
ssh initiates the SSH connection
-i specifies the identity file
/Path/To/Your/Keypair.pem specifies the location and name of your key pair. An example location might be /Home/YourUserName/Downloads/KeyPair.pem.
AMIUserName specifies the SSH user:
For the Amazon Linux Amazon Machine Image (AMI), a standard SSH user is ec2-user.
For Ubuntu images, a standard SSH user is ubuntu.Â
For CentOS images, a standard SSH user is centos.Â
For Debian images, a standard SSH user is admin.
For Red Hat 6.4 and later images, a standard SSH user is ec2-user.
YourIPv4Address is the IPv4 address noted earlier in the instructions.
Note: Your SSH client may refuse to start the connection due to key permissions. If you receive a warning that the key pair file is unprotected, you must change the permissions. Enter the following command and try the connection command again:
Copy codechmod 600 /Path/To/Your/KeyPair.pem
Â
c. Â After successfully connecting to the virtual machine, you should reach a terminal prompt similar to the one shown in the image below.
Note: If you receive a warning that the host is unknown, enter y or yes to add the host and complete the connection.
Â
Connecting using Windows
Windows does not include an SSH client; you must download an application that includes one. A free, and useful utility, is called PuTTY. PuTTY supports SSH connections, as well as key generation and conversion. Download PuTTY at http://www.putty.org. Complete the following steps to use PuTTY to create an SSH connection.
a. Open PuTTY and insert the IPv4 public IP address in the Host Name (or IP address) field.
Â
b. Navigate to the Connection > SSH > Auth section. Select the PPK key pair you downloaded earlier, and click Open.
Â
c. Wait several seconds for the authentication prompt. Enter the SSH username for the virtual machine operating system, such as ec2-user for Amazon Linux, and press Enter.
Additional example SSH usernames include:
For Amazon Linux, a standard SSH user is ec2-user.
For Ubuntu images, a standard SSH user is ubuntu.
For CentOS images, a standard SSH user is centos.
For Debian images, a standard SSH user is admin.
For Red Hat 6.4 and later images, a standard SSH user is ec2-user.
Â
Summary
In this lab step, you connected to a virtual machine using an SSH client.Â