Don't create PrivateKey on install #774

Open
opened 2025-11-20 05:17:17 -05:00 by saavagebueno · 4 comments
Owner

Originally created by @euh2 on GitHub (Apr 4, 2024).

Problem

I struggled with a weird issue. I deployed several machines from one base image. In the base image I have Netbird preinstalled. From all machines only one would connect to the Netbird Network. When checking the machines, all of them would have the same /etc/netbird/config.json, i.e. the same PrivateKey.

Since Netbird is installed at Image build time, the keys are the same for all deployed instances. That does of course not work.

To Reproduce

See above

Expected behavior

Create the PrivateKey when first running netbird up.

Are you using NetBird Cloud?
No

NetBird version

0.27.0

Originally created by @euh2 on GitHub (Apr 4, 2024). **Problem** I struggled with a weird issue. I deployed several machines from one base image. In the base image I have Netbird preinstalled. From all machines _only one_ would connect to the Netbird Network. When checking the machines, all of them would have the same `/etc/netbird/config.json`, i.e. the same **PrivateKey**. Since Netbird is installed at Image build time, the keys are the same for all deployed instances. That does of course not work. **To Reproduce** See above **Expected behavior** Create the **PrivateKey** when first running `netbird up`. **Are you using NetBird Cloud?** No **NetBird version** 0.27.0
saavagebueno added the feature-request label 2025-11-20 05:17:17 -05:00
Author
Owner

@sbrw commented on GitHub (Jan 21, 2025):

Is there a workaround for this?
What is used for creation of the private key? Machine ID, SSH key...?

@sbrw commented on GitHub (Jan 21, 2025): Is there a workaround for this? What is used for creation of the private key? Machine ID, SSH key...?
Author
Owner

@0xSeb commented on GitHub (Jun 4, 2025):

We face the exact same issue running multiple EC2 instances from our base AMI where we baked the install of netbird. Anything planned for this or a workaround ?

@0xSeb commented on GitHub (Jun 4, 2025): We face the exact same issue running multiple EC2 instances from our base AMI where we baked the install of netbird. Anything planned for this or a workaround ?
Author
Owner

@0xSeb commented on GitHub (Jun 4, 2025):

We just found a workaround in our base AMI

  • install netbird
  • rm /etc/netbird/config.json

When we start netbird with a setup key, this file gets generated with a new private key and all.

@0xSeb commented on GitHub (Jun 4, 2025): We just found a workaround in our base AMI - install netbird - rm /etc/netbird/config.json When we start netbird with a setup key, this file gets generated with a new private key and all.
Author
Owner

@nazarewk commented on GitHub (Jun 4, 2025):

How did you guys end up with NetBird client started while building the images?

Generally, those should be cleared (like A LOT of other dynamic data) before dumping the system image for reuse.


What is used for creation of the private key? Machine ID, SSH key...?

It's a random key depending on nothing specific.


We just found a workaround in our base AMI

* install netbird

* rm /etc/netbird/config.json

When we start netbird with a setup key, this file gets generated with a new private key and all.

You have the right idea. This should be in a post-baking/wrapup step for any kind of AMI/base image before storing it anywhere for reuse.


It's probably not easy in the current codebase, but a feature that would generate the keys upon first connection attempt would make some sense in the future.

@nazarewk commented on GitHub (Jun 4, 2025): How did you guys end up with NetBird client started while building the images? Generally, those should be cleared (like A LOT of other dynamic data) before dumping the system image for reuse. --- > What is used for creation of the private key? Machine ID, SSH key...? It's a random key depending on nothing specific. --- > We just found a workaround in our base AMI > > * install netbird > > * rm /etc/netbird/config.json > > > When we start netbird with a setup key, this file gets generated with a new private key and all. You have the right idea. This should be in a post-baking/wrapup step for any kind of AMI/base image before storing it anywhere for reuse. --- It's probably not easy in the current codebase, but a feature that would generate the keys upon first connection attempt would make some sense in the future.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#774