Cant log in due to Permission Denied

ssh -p 22222 root@192.168.1.38 
root@192.168.1.38: Permission denied (publickey).

Even though I have checked twice that my public key is registered in Balena cloud, which is how I deployed the app.

Is there an additional step I am missing?

Hi, @pitosalas,
to use balena CLI, you need to login to your balenaCloud account as described here: https://www.balena.io/docs/learn/more/masterclasses/cli-masterclass/#12-authentication.
Could you please follow these steps and let us know how it worked for you?

Please note above I am not using balena cli.

Is the device in local mode ?
Does it work with balena ssh 192.168.1.38 work ?

There are two ssh public keys in the cloud, one for each of my computers. Does that cause a potential problem?

Because balena ssh 192.168.1.38 also doesnโ€™t work but I am sure it has worked before. I get a slightly longer error message.

balena ssh 192.168.1.38


   โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
   โ”‚                                                                    โ”‚
   โ”‚                  Update available 12.7.7 โ†’ 12.9.1                  โ”‚
   โ”‚                                                                    โ”‚
   โ”‚   https://github.com/balena-io/balena-cli/blob/master/INSTALL.md   โ”‚
   โ”‚                                                                    โ”‚
   โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

root@192.168.1.38: Permission denied (publickey).
Warning: ssh process exited with non-zero code "255"

Are the SSH keys correctly configured in balenaCloud? See:
https://www.balena.io/docs/learn/manage/ssh-access/#add-an-ssh-key-to-balenaclou

And, no, itโ€™s not in local mode.

Hi,

It could be that your SSH public key is out of date. You can check that what you have on your workstation matches whatโ€™s in balenaCloud preferences. Something like cat ~/.ssh/id_rsa.pub and then compare that with the key in balena. If you have two keys, you may have to explicitly add the proper identity to your ssh command, such as ssh -i ~/.ssh/id_rsa -p 22222 root@<ip-adddress>.

John

Hi,

Did you happen to disable/enable VPN on any of these devices? Weโ€™re looking into this as perhaps related to your ssh issue.

Thanks,
John

Not knowingly or on purpose.

Pito Salas
Brandeis Computer Science
Volen 134

Hi Pito,
I think there is a misunderstanding here.
You are accessing your device directly via ssh. For that to work the device must either have a development version of Balena installed or you must add your public key to the device. The keys stored in balena-cloud are for accessing devices via balena-cli.
Does balena ssh <device-uuid> work for you ? If yes your keys are OK.
To register your key on the device and be able to use ssh you need to add the key to the devices config.json (in /mnt/boot/config.json) as explained here https://github.com/balena-os/meta-balena#sshkeys . Please be very careful when editing config.json - a broken config.json will prevent your device from coming online and starting balena properly. I strongly suggest making a copy of the file and testing your edits with jq before rebooting the device. cat /mnt/boot/config.json | jq should display no errors if your edit was correctโ€ฆ
Regards Thomas

1 Like

Thanks for the great answer. I understand now.