Loading...
 

Creating a basic linux instance in the cloud - AWS

1. AWS Login

Log in to your Amazon Web Services account, using the “My Account” menu option and choosing the “AWS Management Console” link (as shown below).

r4KrlB25yw41B29EEl3AeoETOjXsuhVHxVpo2mctcpganodS5nSgynSpivnam9HeTBk1TxNsJX3dpP4mEyOtMIegle2kViMMVpkc2LIQ81BJpSZomLyXDN6aPLr0ZmaWNWSZZA1d

 

The AWS management console page will look something like below;

-wb7M1-bl2d_rch4CIpAXu9Bt0keBHGBwKwrEN8MhWZrFx559KQg_7NVwy47ZboUeYjUFvaFSk-5XHad-FRm-91WJyMQFxL5nndvE71CXHRYom26hWw3F1yevTyOamI2BRdYtRc3

2. Elastic Cloud Compute (EC2)

Click on the “Services” option in the top menu bar and then click “EC2” under the “Compute” group, to go to the EC2 management console.

eNphH-xvtTLY_hiZLAaimcYYUaJSiP9wx52AProkVbyeO3qShdJcGdtQW_2EPYCtHiaT6rzihFo_u74xgeQ0_Ep_ltfhjLVwNcuyHrE9v4ZNCxChQxzrk_NdhFXyZPBhkf_XC5Fr
 

2.1. EC2 menu options

The EC2 console has a left hand side menu bar that has options grouped under “Instances”, “Images”, “Elastic Block Store” etc. By default the EC2 console displays the “EC2 Dashboard” menu option.

zzc-k34dnWt9PFe-d9oLKE4FBfC8S5Tny45uDq6V-PlFDZPKHiuuW5Zs6e93liGzMxo88nBtWO9GmMuKJ2kThRJsGx9Q3vtfa8TRep-JCbUyYTBTXPuc6vT7wUPS6RxrVbnOBIC7

The above screenshot shows that there are no running instances, no volumes, no elastic ips, 10 key paris, 1 snapshots etc. This is the summary of all the existing EC2 related resources in this account. Clicking on any of those (for example… “10 Key Pairs” will take you to that section of the EC2 console).

2.2. Creating an on-demand Instance

2.2.1. Click on the “Instances” menu option, from the left hand side menu. The instances window provides information about all your created instances. Currently there are no instances created in this account.

Ia_FcuhYFAxACxtfKx3skAiaAywccvzYVPThv53xpaIA1ILn6lXR5h09eYUeS-cQVnIabtOu2UAnwLWg1PDsA3tbNJDxdTEuMlrpXYXtq2_l1I3sEBd-Wz2GzB83h_nDbGTndiD2


2.2.2. Click on the “Launch Instance” button. This will open up a workflow with 7 steps. The very first step is to choose an AMI (Amazon Machine Image).

zGzOsdDeoBTVuCK_abmFZZwmi1ZwSe8zlaSeuc9dlZV7neaANSXv4mh9CHQf8nzp8Rn3w3Jt05cUo3vZb0k5WDjPKK4cMESVuCLchrlbApiPQYNGZ49iDzZ0Ewaj5hW8P3xPJPTR


2.2.3. Scroll through the list on the right hand side, until you see “Ubuntu Server 16.06 LTS…”. We are going to select (Click “Select” button)  this Ubuntu linux server operating system image, to create an instance of it running in the AWS.

mukw6kAUkLewE55W3ABaEwb9S8qpBSHHjzXp9C_hXR-SXs1fD415bnjdqNwS5EcM7voTQPul0AtHC3lfRiWMvLSkjrsqgvPaZHv6iyU5f8Z8siVU1mP11v3dHz8W9NPgJYKSf0al=


2.2.4. After the AMI is selected, we need choose the instance type in Step 2. Scroll through the list and click on the little left hand side box to choose the instance type (in the below example we are choosing the “t2.micro” instance type - the selection is shown as a blue filled box).

8TI_OeqClX27wzzeIBCRfnPRhe4kEbqKgZX1TUGshQVoHIog-Y6w-ibuKSXcjBq0SIvQLfM7pjGaIXReppxzuIvHnf4pKUi7_wA66sGZHq-oXrVEvdrkYPl5j1D3rO62s7fYoQ90


