When I execute this from command line, I get prompted for joe's password (which is what I want):
ssh -t 192.168.1.32 'scp joe@192.168.1.31:/etc/hosts /tmp'
When I try to run the same command from a perl script, it just hangs there (with no prompt):
`ssh -t 192.168.1.32 'scp joe\@192.168.1.31:/etc/hosts /tmp'`;
How can I make this work from a Perl script?
Note: No, I cannot use key-based authentication for this.
Best Answer
You could use Expect. See https://stackoverflow.com/a/1366802
(and the Expect module FAQ on this topic http://search.cpan.org/~rgiersig/Expect-1.15/Expect.pod#I_want_to_automate_password_entry_for_su/ssh/scp/rsh/... )