After editing OpenSSH.pm to not disable publickey and not getting anywhere while being able to run same ssh command manually I got stuck. The problem is public key authentication (key is coming from ssh-agent, NOT the local file) to the gateway host. Here is what happens with one called from perl :
# call args: ['ssh','-o','CheckHostIP no','-o','HashKnownHosts no','-o +','StrictHostKeyChecking no','-o','VerifyHostKeyDNS no','-o','UserKno +wnHostsFile /dev/null','-o','HostbasedAuthentication no','-o','Challe +ngeResponseAuthentication no','-o','RhostsRSAAuthentication no','-o', +'GSSAPIAuthentication no','-o','ProxyCommand=ssh -o "PasswordAuthenti +cation no" -o "GSSAPIAuthentication no" -vvv -k root@192.168.1.1 nc % +h 22','-o','PasswordAuthentication yes','-o','PubkeyAuthentication ye +s','-o','ServerAliveInterval=30','-x2MN','-o','NumberOfPasswordPrompt +s=1','-o','PreferredAuthentications=publickey,keyboard-interactive,pa +ssword','-S','/root/.libnet-openssh-perl/root-10.20.30.40-16309-99228 +','-l','root','10.20.30.40','--']
Output from perl:
debug1: Authentications that can continue: publickey,gssapi-with-mic,p +assword debug3: start over, passed a different list publickey,gssapi-with-mic, +password debug3: preferred publickey,keyboard-interactive debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Trying private key: /root/.ssh/id_rsa debug3: no such identity: /root/.ssh/id_rsa debug1: Trying private key: /root/.ssh/id_dsa debug3: no such identity: /root/.ssh/id_dsa debug2: we did not send a packet, disable method debug1: No more authentication methods to try. Permission denied (publickey,gssapi-with-mic,password).
And this one is manual :
ssh -o "CheckHostIP no" -o "HashKnownHosts no" -o "StrictHostKeyChecki +ng no" -o "VerifyHostKeyDNS no" -o "UserKnownHostsFile /dev/null" -o +"PasswordAuthentication yes" -o "PubkeyAuthentication yes" -o "ProxyC +ommand=ssh -vvv root@192.168.1.1 nc %h 22" -o "ServerAliveInterval=30 +" -x2MN -o "NumberOfPasswordPrompts=1" -o "PreferredAuthentications=p +ublickey,keyboard-interactive,password" -S /tmp/zzz -l root 10.20.30. +40
Output:
debug3: remaining preferred: publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering DSA public key: /HOME/MY_KEY.DSA debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: pkalg ssh-dss blen 432

In reply to Re^4: Establishing SSH tunnel and opening another SSH connection through it by tehcook
in thread Establishing SSH tunnel and opening another SSH connection through it by tehcook

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.