#!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; use Term::ReadKey; my $host = 'localhost'; my $username = 'username'; my $cmd = '/sbin/ifconfig'; warn "Starting ssh: "; my $ssh = Net::SSH::Perl->new($host, protocol => '2,1', debug => 1); print "done", "\n"; print "Your password: "; ReadMode('noecho'); chomp(my $password = ReadLine(0)); ReadMode('restore'); print "\n"; warn "Starting login: "; $ssh->login($username, $password); print "login done", "\n"; warn "Starting command: "; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print $stdout, "\n";