Here's an article that explains how to setup key-based authentication:
Linux.com :: Using key-based authentication over SSH
You may want to google around for other examples if this one doesn't work for you.
After the public key for USER_A has been created and appended to the authorized_keys file of USER_B, you can run local scripts like this:
As USER_A:
ssh USER_B@localhost /path/to/script
You would need to copy the public key to each user's authorized_keys file that you wish to execute commands as.