The bummer is that ssh/scp don't provide for any way (hence "expect") for you to pass them a password in non-interactive mode.
If you need to set up keys, maybe this will help - a quick step by step assuming user1 (should be whomever is going to be doing the actual transfer, so if root is running an scp for another user, that user's key will be important)
1. On the sending host, if you havent' already, for root and/or the user who the transfer will be done as, log into that account and run:
ssh-keygen -t dsa
just hit enter for all the defaults. Don't enter an extra security password or even this won't work automatically ;)
2. On the receiving host, for the user account that will be being transferred to (regardless of "where" on the machine the data is going if user2 is accepting the data and you're putting it in /tmp we need to run this command in user2's homedir)
either login as user2 and run
ssh-keygen -t dsa (unnecessary if you do the next thing ;)
or
mkdir -m 700 .ssh
cd into .ssh in user2's home directory and create a file called (depending on what version of ssh you're running) authorized_keys or authorized_keys2 (doesn't hurt to do both, either)
3. Populate authorized_keys or authorized_keys2 with the output from the id_dsa.pub file from the user on the sending host. If you cut and paste, make sure that the entry is one line when you put it into authorized_keys/authorized_keys2
A simpler way to setup the authorized_keys files is to do your first interactive scp how you would want to automate it and scp your id_dsa.pub file to [email]user2@theOtherHost:~/.ssh[/email]/authorized_keys
and/or to
[email]user2@theOtherHost:~/.auth[/email]orized_keys2
Then just send the file again (shouldn't get prompted for a password) or do a simple ssh over (the way you would during your execution) and your command should be executed remotely without a password prompt.
Hope that was helpful and I didn't leave too much out :)
Best wishes,
Mike