in reply to Re: Net::OpenSSH key authentication
in thread Net::OpenSSH key authentication

Hi, Thanks for your help. You're right what I thought but I didn't know how to check it. Script looked for the keys in wrong directory. And script given by salva showed me what directory it should be. From some reason it looked files in directory /var/www/scripts/ not /var/www/scripts/new/ even if everything happens in /var/www/scripts/new and $ENV{HOME} is set to /var/www/scripts/new too. Weird. Thank you for help again. Regards, Jarek

Replies are listed 'Best First'.
Re^3: Net::OpenSSH key authentication
by Shine (Initiate) on Jan 16, 2014 at 20:06 UTC
    Hi everyone, i'm trying to use key authentication using Net::OpenSSH. can someone please help me to understand the issue with my script
    use Net::OpenSSH; use warnings; my $path = "/export/home/tenfold2/.ssh/"; $Net::OpenSSH::debug |= 16; my $t = Net::OpenSSH->new('ildep@sxm0019', master_opts => [-o => "U +serKnownHostsFile=/dev/null", -o => "StrictHostKeyChecking=no"], time +out => 10, ctl_dir => $path); $t->error and SendMail "unable to connect to remote host: ". $t->err +or; my $cmd = "ls -l";
    When i run the script it gives below message:
    x Connecting to sxm0019 command-line: line 0: Bad configuration option: ServerAliveInterval unable to connect to remote host: unable to establish master SSH conne +ction: master process exited unexpectedly
    ssh -vvv ildep@sxm0019 echo "hello world" >/tmp/ssh.out 2>&1
    /tmp/ssh.out: debug2: we did not send a packet, disable method debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Trying private key: /export/home/tenfold2/.ssh/identity debug3: no such identity: /export/home/tenfold2/.ssh/identity debug1: Trying public key: /export/home/tenfold2/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: xx hint 1 debug2: input_userauth_pk_ok: xx debug3: sign_and_send_pubkey debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey) debug1: fd 6 setting O_NONBLOCK debug2: fd 7 is O_NONBLOCK debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug1: send channel open 0 debug1: Entering interactive session. debug2: callback start debug1: ssh_session2_setup: id 0 debug1: Sending command: echo hello world debug1: channel request 0: exec debug2: callback done debug1: channel 0: open confirm rwindow 0 rmax 32768 debug2: channel 0: rcvd adjust 198560 debug1: channel 0: rcvd eof debug1: channel 0: output open -> drain debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: rcvd close debug1: channel 0: close_read debug1: channel 0: input open -> closed debug3: channel 0: will not send data after close hello world debug3: channel 0: will not send data after close debug1: channel 0: obuf empty debug1: channel 0: close_write debug1: channel 0: output drain -> closed debug1: channel 0: almost dead debug1: channel 0: gc: notify user debug1: channel 0: gc: user detached debug1: channel 0: send close debug1: channel 0: is dead debug1: channel 0: garbage collecting debug1: channel_free: channel 0: client-session, nchannels 1 debug3: channel_free: status: The following connections are open: #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1) debug3: channel_close_fds: channel 0: r -1 w -1 e 7 debug1: fd 1 clearing O_NONBLOCK debug2: fd 2 is not O_NONBLOCK debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.1 seconds debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0 debug1: Exit status 0 rc: 0