For example, I can use
ssh-id-copy to get the key and login to the remote server without entering the password.
Is there a similar mechanism to run as root without prompting password?
I don't know. If login with a key is sort of safe, then I argue there should be a mechanism like that for
NOPASSWD is not a good solution, however.