Amazon Elastic Compute Cloud
User Guide (API Version 2011-12-15)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Adding Rules to the Default Security Group

Before you can log in to an instance, you must authorize access.

This section describes how to add rules that allow HTTP access on port 80, SSH access on port 22, and Remote Desktop (RDP) access on port 3389. This enables the instance to be reached on port 80 from the Internet and enables you to administer the instance over SSH or RDP.

AWS Management Console

To authorize access to your instance

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. Click Security Groups in the Navigation pane.

    The console displays a list of security groups that belong to the account.

  3. Select the default security group.

    Its rules appear on the Inbound tab in the lower pane.

  4. To add the HTTP rule:

    1. Select HTTP from the Create a new rule menu.

    2. Click Add Rule.

      The rule is added to the list of rules on the right. However, the rule isn't applied to the group until you click Apply Rule Changes (which you'll do after you've added all the rules). Notice that the rules are highlighted in blue, and there's an asterisk on the Inbound tab. These signs indicate that you haven't yet applied the rule changes.

  5. To add the SSH rule:

    1. Select SSH from the Create a new rule menu.

    2. In the Source field, enter your public IP address (e.g., 192.0.2.1/32).

    3. Click Add Rule.

      The rule is added to the list of rules.

  6. To add the RDP rule:

    1. Select RDP from the Create a new rule menu.

    2. In the Source field, enter your public IP address (e.g., 192.0.2.1/32).

    3. Click Add Rule.

      The rule is added to the list of rules.

  7. Click Apply Rule Changes.

    The new rules now apply to the default security group. Notice that the rules are no longer highlighted in blue, and the asterisk no longer appears on the Inbound tab.

Command Line Tools

To authorize access to your instance

  • Enter the ec2-authorize commands.

    PROMPT>  ec2-authorize default -p 22 -s your-local-system's-public-ip-address/32
    PERMISSION     default  ALLOWS  tcp     22      22      FROM    CIDR   your-local-system's-public-ip-address/32
    PROMPT>  ec2-authorize default -p 3389 -s your-local-system's-public-ip-address/32
    PERMISSION     default  ALLOWS  tcp     3389      3389      FROM    CIDR   your-local-system's-public-ip-address/32
    PROMPT>  ec2-authorize default -p 80
    PERMISSION     default  ALLOWS  tcp     80      80      FROM    CIDR   0.0.0.0/0 

    Because we didn't specify otherwise, your instance was launched in your default group. The first command authorizes network access from your local system to instances in your default group on the standard SSH port (22). The second command authorizes RDP access (port 3389) from your local system to instances in the default security group. Similarly, the third command opens up the standard HTTP port (80).

API

To authorize access to your instance

  • Construct the following Query requests. The first two of the following requests give your local system the ability to use SSH (port 22) or Remote Desktop (port 3389) to connect to any instance in the "default" security group. The third command allows all port 80 traffic into all instances in the "default" security group.

    https://ec2.amazonaws.com/
    ?Action=AuthorizeSecurityGroupIngress
    &GroupName=default
    &IpPermissions.1.IpProtocol=tcp
    &IpPermissions.1.FromPort=22
    &IpPermissions.1.ToPort=22
    &IpPermissions.1.IpRanges.1.CidrIp=your-local-system's-public-ip-address/32
    &AUTHPARAMS
    
    https://ec2.amazonaws.com/
    ?Action=AuthorizeSecurityGroupIngress
    &GroupName=default
    &IpPermissions.1.IpProtocol=tcp
    &IpPermissions.1.FromPort=3389
    &IpPermissions.1.ToPort=3389
    &IpPermissions.1.IpRanges.1.CidrIp=your-local-system's-public-ip-address/32
    &AUTHPARAMS
    
    https://ec2.amazonaws.com/
    ?Action=AuthorizeSecurityGroupIngress
    &GroupName=default
    &IpPermissions.1.IpProtocol=tcp
    &IpPermissions.1.FromPort=80
    &IpPermissions.1.ToPort=80
    &IpPermissions.1.IpRanges.1.CidrIp=0.0.0.0/0
    &AUTHPARAMS
    

    Following is an example response.

    <AuthorizeSecurityGroupIngressResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
       <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
       <return>true</return>
    </AuthorizeSecurityGroupIngressResponse>