Manage sessions
Sessions
are Boundary resources created when connecting to a
target. A
target allows Boundary users to define an endpoint with a protocol and default
port to establish a session. Unless specified with a -host-id
flag when
establishing a session, Boundary will choose one
host from the
target's host
sets to
connect to at random.
This tutorial demonstrates the basics of how to start a session, view the session details and cancel a session in Boundary.
Prerequisites
This tutorial assumes that you successfully completed the Manage Scopes and Manage Targets tutorials.
Retrieve resource IDs
To connect to a target, you need the target ID and host ID to use the -host-id
flag. If you are not sure about those IDs, follow the steps in this section;
otherwise, skip to the Start a session section.
Log back into the CLI as the admin user. Enter password
at the Please enter the password (it will be hidden):
prompt.
List the existing targets under the
QA_Tests
project.Now, you have the target ID (e.g.
ttcp_34yV5O9cwt
).If you haven't already, copy the ID and save it as an environment variable,
TARGET_ID
.Example:
List the host IDs that belong to the host catalog.
Copy the localhost host ID. In the example output, the ID is
hst_FrdNPd9Zm9
.
Start a session
Open a session to the postgres target using boundary connect
. When prompted,
enter the password secret
to connect.
Note
If you followed the Admin Console workflow and did not export the
TARGET_ID
environment variable, supply it directly instead. such as
ttcp_34yV5O9cwt
.
For more information regarding different ways to connect to a target behind Boundary see Connect to Target and the Advanced Session Establishment section.
View sessions
Note
After connecting to the postgres container, the exported environment variables may no longer be available in your shell session. Leave this session open, and open a new terminal window to proceed.
Log back into the CLI as the admin user. Enter password
at the Please enter the password (it will be hidden):
prompt.
List the available scopes.
Copy the QA_Tests
project scope ID, such as p_oMgeFL2hP6
.
View all sessions which Boundary has under the QA_Tests project by listing them.
We can get a more detailed view of a specific session by reading it.
Cancel a session
If unexpected activity is detected, you can force-cancel the session.
Cancel the session using the session ID copied in the previous step.
The status is now canceling
. When it completes, the session status will change
to terminated
.
Wait a moment, and then read the session details.
Advanced session establishment
In addition to the boundary connect
command, you can create a session to a
target and connect to that session in separate steps. This is accomplished using
the boundary targets authorize-session
command, which generates an
authorization token that a user can use to start a session via boundary connect
-authz-token
at their own convenience.
For this example, gather the target ID and host ID as demonstrated in the previous tutorials:
List all targets.
Copy the postgres
target ID.
List all host catalogs.
Copy the DevOps
host catalog ID, and then list all hosts within the host
catalog.
Then copy the localhost host ID, such as hst_FrdNPd9Zm9
.
With these IDs gathered, generate an authorize token for the localhost host.
Example:
Copy the generated Authorization Token
value.
Note
In the absence of -host-id
flag, Boundary will pick a host from
the host set. If there is more than one host in the host set attached to the
target, one is selected automatically.
Example:
With the above address and port information, you can connect to the local proxy and have your tcp traffic sent through the Boundary system.
Copy the Port (such as 61617
) and note the Address (127.0.0.1
).
Open a new terminal window.
Attempt to establish an ssh session to the postgres container again.
When prompted, enter the sampledb password secret
.
Practice cancelling the session, as demonstrated before.
Summary
The Manage Scopes tutorial demonstrated
the steps to create a new org (IT_Support
) and a project (QA_Tests
) under
the org.
The Manage Targets tutorial demonstrated the creation of a host catalog, a host set, and hosts. Then, associated the host set to a target.
You also enabled a new authorization method (password
) for the IT_Support
org and created a new user in the Manage Users and
Groups tutorial. The Manage Roles and
Permissions tutorial showed you how to create
a role and assign a grant which specifies a set of permissions.
Finally, this tutorial demonstrated session management based on the target you
defined for the QA_Tests
project.
To continue learning about Boundary, check out the Self-Hosted Administration Workflows.