Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Net::SCP::Expect RSA Fingerprint Problem

by anshumangoyal (Scribe)
on Jan 11, 2013 at 04:34 UTC ( #1012789=perlquestion: print w/replies, xml ) Need Help??

anshumangoyal has asked for the wisdom of the Perl Monks concerning the following question:

I am facing issue with Net::SCP::Expect while performing SCP. It sometimes dies saying
The authenticity of host can't be established. RSA Fingerprint is XXXX Are you Sure Yes/No
I want to check how Net::SCP::Expect can perform no host checking and just do an SCP. Is there any way to do that?

Replies are listed 'Best First'.
Re: Net::SCP::Expect RSA Fingerprint Problem
by salva (Abbot) on Jan 11, 2013 at 08:28 UTC
    If the option StrictHostKeyChecking=no is passed to OpenSSH ssh client and no key exists on the known_hosts file for the target host, it will accept as good (and remembered for future connections) the first one received from the remote host.

    Though, I don't see how extra options for ssh can be passed through Net::SCP::Expect.

    Anyway, you can use Net::OpenSSH instead:

    $ssh = Net::OpenSSH->new($host, user => $user, password => $password, master_opts => [-o => 'StrictHostKeyChecking= +no']); $ssh->scp_put(...); $ssh->scp_get(...);

    Note that disabling strict host key checking has some security implications that you should be aware of.

      Even Net::SCP::Expect has this option. This is how you pass this:
      my $scp_exp = Net::SCP::Expect->new( host => $host, user => $user, password => $pass, timeout => undef, auto_yes => 1, recursive => 1, option => 'StrictHostKeyCheck +ing=no' );
      Thanks for the Great Help. This worked like a charm!!
        I must admit I do like to see feedback from the original question poster indicating which solution to the problem actually worked for them. Thanks for updating us.
        A Monk aims to give answers to those who have none, and to learn from those who know more.
        How can I give the options 'StrictHostKeyChecking=no' and 'UserKnownHostsFile=/dev/null'? auto_yes => 1 is working only with option => 'StrictHostKeyChecking=no'.
Re: Net::SCP::Expect RSA Fingerprint Problem
by quester (Vicar) on Jan 11, 2013 at 06:47 UTC

    You could try auto_yes if you just want to answer every question coming from scp with a yes...

      This is my Code:
      my $scp_exp = Net::SCP::Expect->new( host => $host, user => $user, password => $pass, timeout => undef, auto_yes => 1 );
      Still I am getting this error. Dont know what all is happening.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012789]
Approved by davido
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2020-07-10 22:23 GMT
Find Nodes?
    Voting Booth?

    No recent polls found