Re: [Ssh-sftp-perl-users] How to load my private DSA key for authentication?
Brought to you by:
dbrobins
From: Anthony L. <ant...@ya...> - 2012-02-09 16:39:38
|
Thank you for your hint. Yes, I am really after sftp, and I did try Net::SFTP::Foreign. But I can't seem to succeed. Problem is I can't figure out what combination of parameters I should use in the constructor. use Net::SFTP::Foreign; $host = "my.sftp.server.com"; $port = 22; $user = "myusername"; $keypath = "c:/path/to/private.key"; $ssh = "c:/path/to/putty.exe"; my $sftp = Net::SFTP::Foreign-> new(host=>$host, port=>$port, user=>$user, ssh_cmd=>$ssh, key_path=>$keypath); if ($sftp->error) { print "sftp error: ". $sftp ->error."\n"; } I get an error running this, which says "Invalid option 'key_path' or bad combination of options at ..". I have to use the given user name and the given private key file to get authenticated by the remote SFTP server. ________________________________ From: Russ Brewer <us...@gm...> To: Anthony Liu <ant...@ya...> Sent: Wednesday, February 8, 2012 5:24 PM Subject: Re: [Ssh-sftp-perl-users] How to load my private DSA key for authentication? Net::SSH::Perl supports PKI keys. This is how I do it -- and how I error check it. eval {$ssh = Net::SSH::Perl->new($remote_server, debug=>0)}; if ($@) { print "Failed SSH Connection to $remote_server\n"; print "$@\n"; } else { print " Successful SSH connection to $remote_server\n"; } ## Don't need to $user or $password if PKI key pairs are set up, working correctly, and ## script is being run by $user ## $ssh->login($user, $password) eval {$ssh->login()}; if ($@) { print "Failed Login on Server $remote_server\n"; print "$@"; } else { print " Successful SSH login to $remote_server\n"; } Test your key pairs manually from the command line to be sure they are set up correctly. But if what you are really after is a Net::SFTP file transfer, I recommend Net::SFTP::Foreign instead of Net::SFTP (which is build on Net::SSH::Perl) On Wed, Feb 8, 2012 at 4:48 PM, Anthony Liu <ant...@ya...> wrote: Hi, I am wondering if anyone of you could give me a hint. Using Net::SSH::Perl, how do I authenticate myself through my user name and my DSA private key? > > >$host = "my.server.com"; >$user = "myusername"; >$pk = "private.key"; >$port = 22; > > >$sftp = Net::SSH::Perl->new (?????); # What constructor do I use? > > >Any hint? Thank you. > > >If Net::SSH::Perl doesn't support public/private key authentication, what other module can I use? Any minimum working example? >------------------------------------------------------------------------------ >Keep Your Developer Skills Current with LearnDevNow! >The most comprehensive online learning library for Microsoft developers >is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, >Metro Style Apps, more. Free future releases when you subscribe now! >http://p.sf.net/sfu/learndevnow-d2d >_______________________________________________ >Ssh-sftp-perl-users mailing list >Ssh...@li... >https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > |