tags:

views:

381

answers:

4

In Net::SCP at which point do I need DSC or RSA keys (i.e when do I use the get or put functions)?. I would like to know the scp service is available without transferring the file.

+3  A: 

Per the docs in CPAN, you need it before you even import that module, and I quote:

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

"""

In other words, NET::SCP is designed to use with "password-less" SSH authentication via pre-generated and propagated private/public key pairs.

Alex Martelli
You cite Net::SCP 0.07; the 0.08 docs add: A #2: See Net::SCP::Expect instead.
ysth
+1  A: 

Since Net::SCP is a wrapper to scp, you don't need to (meaning you can't) supply the keys to the script. You (or someone else) are expected to do the setup by configuring ssh before you attempt using it.

NET::SCP is not meant to be used 'ad hoc'. It requires ssh-configuration and exchange of keys.

EDIT incorporated ysth's comment

lexu
scp certainly can be used ad hoc, with prompting for passwords. Perhaps you meant "Net::SCP is not meant..."
ysth
yepp .. that's what I meant .. I'll fix my answer, thx!
lexu
+1  A: 

If all you want is to check if the remote system is listening on the ssh/scp port, you can try pinging:

use Net::Ping;
$p = Net::Ping->new("tcp", 2);
$p->port_number(scalar(getservbyname("ssh", "tcp")));
if ( $p->ping( $hostname ) ) {
    print "ok!";
}

You can use Net::SSH or Net::SSH::Expect or Net::SSH2 or Net::SSH::Perl if you have keys or password and want to verify that you can connect without actually transfering any files.

ysth
+1  A: 

If you are planning to use SSH using password authentication, consider Net::SSH::Perl.

Quadir