Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(agent,pkg): add connector mode #3809

Merged
merged 1 commit into from
May 20, 2024

Conversation

henrybarreto
Copy link
Member

@henrybarreto henrybarreto commented May 9, 2024

ShellHub Connector is a new kind of ShellHub Agent that turns Docker
containers into ShellHub Devices. It instances a new ShellHub Agent, in
memory, for each container running, redirecting the SSH IO, connections
in general, and authentication credentials to the container its file
system.

As most of the containers don't have passwords set for its users per default,
it rejects the connection every time for users without credentials.

The initial implementation has support for these kinds of connections:

  • Shell
  • Exec
  • Heredoc

To initialize the ShellHub Connector, enter the agent/ directory, build and
run the agent's binary with connector sub command.

go build -ldflags "-X main.AgentVersion=latest" -o agent &&
SERVER_ADDRESS="http://localhost/" PRIVATE_KEYS="/tmp/shellhub/"
TENANT_ID="00000000-0000-4000-0000-000000000000" ./agent connector

To configure the ShellHub Connector, you can/must provide these environmental
variables.

  • SERVER_ADDRESS (required) Set the ShellHub server address of the
    agent will use to connect

  • PRIVATE_KEYS (required) Specify the path to store the devices/containers
    private keys. If not provided, the agent will generate a new one.

  • TENANT_ID (required) Sets the account tenant ID used during communication
    to associate the devices to a specific tenant.

  • KEEPALIVE_INTERVAL Determine the interval to send the keep alive message to
    the server. This has a direct impact on the bandwidth used by the device when
    in idle state.

As this implementation uses the Docker Client, you can override the environment
variables provided for Docker in order to change some behaviors, but the
ShellHub Connector doesn't guarantee its right operation with these changes.

Check [Docker Client documentation about
this](https://pkg.go.dev/github.com/docker/[email protected]+incompatible/client#
FromEnv) for more information.

@henrybarreto henrybarreto self-assigned this May 9, 2024
@henrybarreto henrybarreto force-pushed the feature/add_connector_mode_agent branch 2 times, most recently from 26834b1 to 2647bc5 Compare May 9, 2024 15:14
@henrybarreto henrybarreto marked this pull request as ready for review May 9, 2024 15:15
@henrybarreto henrybarreto requested a review from a team as a code owner May 9, 2024 15:15
@henrybarreto henrybarreto force-pushed the feature/add_connector_mode_agent branch 2 times, most recently from cab6373 to 62400fd Compare May 9, 2024 15:28
@henrybarreto henrybarreto requested a review from a team as a code owner May 9, 2024 15:28
@henrybarreto henrybarreto force-pushed the feature/add_connector_mode_agent branch 2 times, most recently from 8e7c60c to 6ee0c03 Compare May 9, 2024 15:40
@henrybarreto henrybarreto marked this pull request as draft May 9, 2024 16:19
@henrybarreto henrybarreto force-pushed the feature/add_connector_mode_agent branch from 6ee0c03 to 3732638 Compare May 9, 2024 16:19
@henrybarreto henrybarreto marked this pull request as ready for review May 9, 2024 17:18
@henrybarreto henrybarreto force-pushed the feature/add_connector_mode_agent branch 6 times, most recently from 6dffa72 to b05531b Compare May 10, 2024 02:45
@henrybarreto henrybarreto marked this pull request as draft May 14, 2024 19:50
@henrybarreto henrybarreto force-pushed the feature/add_connector_mode_agent branch from b05531b to a4ff918 Compare May 17, 2024 15:08
Move ShellHub Connector service into a is a new kind of ShellHub Agent
that turns Docker containers into ShellHub Devices. It instances a new
ShellHub Agent, in memory, for each container running, redirecting the
SSH IO, connections in general, and authentication credentials to the
container its file system.

> As most of the containers don't have passwords set for its users per default,
it rejects the connection every time for users without credentials.

The initial implementation has support for these kinds of connections:

- [x] Shell
- [x] Exec
- [x] Heredoc

To initialize the ShellHub Connector, enter the `agent/` directory, build and
run the agent's binary with *connector* sub command.

```sh
go build -ldflags "-X main.AgentVersion=latest" -o agent &&
SERVER_ADDRESS="http://localhost/" PRIVATE_KEYS="/tmp/shellhub/"
TENANT_ID="00000000-0000-4000-0000-000000000000" ./agent connector
```

To configure the ShellHub Connector, you can/must provide these environmental
variables.

- SERVER_ADDRESS (**required**) Set the ShellHub server address of the
  agent will use to connect

- PRIVATE_KEYS (**required**) Specify the path to store the devices/containers
  private keys. If not provided, the agent will generate a new one.

- TENANT_ID (**required**) Sets the account tenant ID used during communication
  to associate the devices to a specific tenant.

- KEEPALIVE_INTERVAL Determine the interval to send the keep alive message to
  the server. This has a direct impact on the bandwidth used by the device when
  in idle state.

As this implementation uses the Docker Client, you can override the environment
variables provided for Docker in order to change some behaviors, but the
ShellHub Connector doesn't guarantee its right operation with these changes.

Check [Docker Client documentation about
this](https://pkg.go.dev/github.com/docker/[email protected]+incompatible/client#
FromEnv) for more information.
@henrybarreto henrybarreto force-pushed the feature/add_connector_mode_agent branch from a4ff918 to 02b7cfc Compare May 17, 2024 15:09
@henrybarreto henrybarreto marked this pull request as ready for review May 20, 2024 13:02
@gustavosbarreto gustavosbarreto merged commit 52189ef into master May 20, 2024
24 checks passed
@gustavosbarreto gustavosbarreto deleted the feature/add_connector_mode_agent branch May 20, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants