Amazon AWS SDK Uživatelský manuál Strana 22

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 26
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 21
For information about running your Amazon EC2 instance, see Run an Amazon EC2 Instance (p. 20).
Authorize Security Group Ingress
By default, a new security group does not allow any inbound traffic.To allow inbound traffic, you must
explicitly authorize security group ingress.You can authorize ingress for individual IP addresses, for a
range of IP addresses, for a protocol, and for TCP/UDP ports.
To authorize ingress for your security group, use the SecurityGroup.authorize_ingress method.
The following code demonstrates one way to authorize security group ingress for a range of IP addresses.
ip_addresses = ['111.111.111.111/0', '150.150.150.150/0']
security_group.authorize_ingress :tcp, 22, *ip_addresses
Specify the IP address using CIDR notation. If you specify the protocol as TCP/UDP, you must provide
a source port or a range of ports.You can authorize ports only if you specify TCP or UDP.
If you authorize ingress for IP addresses that have already been authorized, the method returns an error.
Whenever you use authorize_ingress or SecurityGroup.authorize_egress, a rule is added to your
security group.You can add up to 100 rules per security group.
For more information about security groups, go to Security Group Concepts.
Create a Key Pair
Public AMI instances have no default password.To log into your Amazon EC2 instance, you must generate
an Amazon EC2 key pair.The key pair consists of a public key and a private key, and is not the same
as your AWS access credentials. For more information about Amazon EC2 key pairs, go to Getting an
SSH Key Pair.
To create a key pair and obtain the private key
1. Use the KeyPairCollection.create method and specify the key pair name.The method returns a
KeyPair object, as follows:
key_pair = ec2.key_pairs.create('YOUR_KEY_PAIR_NAME')
Key pair names must be unique. If you attempt to create a key pair with the same key name as an
existing key pair, an error occurs.
2. Use the returned object's fingerprint property to obtain an SHA-1 digest of the DER-encoded private
key, as follows:
private_key = key_pair.private_key;
Calling create is the only way to obtain the private key programmatically.You can always access
your private key through the AWS Management Console.
Version v1.0.0
19
AWS SDK for Ruby Developer Guide
Authorize Security Group Ingress
Zobrazit stránku 21
1 2 ... 17 18 19 20 21 22 23 24 25 26

Komentáře k této Příručce

Žádné komentáře