net:scp Host key verification failed

L

lerameur

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
 
J

J. Gleixner

lerameur said:
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.
 
L

lerameur

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
 
L

lerameur

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
 
J

J. Gleixner

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.
 
L

lerameur

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top