How to ssh to Balena OS, a build generated from Balena Yocto project


I generated a build using Balena yocto project for the device: npe-x500-m3. After generating the build, I used balena cli to configure the network and the hostname(basegateway). After writing the image to the device storage, I can see the device is up and can ping to it.

$ ping basegateway
PING basegateway.localdomain ( 56(84) bytes of data.
64 bytes from ( icmp_seq=9 ttl=128 time=2.75 ms
64 bytes from ( icmp_seq=10 ttl=128 time=1.89 ms
64 bytes from ( icmp_seq=11 ttl=128 time=1.78 ms

However, ssh fails. I tried the following:

$ balena ssh basegateway
and also,
$ balena ssh basegateway.local
both ending into the same result(Fleet or device not found).

I can ssh into the device if I use the add device function from my balena dashboard and download a preconfigured build. I have following questions:

  1. How do I ssh into the balena OS which is generated by building an image from the Balena yocto prject. Is there something I can configure in the Yocto project?
  2. Where in meta-balena is config.json generated and can I add ssh-keys before triggering the build so that generated image already has my ssh keys?
  3. Also, how do I add this device into the fleet on my dashboard? The only option I can see is either I download a preconfigured image or the config.json file.

Thank you!


  1. Did you specify you wanted to build a development image in Yocto?
    The development and production images handle SSH differently.

  2. As far as I understand, this is generated in the meta-balena/meta-balena-common/recipes-core/images/ recipe, based on the meta-balena/meta-balena-common/classes/image-balena.bbclass.

  3. What worked for me was to use balena os configure <image> --app <app> --device-type <device> before flashing the image.

1 Like

Thanks @TJvV – you got it!