#!/usr/bin/perl use strict; use warnings; use Net::SSH qw(ssh issh sshopen2); my $user = "USERNAME"; my $host = "HOSTNAME"; my $cmd = "passwd USERNAME"; sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!"; while () { chomp(); print "$_\n"; } close(READER); close(WRITER);