Connect to Your First Target
In the admin console, you saw that localhost
was listed as Generated
target with connection type, TCP. The default target 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 command terminal 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 Global scopes password auth method ID.
Create an environment variable for the Generated target ID.
If you authenticated through the admin console, authenticate with Boundary via
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 target.
Use the boundary connect
command to SSH into the localhost.
This will attempt to establish an ssh session to your localhost. Remote Login may need to be enabled 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.
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 that will be sent directly to the executed client.
For example, the following command accomplishes the same as -username
flag.
In the terminal where Boundary server is running, you should see connection
successfully authorized
message similar to below.
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 (e.g. s_895vskVZh0
).
Open a new command terminal and 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 indicate that 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.