Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable sshpass output to console

Tags:

scp

sshpass

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?

like image 925
jacknad Avatar asked May 05 '16 12:05

jacknad


People also ask

What is Sshpass command?

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.

How do I get Sshpass in Linux?

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.

Does Sshpass work with SCP?

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.


1 Answers

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
like image 107
18446744073709551615 Avatar answered Oct 21 '22 12:10

18446744073709551615