Cannot setup ssh autorized_key for normal user. But for root

Maybe I just have block…

I want to embed a ‘ssh userxy@mydietpiraspi somecmd’ in a script on a remote machine.
For arguments sake lets assume on the remote machine the username is bob.

So on my remote machine I created id_rsa in /home/bob/.ssh/ with ssh-keygen -t rsa
and on my mydietpiraspi edited /etc/ssh/sshd_config lines:
43 PubkeyAuthentication yes
44 AuthorizedKeysFile .ssh/authorized_keys

Then copied public key over with
ssh-copy-id -i /home/bob/.ssh/id_rsa.pub userxy@mydietpiraspi
prompt came for userxy passwd and I logged in successfully.

After that ssh userxy@mydietpiraspi should not prompt for a password.
But it does.
I checked for bob’s public key in userxy .ssh/authorized_keys and it is in there.

If I do the same for root@mydietpiraspi it works.
ssh-copy-id -i /home/bob/.ssh/id_rsa.pub root@mydietpiraspi
Passwd prompt for root shows up, logged in successfully.
Now bob can login as root@mydietpiraspi without being prompted for a passwd.

Why?

was there an issue to fill the troubleshooting template? You are running Dropbear or OpenSSH

We already had some cases where ssh-copy-id was not working correctly. Dropbear Public Key Authentication - #16 by MichaIng

That would be OpenSSH_8.4 on the pi.
On the remote machine where I used ssh-copy-id OpenSSH_7.9

did you check permission on files and filder for /home/userxy/.ssh if they set correctly?

They are as they should be.
the dir is owned by userxy 700
files inside too.
authorized_keys 600
known_hosts 644

can you check format of your public key [SOLVED] SSH PubkeyAuthentication not working - #5 by zenzip

it is fine, a oneliner.
And as said, it works with root, for any user on the remote machine.