How to enable sshpass output to the console

Using scp and interactively entering a password, the process of copying files is sent to the console, but when using sshpass , the console does not have a script for scp files.

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

Sshpass seems to suppress or hide scp console output. Is there any way to enable scp sshpass output to the console?

+6
source share
1 answer

In this way:

output = $ (sshpass -p $ PASSWD scp -v $ filename root@192.168.8.1 : / root 2> & 1)

echo "Output = $ output"

you are redirecting console output to variable output.

Or, if you want to see only the console output of the scp command, you should add only the -v command to your ssh pass cmd:

sshpass -p $ PASSWD scp -v $ filename root@192.168.8.1 : / root

+1
source

All Articles