SendSerialConsoleSSHPublicKey - Amazon EC2 Instance Connect


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.


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


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


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 80. 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.


The ID of the request. Please provide this ID when contacting AWS Support for assistance.

Type: String


Is true if the request succeeds and an error otherwise.

Type: Boolean


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


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

HTTP Status Code: 400


The specified instance was not found.

HTTP Status Code: 400


Unable to connect because the instance is not in a valid state. Connecting to a stopped or terminated instance is not supported. If the instance is stopped, start your instance, and try to connect again.

HTTP Status Code: 400


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

HTTP Status Code: 400


The instance is currently unavailable. Wait a few minutes and try again.

HTTP Status Code: 400


One of the parameters is not valid.

HTTP Status Code: 400


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


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

HTTP Status Code: 400


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

HTTP Status Code: 500


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

HTTP Status Code: 500


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: