How to Communicate Among Instances using Amazon EC2

Sample Code & Libraries>Amazon EC2>How to Communicate Among Instances using Amazon EC2
Community Contributed Software

  • Amazon Web Services provides links to these packages as a convenience for our customers, but software not authored by an "@AWS" account has not been reviewed or screened by AWS.
  • Please review this software to ensure it meets your needs before using it.

Nimantha de Silva, Freelance Technical Writer will guide you through on how to communicate among instances using Amazon EC2. This will be done in a step by step manner, so that the user can does not need any extensive knowledge on how to deploy the following.

Details

Submitted By: nimantha
AWS Products Used: Amazon EC2
License: Other
Created On: May 3, 2010 8:13 AM GMT
Last Updated: August 16, 2010 5:26 PM GMT
Download

This is one of the simplest but the coolest work I tried using Amazon EC2.During the implementation process, the major challenge I had to face was to communicate between instances. For this to work, 1st i had to make sure that my application has the capability to recall "[b]ssh[/b]" and "[b]scp[/b]"among the nodes, which in most scenarios do happen automatically. This was fun but was hard as I mentioned at the beginning itself, because in EC2 if you want to connect to an instance you have to define the key-pair, which is not possible for my application. So I had to follow an alternative method and these are the steps of how I got it fixed:

  • First step is to run an instance with the your operating system (in my case I was using Fedora 8 and selected it)
  • Once it is done and ready to run the application, you have to select the key-pair and the security group.
  • Next step is to generate the SSH key, you can do that by using the following command (Remember : Do not enter a passphrase)
  • ssh-keygen -t rsa
  • Next is to go and edit the [b]~/.ssh/authorized_keys[/b]. For that copy and paste the content of [b].ssh/id_rsa.pub[/b]
  • Now open the [b]~/.ssh/authorized_keys[/b], and change the tail as "[b]root@domU[/b]" , (Basically to remove root@ec2-.. with the new one)
  • Next step is to edit the "[b]~/.ssh/know_hosts[/b]" file and add the following command to it.
  • *.amazon.com ssh-rsa Asasdas...
  • (Asasdas.... = content of rsa.pub)
Now its done and all set (unless you need to install some other packages).

  • Next step is to bundle the image and register it with EC2 and S3.
  • After doing that, try running more than one instances.
  • Now if you try to do "[b]ssh[/b]" among these you will figure out that you do not need to enter the password or even you do not need to specify the key-pairs for it.
[b]Author: Nimantha de Silva [www.nimantha.com][/b]
©2014, Amazon Web Services, Inc. or its affiliates. All rights reserved.