Recently I had to connect the phpCI as a continuous integration system to the system consisting of several distributed servers with access via ssh+password (sad but ssh-keys were disallowed). It was decided to use ssh+scp+sshpass and then phpCI could upload builds to remote servers. For this purpose I wrote the following script:
The script is simple.
frontend and acme are just example folders - use your own instead.
sshpass using only for password authorization. So You can remove it for ssh-keys auth.
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no is using for pass unknown host error.