All Products
Search
Document Center

Elastic Compute Service:DescribeTerminalSessions

更新時間:Dec 24, 2024

Queries the session records of Elastic Compute Service (ECS) Session Manager.

Operation description

You can query the session records of Session Manager that were generated in the last four weeks.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:DescribeTerminalSessionslist
*Instance
acs:ecs:{#regionId}:{#accountId}:instance/{#InstanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID.

cn-hangzhou
InstanceIdstringNo

The instance ID.

i-bp1i7gg30r52z2em****
SessionIdstringNo

The session ID.

s-hz023od0x9****
MaxResultsintegerNo

The maximum number of entries per page.

Valid values: 1 to 100.

Default value: 10.

10
NextTokenstringNo

The pagination token that is used in the next request to retrieve a new page of results. You do not need to specify this parameter for the first request. You must specify the token that is obtained from the previous query as the value of NextToken.

AAAAAdDWBF2****

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****
NextTokenstring

A pagination token. It can be used in the next request to retrieve a new page of results.

AAAAAdDWBF2****
Sessionsarray<object>

The information of the sessions.

Sessionobject
CreationTimestring

The time when the session was created.

2024-01-19T09:15:46Z
TargetServerstring

The address of the service that was accessed in a virtual private cloud (VPC) from the instance.

192.168.0.246
PortNumberinteger

The port number of the instance, which is used for data forwarding. If no port number was specified for data forwarding when the session was created, this parameter is empty.

22
PrincipalIdstring

The ID of the principal. Valid values based on the IdentityType value:

  • If the requester uses an Alibaba Cloud account to call the operation, the ID of the Alibaba Cloud account is returned.
  • If the requester uses a Resource Access Management (RAM) user to call the operation, the ID of the RAM user is returned.
  • If the requester uses a RAM role to call the operation, the ID of the principal that actually calls the operation is returned.
123456xxxx
Usernamestring

The username used to establish connections.

root
ClientIPstring

The IP address of the client used to establish connections.

192.168.1.1
IdentityTypestring

The principal type. Valid values:

  • Account: an Alibaba Cloud account
  • RAMUser: a RAM user
  • AssumedRoleUser: a RAM role
RAMUser
SessionIdstring

The session ID.

s-hz023od0x9****
Connectionsarray<object>

The information of the connections.

Connectionobject
ClosedReasonstring

The reason why the connection was closed. This parameter is returned only when the Status value is Disconnected, Terminated, or Failed. Valid values:

  • InstanceNotExists: The specified instance did not exist or was released.
  • InstanceNotRunning: The specified instance was not running.
  • DeliveryTimeout: The connection timed out.
  • AgentNeedUpgrade: Cloud Assistant Agent required an upgrade.
  • AgentNotOnline: Cloud Assistant Agent was not connected to the Cloud Assistant server.
  • MessageFormatInvalid: The message format was invalid.
  • AgentSocketClosed: The connection was closed as expected.
  • ClientClosed: Session Manager Client closed the connection.
AgentNeedUpgrade
EndTimestring

The time when the connection was closed.

2024-01-19T09:16:46Z
Statusstring

The state of the session. Valid values:

  • Connecting: The connection is being established.
  • Connected: The connection is established.
  • Disconnected: The connection is disconnected.
  • Terminating: The session is being terminated.
  • Terminated: The session is terminated.
  • Failed: The connection failed.
Connecting
StartTimestring

The time when the connection started to be established.

2024-01-19T09:16:40Z
InstanceIdstring

The instance ID.

i-bp1i7gg30r52z2em****

Examples

Sample success responses

JSONformat

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "NextToken": "AAAAAdDWBF2****",
  "Sessions": {
    "Session": [
      {
        "CreationTime": "2024-01-19T09:15:46Z",
        "TargetServer": "192.168.0.246",
        "PortNumber": 22,
        "PrincipalId": "123456xxxx",
        "Username": "root",
        "ClientIP": "192.168.1.1",
        "IdentityType": "RAMUser",
        "SessionId": "s-hz023od0x9****",
        "Connections": {
          "Connection": [
            {
              "ClosedReason": "AgentNeedUpgrade",
              "EndTime": "2024-01-19T09:16:46Z",
              "Status": "Connecting",
              "StartTime": "2024-01-19T09:16:40Z",
              "InstanceId": "i-bp1i7gg30r52z2em****"
            }
          ]
        }
      }
    ]
  }
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidParameter.NextTokenThe specified parameter NextToken is not valid.The specified parameter NextToken is illegal.
400InvalidParameter.MaxResultsThe specified parameter MaxResults is not valid.The specified parameter MaxResults is illegal.
404InvalidRegionId.NotFoundThe specified parameter RegionId does not exist.-
500InternalErrorAn error occurred when you dispatched the request.An error occurred while sending the request, please try again later.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history