[Kc] Interactive Login in Perl

Scott Kahler scottk at uclick.com
Mon Jul 17 10:33:02 PDT 2006


Actually I'm using it to get past and interactive prompt and execute a
command


  my $ssh = Net::SSH::Perl->new($server);
  $ssh->login('scoota','password') || "SSH LOGIN ERROR: $server $!";

  my $str;
  $ssh->register_handler("stdout", sub {
    my($channel, $buffer) = @_;
    $str = $buffer->bytes;
    }  );
  my $cmd = 'df -hP -x smbfs';
  $ssh->cmd($cmd);
  my @lines = split(/\n/,$str);



It's not pretty but it gets the job done.



On Mon, 2006-07-17 at 11:20 -0500, Garrett Goebel wrote:
> On Jul 15, 2006, at 10:56 PM, Dan Hull wrote:
> 
> > I am trying to write some perl scripts which will be run from Cron  
> > which require interactive ssh or regular unix login.  Can someone  
> > point me in the right direction to accomplish this.
> 
> require interactive ssh?
> 
> You mean setting up "login-less" public key authentication is not an  
> option? A google search on "openssh public key authentication" will  
> turn up documentation like the following:
>      http://cfm.gs.washington.edu/security/ssh/client-pkauth/
> 
> FYI: Net::SSH won't help with interactive logins. Using pre- 
> configured RSA or DSA keys is a prerequisite. It's in the Net::SSH  
> docs in the FAQ:
>      http://search.cpan.org/dist/Net-SSH/ 
> SSH.pm#FREQUENTLY_ASKED_QUESTIONS
> 
> 
> regular unix login?
> 
> If by that you mean execute something locally using different  
> credentials... you might try:
>      http://search.cpan.org/dist/Sudo/lib/Sudo.pm
> 
> I've never used it. But it might do what you need.
> 
> cheers,
> 
> Garrett
> _______________________________________________
> kc mailing list
> kc at pm.org
> http://mail.pm.org/mailman/listinfo/kc

Scott Kahler
=-=-=-=-=-=-=-=-=-=-=-=-=
Programmer
http://www.uclick.com
816-210-8884
scottk at uclick.com
=-=-=-=-=-=-=-=-=-=-=-=-=

In the beginning the Universe was created. This has made a lot of people
very
angry and been widely regarded as a bad move. 




More information about the kc mailing list