#!/usr/bin/perl use strict; use warnings; #use Net::OpenSSH; #use Expect; use Net::SSH::Expect; # # You can do SSH authentication with user-password or without it. # my $uName= "admin1"; # Making an ssh connection with user-password authentication # 1) construct the object my $ssh = Net::SSH::Expect->new ( host => "192.168.56.101", password=> "Passw0rd1", user => "admin1", raw_pty => 1 ); # 2) logon to the SSH server using those credentials. # test the login output to make sure we had success my $login_output = $ssh->login(); if ($login_output !~ /Welcome/) { die "Login has failed. Login output was $login_output"; } print "Connected to $uName\n";