Connect to your first target
In the Admin Console, the Generated localhost ssh target with an alias has the address 127.0.0.1
with connection type TCP
. This is a TCP target with a default port of 22
(SSH). In this tutorial, you will start an ssh session to this default target using the CLI command.
Open a terminal session and set up environment variables to support your Boundary instance.
Note
The use of environment variables is not required, but used for the ease of following this tutorial.
Create an environment variable for the Generated target with an alias ID. Copy the target ID from the Admin Console.
If you authenticated through the Admin Console UI, authenticate with Boundary using the CLI with the login name admin
and password password
.
Boundary clusters require an accessible key management service (KMS). An error may occur if this service is not running. If you have any issues check the Troubleshooting section in the Getting Started with Boundary tutorial.
Read the Target Details
Read the details about the Generated localhost ssh target with an alias.
Use the boundary connect
command to SSH into the localhost.
This will attempt to establish an ssh session to your localhost. You may need to enable Remote Login on your system for the session to connect as expected.
When prompted, enter your local administrator user password to proceed.
On MacOS you might receive an error message similar to No connection could be made because the target machine actively refused it.
In this case, you may
need to enable Remote Login under the System Preferences -> Sharing
settings for your user.
Even with Remote Login enabled, you may need to directly add your username to the list of users under "Allow access for:". Enable "Only these users" and add your username to the list using the + button.
An example of this settings panel is shown below. You may need to add your
username instead of "Administrators". After enabling, try running boundary connect ssh
again.
In the terminal where Boundary server is running, you should see connection
successfully authorized
message.
Type exit
to close the connection to the localhost.
You can connect to a target using an alias instead of an ID.
Read the target details again, and find the Aliases
value.
Connect to the target again using the alias ssh.boundary.dev
.
If you want to specify a username to login with, you can do so via the
-username
flag. For example:
There is also a -style
flag to specify a different SSH clients. Currently,
the boundary connect ssh
command supports -style putty
to support passing
connection information to PuTTY for Windows users.
If you want to pass additional arguments to the SSH client, provide them to the
command line separated by "--
" (space, two hyphens, space). Any arguments
after the hyphens are sent directly to the executed client.
For example, the following command accomplishes the same as -username
flag.
Read the Boundary connect usages section to learn
more about the boundary connect
command.
Manage sessions
In the admin console, select Sessions. The UI will show an entry with session
ID matching in the server log (such as s_895vskVZh0
).
Open a new command terminal and re-authenticate to Boundary.
Next, execute the boundary connect
command again.
Return to the admin console. You should see two sessions listed.
Click the Cancel button of one of the sessions. The status changes to
canceling
and then terminated
.
The command terminal where the SSH session was running should also show the connection was closed.
In the Boundary server log, you should see a message indicating that the worker terminated the SSH session.
Boundary connect usages
Build-in commands
Out of the box, Boundary supports the following connection protocols.
Subcommand | Description |
---|---|
http | Authorize a session against a target and invoke an HTTP client to connect |
ssh | Authorize a session against a target and invoke an SSH client to connect |
postgres | Authorize a session against a target and invoke a Postgres client (psql ) to connect |
rdp | Authorize a session against a target and invoke an RDP client (mstsc ) to connect |
Exec command
The boundary connect
can execute clients even when there is no built-in
wrapper subcommand for it using -exec
. The -exec
flag is a very powerful
tool, allowing you to wrap Boundary TCP sessions in your preferred client. You
can use this flag to create an authenticated proxy to almost anything.
If all command flags are followed by "--
" (space, two hyphens, space), then
any arguments after that will be sent directly to the client. This can be
specified via the BOUNDARY_CONNECT_EXEC
environment variable as well.
Example
cURL can be used to do an authenticated download of hashicorp.com
.
First, update the default TCP target (ttcp_1234567890
) port from 22
to 443
using the boundary targets update
command.
Now, execute the cURL command using the -exec
flag.
Set session limits
By default, the session max time is set to 8 hours (28800 seconds). You can
overwrite the default to limit the session duration using the boundary targets update
command.
Set the max session time to 15 seconds to see how it behaves. Also, set the
default TCP port back to 22
if you modified it to use 443
.
Example Output:
Run the boundary connect
command again to SSH into the localhost.
The session automatically terminates after 15 seconds.
Next steps
You learned the boundary connect
command, viewed and managed the SSH sessions.
The next step is to install the Boundary Desktop app, and ensure you can repeat relevant steps in this tutorial related to viewing and managing SSH sessions.