perl - How to make Net::OpenSSH exit if authentication fails? -
i'm connecting remote server using net::openssh.
my $ssh = net::openssh->new( $server, user => $user_name, passwd => $password, strict_mode => 0, master_opts => ['-v'] );
this hangs when authentication fails/when wrong password specified.
openssh_6.0p1, openssl 0.9.8d 28 sep 2006 debug1: reading configuration data /usr/software/etc/ssh_config debug1: connecting 10.53.34.200 [10.53.34.200] port 22. debug1: connection established. ... debug1: authentications can continue: publickey,password,keyboard-interactive debug1: next authentication method: keyboard-interactive debug1: authentications can continue: publickey,password,keyboard-interactive debug1: next authentication method: password
it's hanging in above line.
setting "$net::openssh::debug=-1;" returns:
debug1: authentications can continue: publickey,password,keyboard-interactive debug1: next authentication method: password # file object not yet found @ /usr/hema/.libnet-openssh-perl/diag-10.53.34.200-21463-907722 # file object not yet found @ /usr/hema/.libnet-openssh-perl/diag-10.53.34.200-21463-907722
how make exit in such case?
as module documentation here way of handling errors:
my $ssh = net::openssh->new($host); $ssh->error , die "couldn't establish ssh connection: ". $ssh->error;
Comments
Post a Comment