Problem:
When I scp directly from user1 (user1@box1# ssh box2) -- all is good.
When I scp from root user (root@box1# ssh user1@box2) -- I am prompted for a password.
Following command should help you to copy the file with root user over user1's ssh keys. In fact you'll temporarily switch to user1 and run that scp command.
su -c "scp /tmp/file1 user1@box2:/tmp/file1" user1
I thought you wanted to login as root, but now I think I see what you want.
You are are root in your local box and want to login as an user1 to remote, if so, your public key as root in the local machine, must be appended to your urser1 account $HOME/.ssh/authorized_keys in the remote.
That file, by the way, needs to have permission 600.
(
USER=user1
eval HOME=~$USER
export USER HOME
cd $HOME
su $USER -fc "scp /tmp/file1 box2:/tmp/file1"
)
Not having the isolated - skips the login files. Because some su's don't set USER and HOME we set it beforehand. This is done in a (subshell), so the environment is not changed in the main shell. The -f might skip other shell start files.
Another correction:
The auth key file is authorized_keys or authorized_keys2
Thank you everyone! Even though I'm sure most of the other proposed ways would work also, I ended up adding roots pub key in my target home folders auth file and that solved my issue.