#!/usr/bin/perl use strict; use warnings; use Net::OpenSSH; my $ssh = Net::OpenSSH->new(host=>"$host, user=>"$user, port=>$port, password=>$password); my $cmd1 = 'cd /path/to/file'; my $cmd2 = "ls -a\n"; my $cmd3 = join ('&&', $cmd1, $cmd2); print $cmd3; $ssh->system($cmd3);