SSH key error ... sometimes

These two things are inconsistent:

balena ssh dd641d8fd65c20db1b11ff990c762218
    Welcome to balenaOS

but, the same device and app:

~/m/Balena-ROS-Melodic (gopigo3=) balena ssh gopigo3.local
root@gopigo3.local: Permission denied (publickey).
Warning: ssh process exited with non-zero code "255"

Are the SSH keys correctly configured in balenaCloud? See:

~/m/Balena-ROS-Melodic (gopigo3=)

and the same happens if I give a specific IP address.

Can you help me understand please?

Can you clarify the version of the balena cli & the version & variant of balenaOS that you are using?
Please note that using an ip or a .local address is only supported for the development variants of balenaOS or production versions were you have added your ssh keys during the provisioning process.
Let me also point you to our docs for this:

Kind regards,