SendSerialConsoleSSHPublicKey - AWS EC2 Instance Connect

SendSerialConsoleSSHPublicKey

Pushes an SSH public key to the specified EC2 instance. The key remains for 60 seconds, which gives you 60 seconds to establish a serial console connection to the instance using SSH. For more information, see EC2 Serial Console in the Amazon EC2 User Guide.

Request Syntax

{ "InstanceId": "string", "SerialPort": number, "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.

InstanceId

The ID of the EC2 instance.

Type: String

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

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

Required: Yes

SerialPort

The serial port of the EC2 instance. Currently only port 0 is supported.

Default: 0

Type: Integer

Valid Range: Fixed value of 0.

Required: No

SSHPublicKey

The public key material. To use the public key, you must have the matching private key. For information about the supported key formats and lengths, see Requirements for key pairs in the Amazon EC2 User Guide.

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 ID of the request. Please provide this ID when contacting AWS Support for assistance.

Type: String

Success

Is true if the request succeeds and an error otherwise.

Type: Boolean

Errors

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

AuthException

Either your AWS credentials are not valid or you do not have access to the EC2 instance.

HTTP Status Code: 400

EC2InstanceNotFoundException

The specified instance was not found.

HTTP Status Code: 400

EC2InstanceTypeInvalidException

The instance type is not supported for connecting via the serial console. Only Nitro instance types are currently supported.

HTTP Status Code: 400

InvalidArgsException

One of the parameters is not valid.

HTTP Status Code: 400

SerialConsoleAccessDisabledException

Your account is not authorized to use the EC2 Serial Console. To authorize your account, run the EnableSerialConsoleAccess API. For more information, see EnableSerialConsoleAccess in the Amazon EC2 API Reference.

HTTP Status Code: 400

SerialConsoleSessionLimitExceededException

The instance currently has 1 active serial console session. Only 1 session is supported at a time.

HTTP Status Code: 400

SerialConsoleSessionUnavailableException

Unable to start a serial console session. Please try again.

HTTP Status Code: 500

ServiceException

The service encountered an error. Follow the instructions in the error message and try again.

HTTP Status Code: 500

ThrottlingException

The requests were made too frequently and have been throttled. Wait a while and try again. To increase the limit on your request frequency, 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: