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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ BUG ] ShellHub Agent Registers as New Host on System Restart in WSL2 #3456

Open
yb-cs opened this issue Jan 18, 2024 · 6 comments
Open

[ BUG ] ShellHub Agent Registers as New Host on System Restart in WSL2 #3456

yb-cs opened this issue Jan 18, 2024 · 6 comments
Assignees

Comments

@yb-cs
Copy link

yb-cs commented Jan 18, 2024

馃摑 Description

I'm experiencing an issue with the ShellHub agent in a WSL2 (Ubuntu 22.04 LTS) environment. Each time the system restarts, the host goes offline and the agent registers as a new host instead of continuing the existing session.


馃攳 Details

  • Environment: WSL2 running Ubuntu 22.04 LTS
  • Agent Build: Built the agent from source
  • Service Configuration: Using systemd service to keep the agent running
  • Issue: Despite using a custom hostname to address this problem, every system restart leads to the agent registering as a new host

馃敡 Service Configuration (with dummy information)

[Unit]
Description=ShellHub Agent
Wants=network.target
After=local-fs.target network.target time-sync.target
Requires=local-fs.target

[Service]
ExecStart=/usr/local/bin/agent
Restart=on-failure
Environment="SERVER_ADDRESS=http://dummyaddress:8080"
Environment="PRIVATE_KEY=/path/to/dummykey"
Environment="TENANT_ID=dummy-tenant-id"
Environment="PREFERRED_HOSTNAME=customhostname"

[Install]
WantedBy=multi-user.target

馃惓 Additional Context

  • Docker Issue: Attempted using Docker in WSL2, but faced terminal connection issues (netsc issue).
  • Hostname Customization: Tried using a custom hostname to prevent new host registration but the issue persists.

馃挕 Suggested Resolutions

  1. Resolving Docker with WSL2: Fixing the Docker setup in WSL2 might provide a more stable environment for running the ShellHub agent.
  2. Prevent New Device Registration: Modify the system or ShellHub configuration to not add a new device with the same name, and instead use the new connection for the existing host.
  3. Other Suggestions: Open to any recommendations or solutions that might help in resolving this issue.

Any help or guidance from the community would be greatly appreciated!

Edition

Community

Version

Latest

@gustavosbarreto
Copy link
Member

@yb-cs We're spinning up a test environment to dive deep into this.

Just a heads up, none of our core team has worked with WSL2 before, so it might take a bit for us to fix the issue.

@yb-cs
Copy link
Author

yb-cs commented Jan 18, 2024

Hey @gustavosbarreto thank you for the comment. Good luck with the setup. If you need any help let me know. My hunch is that the issue with the WSL2 when using the compiled version is the network interface not being constant (But I don't really know how the host name is really calculated etc.... in this case). Aaaaand the issue with docker in WSL2 my hunch is that it has to do with the file system structure and mounts etc in WSL2.

@gustavosbarreto
Copy link
Member

After digging into the problem on WSL, we've found that the MAC address changes with each restart, which is causing the issue.

Unfortunately, this behavior isn't something we can directly modify. On our side, we recommend using the SHELLHUB_PREFERRED_IDENTITY variable. It allows you to use a custom identifier instead of relying on the MAC address of the network interface.

@Re4mstr
Copy link

Re4mstr commented Apr 19, 2024

After digging into the problem on WSL, we've found that the MAC address changes with each restart, which is causing the issue.

Unfortunately, this behavior isn't something we can directly modify. On our side, we recommend using the SHELLHUB_PREFERRED_IDENTITY variable. It allows you to use a custom identifier instead of relying on the MAC address of the network interface.

I am having this exact issue on Arch.
Any documentation on these possible variables, and how do I use this one exactly?

@gustavosbarreto
Copy link
Member

After digging into the problem on WSL, we've found that the MAC address changes with each restart, which is causing the issue.
Unfortunately, this behavior isn't something we can directly modify. On our side, we recommend using the SHELLHUB_PREFERRED_IDENTITY variable. It allows you to use a custom identifier instead of relying on the MAC address of the network interface.

I am having this exact issue on Arch. Any documentation on these possible variables, and how do I use this one exactly?

https://docs.shellhub.io/developers/agent/installing#automatic-one-line-installation-script

@Re4mstr
Copy link

Re4mstr commented Apr 22, 2024

After digging into the problem on WSL, we've found that the MAC address changes with each restart, which is causing the issue.
Unfortunately, this behavior isn't something we can directly modify. On our side, we recommend using the SHELLHUB_PREFERRED_IDENTITY variable. It allows you to use a custom identifier instead of relying on the MAC address of the network interface.

I am having this exact issue on Arch. Any documentation on these possible variables, and how do I use this one exactly?

https://docs.shellhub.io/developers/agent/installing#automatic-one-line-installation-script

Thank you, but after investigating further, I am actually using this already.

The new client is registered with the preferred hostname, but alas, as good as every reboot generate a new unique pending device in my dashboard for that PC..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants