Figured out why. I created the ssh keys and copied them to the destination computer. Therefore, there was no invitation "Password:". Therefore, before sending can complete, the ssh connection was closed.
I removed the ssh keys from the destination machine and ran the script again and did not notice any problems
source
share