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?
What is sshpass? The sshpass utility is designed to run SSH using the keyboard-interactive password authentication mode, but in a non-interactive way. SSH uses direct TTY access to ensure that the password is indeed issued by an interactive keyboard user.
Install sshpass on Linux Systems In RedHat/CentOS based systems, first you need to enable Epel repository on your system to install it using yum command as shown. On Debian/Ubuntu and its derivatives, you can install it using apt-get command as shown.
sshpass is a useful tool used for running ssh authentication in non-interactive mode. Using sshpass you can use passwords to ssh or scp command without interactions, which helps to utilize in shell scripts.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With