Device failed to register with balena after adding ssh key to the config.json


I try to enable ssh (not balena ssh) on the raspberrypi3 by updating the config.json in the image.

I updated the config.json by adding the ssh key

      "deviceType": "raspberrypi3",
      "localMode": true,
      "persistentLogging": false,
      "os": {
        "sshKeys": [

Then I used the balena inject command to update the config.json on my application image.

balena config inject /root/config.json --type raspberrypi3 --drive /root/balena_img/balena-cloud-myapp-raspberrypi3-2.38.0+rev1-v9.15.7.img

After that I used the balenaEtcher tool to flash the SD card but the pi was not able to register with the balena cloud. The device was not shown on the dashboard. I could ssh to the pi directly though using the device’s ip address (balena reused the same ip address on the same raspberrypi). The ssh key is configured properly as I can ssh directly to the device now but the device failed to register with balena.

Any idea? Is balena config inject the right command to update the config.json on the image?


This behaviour is expected. balena inject will overwrite the config.json already present in the image with the new one, it does not perform any form of merger of the two.
Your new config.json lacks the configuration needed to connect to our backend. Here is an example of a config.json that would connect to the backend with an pubkey added:

{"applicationName":"NAME","applicationId":ID,"deviceType":"raspberrypi3","userId":ID,"username":"USER","appUpdatePollInterval":600000,"listenPort":48484,"vpnPort":443,"apiEndpoint":"","vpnEndpoint":"","registryEndpoint":"","deltaEndpoint":"","pubnubSubscribeKey":"","pubnubPublishKey":"","mixpanelToken":"KEY","apiKey":"KEY", "os": {"sshKeys": ["KEY1"]}}

You can download this configuration file from the dashboard under Advanced, in the same form where you download your OS image you will see a tick box: Download configuration file only. There you can get a valid config.json that will connect to that application, after you have this configuration file append your configuration and inject it into the image.
Kind regards,


That fixed my problem. Thanks!