sendSerialConsoleSSHPublicKey method
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.
May throw AuthException.
May throw EC2InstanceNotFoundException.
May throw EC2InstanceStateInvalidException.
May throw EC2InstanceTypeInvalidException.
May throw EC2InstanceUnavailableException.
May throw InvalidArgsException.
May throw SerialConsoleAccessDisabledException.
May throw SerialConsoleSessionLimitExceededException.
May throw SerialConsoleSessionUnavailableException.
May throw SerialConsoleSessionUnsupportedException.
May throw ServiceException.
May throw ThrottlingException.
Parameter instanceId :
The ID of the EC2 instance.
Parameter 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.
Parameter serialPort :
The serial port of the EC2 instance. Currently only port 0 is supported.
Default: 0
Implementation
Future<SendSerialConsoleSSHPublicKeyResponse> sendSerialConsoleSSHPublicKey({
required String instanceId,
required String sSHPublicKey,
int? serialPort,
}) async {
_s.validateNumRange(
'serialPort',
serialPort,
0,
0,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target':
'AWSEC2InstanceConnectService.SendSerialConsoleSSHPublicKey'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'InstanceId': instanceId,
'SSHPublicKey': sSHPublicKey,
if (serialPort != null) 'SerialPort': serialPort,
},
);
return SendSerialConsoleSSHPublicKeyResponse.fromJson(jsonResponse.body);
}