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.
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.
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
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.
If you are planning to use SSH using password authentication, consider Net::SSH::Perl.