How to enable sshpass output to console

jacknad picture jacknad · May 5, 2016 · Viewed 12.8k times · Source

Using scp and interactively entering the password the file copy progress is sent to the console but there is no console output when using sshpass in a script to scp files.

$ sshpass -p [password] scp [file] root@[ip]:/[dir]

It seems sshpass is suppressing or hiding the console output of scp. Is there a way to enable the sshpass scp output to console?

Answer

18446744073709551615 picture 18446744073709551615 · Apr 20, 2018

After

sudo apt-get install expect

the file send-files.exp works as desired:

#!/usr/bin/expect -f

spawn scp -r $FILES $DEST
match_max 100000
expect "*?assword:*"
send -- "12345\r"
expect eof