I can use
ssh -i ~/.ssh/id_rsa root@SERVER to connect to my Ubuntu VM but I have another user in same VM and I would like to connect directly to it. I tried
ssh -i ~/.ssh/id_rsa newuser@SERVER but I get this error:
Permission denied (publickey)
The issue is likely that the non-root user on the server does not have a
~/.ssh/authorized_keys file, or that it does not contain the correct public SSH key. Copying the correct public SSH key to that file should make the login over SSH work.