/usr/share/doc/libnet-ssh2-perl/examples/scat.pl is in libnet-ssh2-perl 0.63-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #!/usr/bin/perl
use strict;
use warnings;
use Net::SSH2;
use Getopt::Long;
my ($host, $port, $user, $pwd);
GetOptions("host|h=s" => \$host,
"port|p=s" => \$port,
"user|u=s" => \$user,
"password|pwd|pw|w=s" => \$pwd)
or die "Failed to process arguments";
$host // die "hostname missing";
$user //= getpwuid $<;
$port //= '22';
my $ssh2 = Net::SSH2->new();
# $ssh2->debug(1);
$ssh2->connect($host, $port) or $ssh2->die_with_error;
$ssh2->check_hostkey or $ssh2->die_with_error;
if ($pwd) {
$ssh2->auth_password($user, $pwd);
}
else {
$ssh2->auth_password_interact($user);
}
my $channel = $ssh2->channel or $ssh2->die_with_error;
$channel->exec("cat @ARGV") # FIXME: quote the arguments!
or $ssh2->die_with_error;
$channel->send_eof;
my $buffer;
while (1) {
$channel->read($buffer, 32*1024) or last;
print $buffer;
}
my $exit_status = $channel->exit_status;
undef $channel;
$ssh2->disconnect;
exit($exit_status);
|