2.2.5. Once the instance type is selected, click the “Review and Launch” button at the bottom of that page (shown in the above screenshot). Scroll through the page, make sure you have the correct AMI and instance type. Click the “Launch” button at the bottom of the Step 7: Review Instance Launch page.

wXfc42vJPh5F6If8BuhiOGx9rzsnVUxSikmjnhll4mXOV5w83IJdHe4ePEO2AQ32CwVyrNeLa1HjQo37JaChFSJYJ7xpknjpJJ40fqcHk1LvBEkBi0yBm0IqFMWbcylUdCq3q_v2


2.3. Setting the Key Pair

Clicking the “Launch” button will bring up the key pair creation/selection window.

  • Make sure you have the “Create a new key pair” option selected.

  • Provide a meaningful keypair name.

  • Click the “Download Key Pair” button, to save a key file in a secure location.

  • Click the “Launch Instances” button, to launch your instance of Ubuntu in AWS, as a 1 vCPU and 1 GB RAM machine.

hUpbtRtMzthcqT2foHOcK2m0urRyA42SMdNcYzG0HMaHFNL0gxnuq56ODuOkGIqJv-A8gjBUef8SAeX4pRmmb0QnUZdII2wxMdIkJ5SlllDnguHoDAhpu4Uuym379NAiavF0vI5-


2.4. Instance Information

Click on the instance id shown in the resulting “Launch Status” page, to go to the instance window, in the EC2 console.

piTnxiUIOW1BAkZmtuYUubdX8mVB1SsytRz5OEiVB58316hosMXK1UilRtzGaS85BpSivjv27j8eSvEji3bomZ9QICvr06veqeAfse8yNtYUSqenzr0ErV9jVHlJ1YU6E72llCbn


2.4.1. The instance window has two main panels.

  • The top panel (yellow highlighted) provides a list of all instances running, stopped or terminated. Use the horizontal scroll bar in the top panel to look at all the instance related information.

  • The bottom panel (blue highlighted) provides all information related to a selected instance (selection shown a blue checked box). Use the vertical scroll bar in the bottom panel to look at all the instance related information for a specific instance.

oKdk64e-GS0XR9WTw8CKRv7YAG1CSuUsj7fIa6BjT47fyeRAIz0Jvxi9P3tw6YD9pMypKcs2vv1CpkxQM4ic7GdrtBxaD65JmZHX7Hj3o-GNV2koSUiL5XeOH86h-Uox_5WjC741


2.4.2. Instance IP address

Select your instance of choice and (with the “Description” tab on), note down your instance IP address (54.200.164.251 in the below screenshot, yours will be different).

 

auZ6I7hD4gpwP1ORPcIHUZ3pBQDjMyCeSwH53NZIZtbC9TFMT0hP9wfwvlMqNf0HYPahGQirgeR1IfrQQY66ih0bVXBxdH55reEiqzwqNfv8B_lbOkLytdYOZFn_-muWbjvjdYp0

 


2.4.3. Instance storage

Scroll down the bottom panel (with the “Description” tab on) until you see the “Root device” option. This is the device (like a hard drive) where all your software (operating system) is stored. Click on the device name (in the below example it is… /dev/sda1).

6QLq6b2EWCft4RpgY26I2TTiLYb_cfXAWyLAv_dW7SuhoIJ_i7kNF5FpCF711miAlhLHePzd86mfsztpw1XUL5tL9tIo9YyK7IKNYne_SRHrF1wsOleyP4zPVSDMpr8l89Lua3mH

 


2.4.4. In the resulting “Block Device” information window, click the “EBS ID”. This is take you to the “Volumes” menu option.

1dCXNW0zUX4XPqD21lQT6o0bkdOSZcmxNt1GO4jwH2RfS6EGodvmua-PaBlHlu42uWicsYnFboxsGpFzWHrxtksSsEtWjh094_cj_GL9dYB6MDwwrnPh7tJDANsb73wq05lErHr_


2.4.5. The Volume menu shows the volume (aka device or hard drive or storage) where the root (aka operating system software) is running from. We can see that it is a 8 GB volume and is with the “In-use” state.

