Access device after deletion

Hi all,

I have a device which is deleted from balenaCloud by a colleague (:sweat_smile:). It still has everything running on it, and I’d like to access it via SSH. It’s an UP Squared board with the UP image on it (balenaOS 2.29.2+rev1). I’ve tried to add an SSH key via the config.json. I’ve setup an Live USB of Ubuntu via that way, changed the config.json.

I’ve added the following on root level of the JSON:

"os": {
  "sshKeys": [
    "ssh-rsa ..."

But when I try to SSH into it, it still says “permission denied (publickey)”. So it looks like the SSH key isn’t added.

Did I do something wrong, or is there any other way to access the device? I have to login into the running device, because I have to run a script on it for the very last time.

Thanks in advance!

Hello, are you running a production image?

Yeah, unfortunately it is a production image…

If you have added custom ssh keys before provisioning the image, then you should still be able to SSH into the device to login even after deleting the device through standalone SSH, like:

ssh -p 22222 -i ~/.ssh/id_rsa root@<ip>

Also, can you provide more information into how you are adding SSH keys and editing config.jsoneven after deleting the device.


Thanks for your help!
I have a Live USB of Ubuntu, and use the ‘Try without installing’ option.
Then, I mount the resin-boot and change the config.json inside that partition.
After saving the file, I reboot the UP Squared and remove the Live USB, so it starts Balena.

But I still get the permission denied when SSH’ing into it, using the correct SSH key.

That should work but manually editing the config.json is a bit error-prone, so to rule out any such errors can you please do it this way:

cat /mnt/boot/config.json | jq . > /mnt/boot/
vi  /mnt/boot/
(edit file)
cat /mnt/boot/ | jq .
(verify file is parseable)
cat /mnt/boot/ | jq . > /mnt/boot/config.json

I’m going to try that tomorrow. However, I’ve copied the JSON to my IDE when trying this, and added the SSH keys there and minified it again. It also checks if the JSON is valid, which it was. So probably the JSON is valid.

But it’s correct that I should change the config.json in the resin-boot partition, and not anywhere else?

Yes that’s correct, you only need to change the config.json file in the resin-boot partition (this partition is mounted at /mnt/boot/).


It still doesn’t work, so maybe you guys can spot the problem. This is my config.json at /resin-boot/config.json (with some things left out):

  "apiEndpoint": "",
  "appUpdatePollInterval": "900000",
  "applicationId": "<app-id>",
  "applicationName": "<app-name>",
  "deltaEndpoint": "",
  "deviceApiKey": "<api-key>",
  "deviceApiKeys": {
    "": "<api-key>"
  "deviceId": "<device-id>",
  "deviceType": "up-board",
  "listenPort": "48484",
  "mixpanelToken": "<token>",
  "pubnubPublishKey": "",
  "pubnubSubscribeKey": "",
  "registered_at": "1575315785",
  "registryEndpoint": "",
  "userId": "<user-id>",
  "username": "<user-name>",
  "uuid": "<uuid>",
  "vpnEndpoint": "",
  "vpnPort": "443",
  "persistentLogging": "true",
  "os": {
    "sshKeys": [
      "ssh-rsa AAAAB3NzaC1yc2EAAAA...."

I can’t figure out what’s wrong and why it keeps declining my SSH key…

your config.json file looks fine, I have just tried it myself and I have to say, I had to be very careful because the text editor I was using to copy the key wants to reformat the string (line breaks).

also make sure you are copying the complete public ssh-key, in my case it was:
"os": { "sshKeys": [ "ssh-rsa ########" ] }
after that balena ssh <Device's IP Address>

I would say it may be a problem on how the Key is getting copied, or that your local machine is not using the exact same key. I hope this helps, please get back to us if it doesn’t