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

feat(agent,pkg): add connector mode to agent #3115

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

henrybarreto
Copy link
Member

@henrybarreto henrybarreto commented Sep 19, 2023

What is the ShellHub Connector?

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 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.

What is working now?

The initial implementation has support for these kinds of connections:

  • Shell
  • Exec
  • Heredoc

Running Connector

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-native &&
SERVER_ADDRESS="http://localhost/" PRIVATE_KEYS="/tmp/shellhub/"
TENANT_ID="00000000-0000-4000-0000-000000000000" ./agent-native connector

Environmental variables

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.

Docker notes

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 for more information.

UI

Screenshot 2023-09-21 at 11-15-02 ShellHub

@henrybarreto henrybarreto self-assigned this Sep 19, 2023
@henrybarreto henrybarreto force-pushed the improvement/tunnel_as_agent_property branch 3 times, most recently from 187b9aa to ecc0f48 Compare September 20, 2023 20:55
@henrybarreto henrybarreto force-pushed the feat/agent_connector branch 2 times, most recently from 8a39840 to 98c0e38 Compare September 20, 2023 21:31
@henrybarreto henrybarreto force-pushed the improvement/tunnel_as_agent_property branch from ecc0f48 to 92a53e6 Compare September 20, 2023 22:22
@henrybarreto henrybarreto force-pushed the feat/agent_connector branch 2 times, most recently from ba5eaf1 to 601d7ae Compare September 20, 2023 22:33
@henrybarreto henrybarreto force-pushed the improvement/tunnel_as_agent_property branch from 92a53e6 to c9a1c1a Compare September 20, 2023 22:34
@henrybarreto henrybarreto force-pushed the feat/agent_connector branch 5 times, most recently from e701a30 to 3e1f348 Compare September 21, 2023 15:10
@henrybarreto henrybarreto force-pushed the feat/agent_connector branch 5 times, most recently from bec4518 to fea1e19 Compare September 21, 2023 17:30
@henrybarreto henrybarreto force-pushed the improvement/tunnel_as_agent_property branch 2 times, most recently from 74ffec9 to fbb157c Compare September 21, 2023 17:39
@henrybarreto henrybarreto force-pushed the improvement/tunnel_as_agent_property branch from fbb157c to aa256f6 Compare September 21, 2023 19:23
@henrybarreto henrybarreto force-pushed the improvement/tunnel_as_agent_property branch from aa256f6 to 7f1b7a0 Compare September 21, 2023 19:42
@henrybarreto henrybarreto marked this pull request as draft October 9, 2023 14:24
@henrybarreto henrybarreto force-pushed the feat/agent_connector branch 6 times, most recently from 6bc9227 to f3df040 Compare October 11, 2023 14:07
@henrybarreto henrybarreto changed the base branch from master to fix/ssh_stderr_from_agent October 11, 2023 14:07
Base automatically changed from fix/ssh_stderr_from_agent to master October 11, 2023 14:09
@henrybarreto henrybarreto force-pushed the feat/agent_connector branch 3 times, most recently from 1bbe4dd to bbc781a Compare October 11, 2023 14:14
@henrybarreto henrybarreto marked this pull request as ready for review October 11, 2023 14:15
@henrybarreto henrybarreto force-pushed the feat/agent_connector branch 6 times, most recently from 0055571 to bab99af Compare October 13, 2023 18:48
What is the ShellHub Connector?

ShellHub Connector is a new kind of ShellHub Agent that turns
[Docker](https://www.docker.com/) 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 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.

What is working now?

The initial implementation has support for these kinds of connections:

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

Running Connector

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-native &&
SERVER_ADDRESS="http://localhost/" PRIVATE_KEYS="/tmp/shellhub/"
TENANT_ID="00000000-0000-4000-0000-000000000000" ./agent-native connector
```

Environmental variables

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.

Docker notes

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.
@gustavosbarreto gustavosbarreto merged commit 7087045 into master Oct 16, 2023
15 checks passed
@gustavosbarreto gustavosbarreto deleted the feat/agent_connector branch October 16, 2023 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants