FreeKB - Perl SSH run command on a remote host
Perl - SSH run command on a remote host

The following Perl script can be used to execute a command on a remote host.

use Core;

my $user = "username";
my $pass = "password";
my $host = "hostname of the target server";
my $command = "the command you want to run on the target server";

($stdout, $stderr, $exit) = create_shell($host, $user, $pass);
($stdout, $stderr, $exit) = execute_shell_inline($host, $user, $command);


If you want to prompt a user for input, make sure to use chomp.

my $user = <STDIN>;


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter c5c2e in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |