DescribeTerminalSessions

更新时间:
复制 MD 格式

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.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:DescribeTerminalSessions

list

*Instance

acs:ecs:{#regionId}:{#accountId}:instance/{#InstanceId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID.

cn-hangzhou

InstanceId

string

No

The instance ID.

i-bp1i7gg30r52z2em****

SessionId

string

No

The session ID.

s-hz023od0x9****

MaxResults

integer

No

The maximum number of entries per page.

Valid values: 1 to 100.

Default value: 10.

10

NextToken

string

No

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 elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

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

NextToken

string

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

AAAAAdDWBF2****

Sessions

object

Session

array<object>

The information of the sessions.

array<object>

The information about the sessions.

CreationTime

string

The time when the session was created.

2024-01-19T09:15:46Z

TargetServer

string

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

192.168.0.246

PortNumber

integer

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

PrincipalId

string

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

Username

string

The username used to establish connections.

root

ClientIP

string

The IP address of the client used to establish connections.

192.168.1.1

IdentityType

string

The principal type. Valid values:

  • Account: an Alibaba Cloud account

  • RAMUser: a RAM user

  • AssumedRoleUser: a RAM role

RAMUser

SessionId

string

The session ID.

s-hz023od0x9****

Connections

object

Connection

array<object>

The information of the connections.

object

The connection.

ClosedReason

string

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

EndTime

string

The time when the connection was closed.

2024-01-19T09:16:46Z

Status

string

The state of the session. Valid values:

  • Connecting: The connection is being established.

  • Connected: The connection is established.

  • Terminated: The session is terminated.

  • Failed: The connection failed.

Connecting

StartTime

string

The time when the connection started to be established.

2024-01-19T09:16:40Z

InstanceId

string

The instance ID.

i-bp1i7gg30r52z2em****

FailedDetail

string

Cause of the connection failure. This parameter is returned only when the Status parameter is Failed.

The Session Manager is closed normally.

Examples

Success response

JSON format

{
  "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****",
              "FailedDetail": "The Session Manager is closed normally."
            }
          ]
        }
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter.NextToken The specified parameter NextToken is not valid. The specified parameter NextToken is illegal.
400 InvalidParameter.MaxResults The specified parameter MaxResults is not valid. The specified parameter MaxResults is illegal.
500 InternalError An error occurred when you dispatched the request. An error occurred while sending the request, please try again later.
403 Operation.Forbidden The operation is not permitted. The operation is not supported.
404 InvalidRegionId.NotFound The specified parameter RegionId does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.