|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
This version of the AWS SDK for PHP is deprecated and is only provided to support legacy applications. All new code should use the current version of the SDK at http://aws.amazon.com/sdkforphp/.
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
$response = $ec2->create_key_pair('my-php-key-pair');
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 will occur.
Use the response object's
body->keyMaterial property to obtain the unencrypted PEM-encoded private key,
(string) $private_key = $response->body->keyMaterial;
create_key_pair is the only way to obtain the private key programmatically.
You can always access your private key through the
AWS Management Console.
Before logging onto an Amazon EC2 instance, you must create the instance and ensure that it is running. For information on how to run an Amazon EC2 instance, see Run an Amazon EC2 Instance.
For information on how to use your key pair to connect to your Amazon EC2 instance, see Connect To Your Amazon EC2 Instance.