in reply to secure remote command
This one uses passwords:
#!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; my $user = "zz"; my $password = "ztest"; my $host = 'zentara.zentara.net'; my $cmd = "/usr/bin/wvdial"; my $ssh = Net::SSH::Perl->new( $host, port => 22 ,debug => 1); $ssh->login($user,$password); my($out) = $ssh->cmd($cmd); print "$out\n";
This one uses keys:
#!/usr/bin/perl #this uses Net::SSH, instead of Net::SSH::Perl #and it needs the key method of authentication, #it won't use passwords. #use strict; #use warnings; use Net::SSH qw(sshopen3); my $user = "zz"; my $host = "zentara.zentara.net"; my $cmd = "/usr/bin/wvdial"; sshopen3( "$user\@$host", *WRITER, *READER, *ERROR, "$cmd" ); my $out = <READER>; my $error = <ERROR>; chomp $out; print "$out\n"; print "$error\n";
|
|---|