TrueNAS SCALETrueNAS SCALE Version Documentation
This content follows the TrueNAS SCALE 23.10 (Cobia) releases. Use the Product and Version selectors above to view content specific to different TrueNAS software or major version.

Sessions

  5 minute read.

Last Modified 2024-03-19 08:38 EDT

The SCALE CLI guide is a work in progress! New namespace and command documentation is continually added and maintained, so check back here often to see what is new!

Sessions Commands

The sessions namespace has seven commands and is based on functions found in the SCALE API and web UI. It provides access to session information through the seven sessions commands.

You can enter commands from the main CLI prompt or the auth namespace prompt.

Sessions Command

The sessions command returns a table that displays each session id, whether or not each session is current and internal, each session origin, and the credentials and credential data used to log into each session.

Description

The sessions command does not require entering properties or arguments. Enter the command, then press Enter. The command returns a table with the ID, current session state, origin such as an IP or socket information, credentials, and creation date and time.

Usage

From the CLI prompt, enter:

auth sessions

auth> sessions
+--------------------------------------+---------+----------+---------------------------------------+-------------+------------------+---------------------------+
| id                                   | current | internal | origin                                | credentials | credentials_data | created_at                |
+--------------------------------------+---------+----------+---------------------------------------+-------------+------------------+---------------------------+
| 8a21fefe-1255-42eb-a86d-8a7f74752b94 | false   | false    | 10.234.15.210:15864                   | UNIX_SOCKET | <dict>           | 2023-07-25T17:54:49+00:00 |
| f01274e8-4954-4926-9346-76a16d3648dd | true    | true     | UNIX socket (pid=2459768 uid=0 gid=0) | UNIX_SOCKET | <dict>           | 2023-07-26T11:05:16+00:00 |
+--------------------------------------+---------+----------+---------------------------------------+-------------+------------------+---------------------------+

ID Command

The id command displays the IDs of all TrueNAS sessions since boot.

Description

The id command does not require entering properties or arguments. Enter the command, then press Enter. The command returns a table of recent and active session IDs.

Usage

From the CLI prompt, enter:

auth sessions id

auth sessions id
+--------------------------------------+
| id                                   |
+--------------------------------------+
| 8a21fefe-1255-42eb-a86d-8a7f74752b94 |
| f01274e8-4954-4926-9346-76a16d3648dd |
+--------------------------------------+

Current Command

The current command displays whether or not the TrueNAS sessions in the sessions list are current.

Description

The current command does not require entering properties or arguments. Enter the command, then press Enter. The command returns a table showing which sessions are current (true) or not (false). The rows of the table are relative to the rows returned from the sessions command.

Usage

From the CLI prompt, enter:

auth sessions current

auth sessions current
+---------+
| current |
+---------+
| false   |
| true    |
+---------+

Internal Command

The internal command displays whether sessions in the sessions list are internally created (via the web UI) or not (via SSH).

Description

The internal command does not require entering properties or arguments. Enter the command, then press Enter. The command returns a table showing if sessions are internal (true) or not (false). The rows of the table are relative to the rows returned from the sessions command.

Usage

From the CLI prompt, enter:

auth sessions internal

auth sessions internal
+----------+
| internal |
+----------+
| false    |
| true     |
+----------+

Origin Command

The origin command displays the login origin of the sessions in the sessions list.

Description

The origin command does not require entering properties or arguments. Enter the command, then press Enter. The command returns a table showing the login origin of each session. The rows of the table are relative to the rows returned from the sessions command.

Usage

From the CLI prompt, enter:

auth sessions origin

auth sessions origin
+---------------------------------------+
| origin                                |
+---------------------------------------+
| 10.234.15.210:15864                   |
| UNIX socket (pid=2459768 uid=0 gid=0) |
+---------------------------------------+

Credentials Command

The credentials command displays the credentials used to authenticate each session in the sessions list.

Description

The credentials command does not require entering properties or arguments. Enter the command, then press Enter. The command returns a table showing the credentials used to authenticate each session. See the table below for ll possible credential types. The rows of the table are relative to the rows returned from the sessions command.

Possible states:

PropertyDescription
UNIX_SOCKETIndicates the session used web UI user credential authentication.
ROOT_TCP_SOCKETIndicates the session used TCP and Root user credential authentication.
LOGIN_PASSWORDIndicates the session used SSH password authentication.
API_KEYIndicates the session used API key authentication.
TOKENIndicates the session used token authentication.

Usage

From the CLI prompt, enter:

auth sessions credentials

auth sessions credentials
+----------------+
| credentials    |
+----------------+
| LOGIN_PASSWORD |
| UNIX_SOCKET    |
+----------------+

Created At Command

The created_at command displays the creation date and time of the sessions in the sessions list.

Description

The created_at command does not require entering properties or arguments. Enter the command, then press Enter. The command returns a table showing the creation date and time of each session. The rows of the table are relative to the rows returned from the sessions command.

Usage

From the CLI prompt, enter:

auth sessions created_at

auth sessions created_at
+---------------------------+
| created_at                |
+---------------------------+
| 2023-07-25T17:54:49+00:00 |
| 2023-07-26T11:05:16+00:00 |
+---------------------------+

Related CLI Auth Articles