Reputation: 1571
I am using scp to copy a file from one server to another. Both of the servers need a password to be passed with sshpass so I need to use sshpass twice in the same command. Note that I am using the -3
flag because server foo cannot directly communicate with server boo.
I tried
sshpass -p 'foo' scp -3 [email protected]:/home/foo/foo.txt sshpass -p 'boo' [email protected]:/home/boo/
but it didn't work, no error message, just didn't copy the file. Is there a way to accomplish this?
Note: Please don't suggest answers using key pair, I want to pass in the password rather than using keys (or prompting the user to type the password), I know it is visible to the whole system and that it is not secure, I still want to do it.
Upvotes: 1
Views: 2057
Reputation: 20688
This is not possible.
According to scp
manual:
-3
Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts. Note that this option disables the progress meter and selects batch mode for the second host, since scp cannot ask for passwords or passphrases for both hosts.
And according to ssh_config
manual:
BatchMode
If set to
yes
, user interaction such as password prompts and host key confirmation requests will be disabled. This option is useful in scripts and other batch jobs where no user is present to interact withssh(1)
. The argument must beyes
orno
(the default).
Upvotes: 1