JxFbdd-qVEtNnto3hnsLbQA6SgIuzcw6G64tt1OCISPykRAy9SMgLOb1icHC8niqCGm5NUVyogxmimAd9xzlXiZXvXQJZt2osINYi0TbAZtFgL4J0QyYhcAZb_H95Y2hh4ZdExvZ

3. Working with an instance

3.1. Connect to an instance (from PC)

There are multiple ways you can connect to your linux instance that is running. We are going to use an SSH client to connect to our t2.micro instance.

You need three things to connect to your instance;

  1. Instance address (ip address)

  2. Instance user name (“ubuntu” for this instance)

  3. Instance key pair file (“nih1.pem” for this instance)


3.1.1. Using Putty in a Windows machine

Search for the program “puttygen” in the windows machine or start puttygen from the putty installation folder. The puttygen icon looks like this;

kL7vNtJP2b-HrEeqZX0edLRWkwzhVplrHg-CkSAao3aPdKhMy9jvuN1xEwO28DncYbzaavbuNAt9WXsBd-WeTvapPd4t7qc3bBdGnLtkeIG3STI-G6MMadPQMmgPKTN06NlEFm0l


3.1.2. In the Key Generator windows, click the “Load” button, change the file type to “All Files” and choose the “nih1.pem” file and click “Open”. If everything goes successfully, you will see a putty notice. Click “Ok” to discard that message.

EUsOy07wbFTd-23hOXqkuPpNZjw_GyvEoGQAsrjLmyFkrO07BbamKcdRUaYQit69hiTJ4BKDyMfQ7lWygccS1IRFVCo-KPjgzkzy-z8IJmvbr7VSguvKRiit0XJzOx9TYgfiLJ_f


3.1.3. Back in the Key Generator window, click the “Save Private Key” button and save the key with the same name as the original downloaded key (nih1). Say “Yes” to discard the message about key passphrase. Close the Key Generator window after saving the .ppk file.

ufWDPDGWejuNtlcisvDZdiWej4N93j_yuHN2SpUO_qggG0Jtm8GvThySInxxdGbYRqRr2htqHY5Ci018L_yiVq4gU6bylyF7V4L_iXjesoPmeWRcXr7UH2siWUQ_ofKwv5sDEOxT


3.1.4. Start Putty from your putty installation folder or by searching for it in the windows start. The putty icon looks like this;

8-7mGGxWA7m5ScBoEpz1dKzIpp-d1w_kCzigRXAKYMII9NrfyaCieMdO8JGIq6Ph6KuYX0fJXb9JhZpCm4dSntDLkq5jY279CD0bIUMt6mwty9RP4Ajw3e7a2pUKW8r7DLjQz4my


3.1.5. In the Putty Configuration window, enter your instance IP address for the “Host Name” and make sure “22” is chosen for Port.

HM6_S-zfKJP0mciUpHGKtlQ2LPmoxoFw5qfjlsWu4a5TqoJ0OzKSEnssWEaGyfY4Gf-WYLOsRDzcHBhfpbWlpTJIC3iXnPi65Olqwtoa4MED6q7sfNVLni79w943KXjLbLlps8D9


3.1.6. In the same Putty Configuration window, click the “SSH” option to expand it and then click “Auth”. In the resulting “Options controlling SSH authentication” window, use the “Browse” button to set the path for the nih1.ppk file.

HAJYAVSzdq05cyASia2tUanKPvbmcXInVgjzGSvOOVPNuhIQnJ2kL_bC4-eCB34A0PnyZ-7DXRALs1JvUaqhyKCwMvuLJPWVUzGSn_sq6HtKScpSUYH0vM-x6osLfAlCXyB0nbeo


3.1.7. Click “Open”. This will prompt the “Putty Security Alert”. Press “Yes” to accept the signature of the computer.

c9Y2UL313lIwPHjLw7K25FK4JCzWYfH_cpzEnieq7qSNTw-hbyEFlx74RgBF-pHg-23ud1PHbP9XLgnFUjCO1l2qwPDykInPP9EYqHgJ-p4wi2Wf0p0jXuVgq5c2NV8jQfTLX637


3.1.8. When prompted, enter “ubuntu” as the login name:

nYjNGNcrqb8CvQYRJ7b7mCWb8dtGrNRn9wdfIbNwPcVIrwovxJhGAgd4Rd0_oeV-8ShyNZA-YAzmfMMlg07HmF9r4cg8DhEg3p6xKS7h5zKtTkByoIkeUqZvMoEeXnN7MPyHpD-0


3.1.9. If you get any errors, close the existing putty window, start a new putty window and try to connect again using steps 3.1.5. to 3.1.8. If successfully connected, you will see the ubuntu shell prompt, which is now ready for you to work.

3svHMhB5IASG4aOoxHE7thFDH4KGoaZHwvOVO-YpB4z5lJfTGjMEDCSBan2kMRkO3TQj4jMi1bB15oTrs17q0jNeMawktTxgZpO7j3Lk5RndaKwRVlBUUQ-uZgqZ7gw6WpNZ20wu

 

To get out of the machine (not shutting down, just logging out), just close the putty window.

3.2. Connect to an instance (from Mac)

3.2.1. Start the “Terminal” in your Mac machine. You can find the “Terminal” app in your “Applications” - “Utilities” folder.


3.2.2. You can also type “terminal” in your mac spotlight to find the Terminal application. Click on the Terminal icon to start the terminal.

6B8ZehmeUtk4BfNZyE9XYQoSgtMVXh1k7HlnUj-eRpXrMdoEat9GozgbCMOuoGvuGDfbDIwR80MZnq8WCHgeacBnFZVDN3kg8U8Sh9QtCTGdsW6Lx2WXUYWTFgSVQ9mgB8Q_U-cZ


3.2.3. In your terminal, change to the directory where you downloaded the .pem keypair file. Usually your terminal will start in your home directory. From there, typing “cd Downloads” will change to the Downloads directory (if that is where you have the .pem keypair file). Once you are in the appropriate directory, run the following command (type it in the terminal and hit enter to run it) to change the keypair file mode;

chmod 400 nih1.pem

3.2.4. Once the .pem file mode is changed, you can connect to your instance by running the ssh command as shown below;

ssh -i “nih1.pem” ubuntu@54.200.164.251

The above command will log you in to your linux instance. If asked, accept the key signature question.

Just close the terminal to log out of your linux instance.

3.2. Stop an instance

Your instance will be charged for compute as long as it is running (if STARTed). If you want to keep your instance - but dont want to pay for the compute charge, you can STOP it, like physically turning it off, and START it at a later time.

To stop a running instance

  • Go to your EC2 console web page.

  • Chose the Instances menu option

  • Check the running instance that you want to stop

  • Click Actions menu, then “Instance State”, then “Stop”.

    • If you get any warning messages, ignore them and “Stop” the instance.

A6pT7qHTRPP4wy94hpKCmVtTXZe5W55JJRCNiwHSk1Ob7Uq1SdNdZRNMtyL6gKXs3RGZq-OR0HLtERL8xwFWTaPbTId1iNIleDqHkcFmCdGigEEyGOo8Vie0ocx8Jw6vV0vHWCwM

3.3. START the stopped instance

The stopped instance is like your physically shutdown computer. You have your computer, but it is powered down and wont be accessible through Putty or SSH terminal. If you want to access it again, you have to START it.

To START a “stopped” instance;

  • Go to your EC2 console web page.

  • Chose the Instances menu option

  • Check the “stopped” instance that you want to start

  • Click Actions menu, then “Instance State”, then “Start”.

m-zGcIk8tA9x2G2zF-i9k0GwMBbJZNBLkCbmKmsznptF9uSlMqZMk087qbuCO43XVZts2Eg5K7ThFecMA9_eAZ5IUnLTifaC0Ai3rQauZBle6abN29JMY3mTycQPoIJohApRFsRF

3.4. Terminate the instance

If you do not want your instance or its associated volumes anymore, you can terminate the instance (Actions - Instance State - Terminate menu option as shown in the above screenshot) and delete the associated volumes.

Having an instance in a STOPPED state will only help you save money with compute costs, but you will continue to be charged for the storage (volume) associated with your STOPPED instance.

If you terminate your instance and delete any associated (attached) volumes, everything associated with that instance would be gone forever. If you want an instance again, you would have to start over all again from step #2.