[Recipes] Connecting to EC2 Instance From a Windows Machine

Problem: 

We have created and launched an EC2 instance. We need to connect to it from windows machine and run commands from its terminal.

Solution Summary: 

We will use the putty tool to connect to the EC2 instance from the Windows machine. We will use the puttygen file to create ppk file required by putty from the key file downloaded from AWS console.

Solution Steps: 

  1. Login to AWS console, go to EC2 page and click on instance menu option on the left.

  2. Select your EC2 instance and click on connect to see steps to connect. We will do it for windows.

  3. Get putty and puttygen (Search google)

  4. Generate ppk file (required for putty) using puttygen:

    1. Open puttygen, click on laod, select All Files, and load the pem key file downloaded during part 1 (BuddyTutorEC2DemoKeyPair.pem).

    2. Click ok on the success message and click on “save private key”. You may not enter the passphrase for this demo.

    3. Save it as a .ppk file (BuddyTutorEC2DemoKeyPair.ppk)

  5. From the EC2 instance, get the public IPv4 address.

  6. Open putty and add the host name as: ec2-user@<IP>. E.g. ec2-user@ 54.71.189.78. Copy same into the saved sessions text box.

  7. Click to expand on ssh, click on auth and browse to select our ppk file.

  8. Go back to session tab and click on save.

  9. Now you an click on your host entry within saved sessions, click on load and click on open to login. (Can follow this every time from now to login the server.)

  10. You may get a security popup and you can click yes to proceed.

  11. You will be authenticated and logged in to the server. You may see a message similar to: 12 package(s) needed for security, out of 23 available. Run "sudo yum update" to apply all updates.

  12. Run "sudo yum update". You may be asked for a confirmation and you can click yes. Installation should complete successfully.

  13. Create a small webserver and a single file to verify the server:

    1. Install apache server as: yum install httpd -y

      1. You may get a message as: You need to be root to perform this command. Type “sudo su” to elevate you as a admin. And then, run again “yum install httpd -y”. This time it should get installed successfully.

    2. Go to apache server’s html folder: cd /var/www/html

    3. Create a very small html file:

      1. vi index.html

      2. click on insert or i.

      3. Type: <html><h1>Hello Buddy!</h1></html>

      4. Click on ESC, type :x, and press enter to save

    4. Start apache as: service httpd start

  14. Verify getting the html output:

    1. Copy the public ip for the instance from the console

    2. Run it on the browser after http (e.g. http://54.71.189.78/). You should see the web page with: Hello Buddy!

Recipe Tags: 

Contact

Please first use the contact form or facebook page messaging to connect.

Offline Contact
We currently connect locally for discussions and sessions at Bangalore, India. Please follow us on our facebook page for details.
WhatsApp (Primary): (+91) 7411174113
Phone (Escalations): (+91) 7411174114

Business newsletter

Complete the form below, and we'll send you an e-mail every now and again with all the latest news.

About

CloudMaterials.com is my blog to share notes and learning materials on Cloud and Data Analytics. My current focus is on Amazon Web Services.

I like to write. I try to document what I learn and share with others. I believe that knowledge is useless unless you share it; the more you share, the more you learn.

Recent comments

Photo Stream

,