AWS EC2 Instance Connect
API Reference (API Version 2018-04-02)

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

SendSSHPublicKey

Pushes an SSH public key to a particular OS user on a given EC2 instance for 60 seconds.

Request Syntax

{ "AvailabilityZone": "string", "InstanceId": "string", "InstanceOSUser": "string", "SSHPublicKey": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

AvailabilityZone

The availability zone the EC2 instance was launched in.

Type: String

Length Constraints: Minimum length of 6. Maximum length of 32.

Pattern: ^(\w+-){2,3}\d+\w+$

Required: Yes

InstanceId

The EC2 instance you wish to publish the SSH key to.

Type: String

Length Constraints: Minimum length of 10. Maximum length of 32.

Pattern: ^i-[a-f0-9]+$

Required: Yes

InstanceOSUser

The OS user on the EC2 instance whom the key may be used to authenticate as.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 32.

Pattern: ^[A-Za-z_][A-Za-z0-9\@\._-]{0,30}[A-Za-z0-9\$_-]?$

Required: Yes

SSHPublicKey

The public key to be published to the instance. To use it after publication you must have the matching private key.

Type: String

Length Constraints: Minimum length of 256. Maximum length of 4096.

Required: Yes

Response Syntax

{ "RequestId": "string", "Success": boolean }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

RequestId

The request ID as logged by EC2 Connect. Please provide this when contacting AWS Support.

Type: String

Success

Indicates request success.

Type: Boolean

Errors

For information about the errors that are common to all actions, see Common Errors.

AuthException

Indicates that either your AWS credentials are invalid or you do not have access to the EC2 instance.

HTTP Status Code: 400

EC2InstanceNotFoundException

Indicates that the instance requested was not found in the given zone. Check that you have provided a valid instance ID and the correct zone.

HTTP Status Code: 400

InvalidArgsException

Indicates that you provided bad input. Ensure you have a valid instance ID, the correct zone, and a valid SSH public key.

HTTP Status Code: 400

ServiceException

Indicates that the service encountered an error. Follow the message's instructions and try again.

HTTP Status Code: 500

ThrottlingException

Indicates you have been making requests too frequently and have been throttled. Wait for a while and try again. If higher call volume is warranted contact AWS Support.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: