service run not respecting global flags #2185

Open
opened 2025-11-20 07:05:29 -05:00 by saavagebueno · 2 comments
Owner

Originally created by @ProjectInitiative on GitHub (Aug 15, 2025).

Describe the problem

The netbird service run command does not correctly handle the --setup-key or --setup-key-file flags. Although the flags are present in the command's help output, they are ignored when the service starts, leading to a "no peer auth method provided" error.

This is confusing because the netbird up command gives a warning that suggests using netbird service run with configuration flags:

Warning: Config flag is deprecated on up command, it should be set as a service argument with $NB_CONFIG environment or with "-config" flag; netbird service reconfigure --service-env="NB_CONFIG=<file_path>" or netbird service run --config=<file_path>.

A workaround is to run netbird service run in one terminal and netbird up --setup-key <key> in another, but this seems counterintuitive given the warning message.

To Reproduce

Steps to reproduce the behavior:

  1. Run netbird service run with either the --setup-key or --setup-key-file flag.

netbird service run --setup-key <your_key>

netbird service run --setup-key-file /path/to/your/key

  1. Observe the logs.
  2. See the error:
failed to login to Management Service: rpc error: code = PermissionDenied desc = no peer auth method provided, please use a setup key or interactive SSO login

Expected behavior

The netbird service run command should use the provided setup key to register the
peer and start the service without any errors.

Are you using NetBird Cloud?

Yes

NetBird version

0.54.2

Is any other VPN software installed?

I am not aware of any other VPN software installed.

Debug output

To help us resolve the problem, please attach the following anonymized status
output

netbird status -dA

Create and upload a debug bundle, and share the returned file key:

netbird debug for 1m -AS -U

Uploaded files are automatically deleted after 30 days.

Alternatively, create the file only and attach it here manually:

netbird debug for 1m -AS

Screenshots

N/A

Additional context

The root cause of this issue appears to be in the code that handles the service run command. The setupKey flag is parsed from the command line, but its value is not passed to the function that initializes the NetBird service.

Specifically:

  • In client/cmd/service_controller.go, the runCmd function calls server.New
    without passing the setupKey.
  • The server.New function in client/server/server.go does not accept a setupKey as
    a parameter.
  • As a result, the setupKey is never passed down to the internal.Login or
    internal.Register functions where it is needed for authentication.

If the service run command is not intended to use the --setup-key or
--setup-key-file flags, then these flags should be removed from its help output to
avoid confusion.

Have you tried these troubleshooting steps?

  • Reviewed [client troubleshooting
    (https://docs.netbird.io/how-to/troubleshooting-client) (if applicable)
  • Checked for newer NetBird versions
  • Searched for similar issues on GitHub (including closed ones)
  • Restarted the NetBird client
  • Disabled other VPN software
  • Checked firewall settings
Originally created by @ProjectInitiative on GitHub (Aug 15, 2025). Describe the problem The netbird service run command does not correctly handle the `--setup-key` or `--setup-key-file` flags. Although the flags are present in the command's help output, they are ignored when the service starts, leading to a "no peer auth method provided" error. This is confusing because the netbird up command gives a warning that suggests using netbird service run with configuration flags: ```bash Warning: Config flag is deprecated on up command, it should be set as a service argument with $NB_CONFIG environment or with "-config" flag; netbird service reconfigure --service-env="NB_CONFIG=<file_path>" or netbird service run --config=<file_path>. ``` A workaround is to run `netbird service run` in one terminal and `netbird up --setup-key <key>` in another, but this seems counterintuitive given the warning message. To Reproduce Steps to reproduce the behavior: 1. Run `netbird service run` with either the `--setup-key ` or `--setup-key-file` flag. `netbird service run --setup-key <your_key>` `netbird service run --setup-key-file /path/to/your/key` 2. Observe the logs. 3. See the error: ```bash failed to login to Management Service: rpc error: code = PermissionDenied desc = no peer auth method provided, please use a setup key or interactive SSO login ``` Expected behavior The netbird service run command should use the provided setup key to register the peer and start the service without any errors. Are you using NetBird Cloud? Yes NetBird version 0.54.2 Is any other VPN software installed? I am not aware of any other VPN software installed. Debug output To help us resolve the problem, please attach the following anonymized status output netbird status -dA Create and upload a debug bundle, and share the returned file key: netbird debug for 1m -AS -U Uploaded files are automatically deleted after 30 days. Alternatively, create the file only and attach it here manually: netbird debug for 1m -AS Screenshots N/A Additional context The root cause of this issue appears to be in the code that handles the service run command. The setupKey flag is parsed from the command line, but its value is not passed to the function that initializes the NetBird service. Specifically: * In client/cmd/service_controller.go, the runCmd function calls server.New without passing the setupKey. * The server.New function in client/server/server.go does not accept a setupKey as a parameter. * As a result, the setupKey is never passed down to the internal.Login or internal.Register functions where it is needed for authentication. If the service run command is not intended to use the --setup-key or --setup-key-file flags, then these flags should be removed from its help output to avoid confusion. Have you tried these troubleshooting steps? - [ ] Reviewed [client troubleshooting (https://docs.netbird.io/how-to/troubleshooting-client) (if applicable) - [ ] Checked for newer NetBird versions - [ ] Searched for similar issues on GitHub (including closed ones) - [ ] Restarted the NetBird client - [ ] Disabled other VPN software - [ ] Checked firewall settings
saavagebueno added the triage-needed label 2025-11-20 07:05:29 -05:00
Author
Owner

@lixmal commented on GitHub (Aug 27, 2025):

Hi @ProjectInitiative,

In what situations do you need to run netbird service run manually? The intended functionality is that the setup key is passed to netbird up.

The warning you were seeing refers to the --config flag only.

@lixmal commented on GitHub (Aug 27, 2025): Hi @ProjectInitiative, In what situations do you need to run `netbird service run` manually? The intended functionality is that the setup key is passed to `netbird up`. The warning you were seeing refers to the `--config` flag only.
Author
Owner

@ProjectInitiative commented on GitHub (Aug 27, 2025):

For automated deployments. But this is more about the inconsistencies of the help menu and argument parsing. If there is an intended way of setup and deployment, the help menu should not lead users astray. service run says it supports the setup key flags. If it is not intended to be used that way like you said, it should not be included in the global flag menu.

@ProjectInitiative commented on GitHub (Aug 27, 2025): For automated deployments. But this is more about the inconsistencies of the help menu and argument parsing. If there is an intended way of setup and deployment, the help menu should not lead users astray. `service run` says it supports the setup key flags. If it is not intended to be used that way like you said, it should not be included in the global flag menu.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#2185