net:scp Host key verification failed

Discussion in 'Perl Misc' started by lerameur, Oct 12, 2007.

  1. lerameur

    lerameur Guest

    hello,

    I am using ftp in perl script with no problem. I want to use SCP
    instead of ftp but I am not having any luck. Do I need a key on the
    receiving end??. The script uses the put command and gives me an error
    when it cannot use this command:

    .....
    $SCP->cwd($directory) or $newerr=1; #getting into the directory
    push @ERRORS, "Can't cd $!\n" if $newerr;
    myerr() if $newerr;
    $SCP->quit if $newerr;

    $SCP->put("$file_to_put") or die $SCP->{errstr};
    print "Putting file and quitting \n";

    $SCP->quit;

    Here the error message:
    Connected
    Getting file list
    Logged in
    unable to initialize mechanism library [/usr/lib/gss/gl/mech_krb5.so]
    Host key verification failed.
    lost connection
    lerameur, Oct 12, 2007
    #1
    1. Advertising

  2. lerameur

    J. Gleixner Guest

    lerameur wrote:
    > hello,
    >
    > I am using ftp in perl script with no problem. I want to use SCP
    > instead of ftp but I am not having any luck. Do I need a key on the
    > receiving end??. The script uses the put command and gives me an error
    > when it cannot use this command:
    >
    > ....
    > $SCP->cwd($directory) or $newerr=1;


    What is $SCP???.. I'm guessing it's Net::SCP, but yes
    you need to set up the authorized_keys file appropriately on the
    destination machine.

    First, get ssh working from the command line, then
    Net::SCP should work.

    perldoc Net::SCP

    FREQUENTLY ASKED QUESTIONS

    Q: How do you supply a password to connect with ssh within a perl script
    using the Net::SSH module?

    A: You don't. Use RSA or DSA keys. See the ssh-keygen(1) manpage.
    J. Gleixner, Oct 12, 2007
    #2
    1. Advertising

  3. lerameur

    lerameur Guest

    On Oct 12, 2:08 pm, "J. Gleixner" <>
    wrote:
    > lerameur wrote:
    > > hello,

    >
    > > I am using ftp in perl script with no problem. I want to use SCP
    > > instead of ftp but I am not having any luck. Do I need a key on the
    > > receiving end??. The script uses the put command and gives me an error
    > > when it cannot use this command:

    >
    > > ....
    > > $SCP->cwd($directory) or $newerr=1;

    >
    > What is $SCP???.. I'm guessing it's Net::SCP, but yes
    > you need to set up the authorized_keys file appropriately on the
    > destination machine.
    >
    > First, get ssh working from the command line, then
    > Net::SCP should work.
    >
    > perldoc Net::SCP
    > in and getting a different error message:


    > FREQUENTLY ASKED QUESTIONS
    >
    > Q: How do you supply a password to connect with ssh within a perl script
    > using the Net::SSH module?
    >
    > A: You don't. Use RSA or DSA keys. See the ssh-keygen(1) manpage.


    yes it is the net::scp module.
    I tryed using ssh session manually, worked..Tried the ftp agained and
    obtained a different error message:
    how do I set the key properly

    Connected
    Getting file list
    Logged in
    unable to initialize mechanism library [/usr/lib/gss/gl/mech_krb5.so]
    Permission denied (publickey,password,keyboard-interactive).
    lost connection
    lerameur, Oct 12, 2007
    #3
  4. lerameur

    lerameur Guest

    On Oct 12, 2:47 pm, lerameur <> wrote:
    > On Oct 12, 2:08 pm, "J. Gleixner" <>
    > wrote:
    >
    >
    >
    > > lerameur wrote:
    > > > hello,

    >
    > > > I am using ftp in perl script with no problem. I want to use SCP
    > > > instead of ftp but I am not having any luck. Do I need a key on the
    > > > receiving end??. The script uses the put command and gives me an error
    > > > when it cannot use this command:

    >
    > > > ....
    > > > $SCP->cwd($directory) or $newerr=1;

    >
    > > What is $SCP???.. I'm guessing it's Net::SCP, but yes
    > > you need to set up the authorized_keys file appropriately on the
    > > destination machine.

    >
    > > First, get ssh working from the command line, then
    > > Net::SCP should work.

    >
    > > perldoc Net::SCP
    > > in and getting a different error message:
    > > FREQUENTLY ASKED QUESTIONS

    >
    > > Q: How do you supply a password to connect with ssh within a perl script
    > > using the Net::SSH module?

    >
    > > A: You don't. Use RSA or DSA keys. See the ssh-keygen(1) manpage.

    >
    > yes it is the net::scp module.
    > I tryed using ssh session manually, worked..Tried the ftp agained and
    > obtained a different error message:
    > how do I set the key properly
    >
    > Connected
    > Getting file list
    > Logged in
    > unable to initialize mechanism library [/usr/lib/gss/gl/mech_krb5.so]
    > Permission denied (publickey,password,keyboard-interactive).
    > lost connection


    I also ran the ssh-keygen -t rsa command.
    This created a key on one server. I copied this key on the other
    server, still do not work

    k
    lerameur, Oct 12, 2007
    #4
  5. lerameur

    J. Gleixner Guest

    lerameur wrote:
    [...]
    > I also ran the ssh-keygen -t rsa command.
    > This created a key on one server. I copied this key on the other
    > server, still do not work


    "Still do not work" isn't very helpful. How did you get it to work
    on the command line?

    Regardless, this isn't related to perl so I suggest you learn
    about ssh/scp by searching/reading/trial and error/whatever and
    post questions to a more appropriate ssh, scp, or OS related
    newsgroup.

    In short:

    man ssh
    man scp

    Basically you copy the id_rsa.pub, or whatever public key
    you created, to the destination machine, into that login's
    $HOME/.ssh/authorized_keys2 file.

    Then you should be able to test it by running "date" on
    the remote host.

    ssh remote.host.name date

    if that works then scp will work.

    scp file remote.host.net:remote_file_name

    and Net::SCP should work.
    J. Gleixner, Oct 12, 2007
    #5
  6. lerameur

    lerameur Guest

    On Oct 12, 4:10 pm, "J. Gleixner" <>
    wrote:
    > lerameur wrote:
    >
    > [...]
    >
    > > I also ran the ssh-keygen -t rsa command.
    > > This created a key on one server. I copied this key on the other
    > > server, still do not work

    >
    > "Still do not work" isn't very helpful. How did you get it to work
    > on the command line?
    >
    > Regardless, this isn't related to perl so I suggest you learn
    > about ssh/scp by searching/reading/trial and error/whatever and
    > post questions to a more appropriate ssh, scp, or OS related
    > newsgroup.
    >
    > In short:
    >
    > man ssh
    > man scp
    >
    > Basically you copy the id_rsa.pub, or whatever public key
    > you created, to the destination machine, into that login's
    > $HOME/.ssh/authorized_keys2 file.
    >
    > Then you should be able to test it by running "date" on
    > the remote host.
    >
    > ssh remote.host.name date
    >
    > if that works then scp will work.
    >
    > scp file remote.host.net:remote_file_name
    >
    > and Net::SCP should work.


    ok good, I copied the key into the accepting server and it now works.

    now I get an error when I am quitting:

    Can't locate object method "quit" via package "Net::SCP" (perhaps you
    forgot to load "Net::SCP"?) at ./ftptest.pl line 36.
    line 36: $scp->quit;



    this looks like a valid command from http://perldoc.net/Net/SCP.pm
    there is also a nice tutorial on generating the keys at
    http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node31.html

    k
    lerameur, Oct 12, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moi
    Replies:
    1
    Views:
    5,825
  2. krabhi
    Replies:
    1
    Views:
    9,295
    Marco Meschieri
    Aug 9, 2006
  3. Bob T
    Replies:
    0
    Views:
    275
    Bob T
    Sep 19, 2007
  4. Une Bévue
    Replies:
    0
    Views:
    380
    Une Bévue
    Jul 22, 2008
  5. lerameur

    net:scp Host key verification failed

    lerameur, Oct 12, 2007, in forum: Perl Misc
    Replies:
    0
    Views:
    85
    lerameur
    Oct 12, 2007
Loading...

Share This Page