Hi wise monks, after several days of going in circles I would like some help.
I have a webform (CGI) that I am developing, and after the user fills in various parts of the form, I need to copy a file from one server to another. I have a short sample code (that isn't CGI-based but may illustrate my problem) below:
#!/usr/bin/perl -w -T
my $ssh = Net::SSH::Expect->new (
host => "<IP>",
user => "<username>",
raw_pty => 1
$ssh->run_ssh() or die "SSH Process couldn't start: $!";
$ssh->exec("stty raw -echo");
my $who = $ssh->exec("whoami");
my $scp = "scp <file> <username>\@<IP Address>:<destinationpath>;
$ssh->exec($scp) or die "SCP Process error: $!";
I understand that the taint flag isn't necessary in this short example, but it is required for the main application and I believe is causing most of my problems.
Prior to this attempt, I have also tried using system() to run the scp:
system('ssh <user>\@<IP> scp $file <user2>\@<Destination IP>:<destinat
This involved untainting all variables before this call. This attempt resulted in a slew of errors ("Can't exec 'ssh': No such file or directory", "sh: 1: ssh: not found").
I had read (although I may be wrong) that the Net::SSH::Expect module does not have full support for taint mode.
Also, as the script is generally being run from the web, the user for the commands is www-data (I don't know exactly what relevance this has, but it seems to be important, at least in my debugging attempts).
Thank you very much for any help or advice you can give. If more information is needed, I'm happy to provide it (I just can't think of anything else to include at the moment).