How to respond to password prompt when using SCP in a shell script? How to respond to password prompt when using SCP in a shell script? shell shell

How to respond to password prompt when using SCP in a shell script?


Use "sshpass"!

#!/bin/bashsshpass -p "password" scp -r /some/local/path user@example.com:/some/remote/path


Are ssh keys not allowed? That would be a better solution.


I don't think you can easily do that. What you can do is using public key authentication instead.

Something along these lines

ssh-keygen -t rsassh school mkdir .ssh/cat ~/.ssh/id_rsa.pub | ssh school "cat >>.ssh/authorized_keys"

(or dsa).

But hey, it's not serverfault, is it? ;-)