Re: SFTP on Windows
by salva (Canon) on Jul 30, 2018 at 07:32 UTC
|
| [reply] [d/l] [select] |
|
|
Thank you for the advice, but my ppm isnt able to conncect to sisyphusion, via Internet Explorer i can open up the page but ppm is telling me "ERROR: 500 Can't connect to www.sisyphusion.tk:80 (timeout)" have you heard about such a failure?
| [reply] |
|
|
Most likely, your browser connects to the outside world through a proxy. You will need to configure the same proxy settings with the ppm tool. Most likely, just setting up the HTTP_PROXY environment variable already is enough.
| [reply] [d/l] |
|
|
| [reply] |
|
|
EDIT: Firstly i would like to thank you all for the help so far, but im getting from one problem to another ;)
After some problems with the ppm and proxy i finally managed to install Net::SSH2 Net::SFTP::Foreign and Net::SFTP::Foreign::Backend::Net_SSH2, by using ppm install "Modulename" --force after setting sisyphusion in the repository list, but when i now try to start my script:
use strict;
use Net::SFTP::Foreign;
my $host = "127.0.0.1";
my $user = "Admin";
my $port = "22";
#my $timeout = "5";
my $key = "C:/Users/BeckerB/Desktop/SFTP Schluessel/Private.ppk";
#$ssh_cmd = "C:/Users/BeckerB/Desktop/SDH1/applikation/model/modules/N
+et/OpenSSH.pm";
print $key;
my $sftp = Net::SFTP::Foreign->new( $host, user=>$user, port=>$port, b
+ackend=>'Net_SSH2', timeout=>30, key_path=>$key );
print "\ntest1\n";
#$sftp = Net::SFTP::Foreign->new($host, user=>$user, key_path=>$key, s
+sh_cmd=>);
$sftp->die_on_error("SSH connection failed");
print "\nok\n";
i get a failure: Unable to load backend Net_SSH2: Can't locate loadable object for module Net::SSH2 in @INC (@INC contains: ../model/GPS ../Xtensions ../model ../model/modules ../model/mymodules ../model/mymodules ../model/modules ../model ../Xtensions ../model/GPS C:/Users/BeckerB/Desktop/SDH1/server/perl/lib .) at ../model/modules/Net/SFTP/Foreign/Backend/Net_SSH2.pm line 15
Compilation failed in require at ../model/modules/Net/SFTP/Foreign/Backend/Net_SSH2.pm line 15.
BEGIN failed--compilation aborted at ../model/modules/Net/SFTP/Foreign/Backend/Net_SSH2.pm line 15.
Compilation failed in require at (eval 9) line 1.
at C:\Users\BeckerB\Desktop\SDH1\applikation\controller\test.pl line 11
anyone got a problem like this before?
Update: I reinstalled the packages. Now it works better | [reply] [d/l] |
|
|
Re: SFTP on Windows
by Corion (Patriarch) on Jul 30, 2018 at 07:13 UTC
|
Net::SSH2 comes included with Strawberry Perl, so maybe you want to try that.
It supports SFTP and I've used the file transfer capabilities of the SSH protocol to good effect.
Maybe if you can tell us in more detail how things fail for you, we can give you answers closer to the actual problem you are encountering.
| [reply] |
|
|
| [reply] [d/l] |
Re: SFTP on Windows
by davies (Monsignor) on Jul 30, 2018 at 07:03 UTC
|
I don't know that much about the subject, but the first thing I would try is your public key. I see it has an extension of ppk, which I have always thought was specific to PuTTY. If you have a key with a pub extension, you might consider trying that. Otherwise, I have no ideas.
Regards,
John Davies
| [reply] [d/l] [select] |
Re: SFTP on Windows
by Poolstar (Acolyte) on Jul 30, 2018 at 07:37 UTC
|
Ive forgot to mention that im also limited to perl 5.12.4
when i try to start the script it gets to "my $ssh = Net::OpenSSH->new( $host, user=>$user, port=>$port, timeout=>30, key_path=>$key );" and afterwards nothing happen. I don't get an error or anything else, the print command afterwards doesnt happen either. | [reply] |
Re: SFTP on Windows
by jahero (Pilgrim) on Jul 31, 2018 at 07:04 UTC
|
Hello there!
I have been tackling the same issue several months ago. By that time, I failed to "make it work" directly from perl, and resorted to writing a thin wrapper over WinSCP. It is long enough in the past so that I am no longer able to recollect why exactly I did it like this, sorry.
Now, I am not claiming at all that this is the best approach, but it worked in my case.
The code itself is probably too long to be posted here, and it is definitely not generic enough to be put to CPAN, but if you want to take a look at it just to have more options, give me a holer, and I will send it to you.
https://winscp.net/eng/docs/portable
https://winscp.net/eng/docs/scripting
UPDATE: added "not" in the sentence stating the code is not generic enough to be pushed to CPAN.
| [reply] |
Re: SFTP on Windows
by Poolstar (Acolyte) on Jul 31, 2018 at 13:02 UTC
|
So far so good, i managed to install all the packages and now the libssh2 through your help. My code is:
use strict;
use Net::SFTP::Foreign;
use Net::SSH2;
my $ssh2 = Net::SSH2->new();
my $host = "127.0.0.1";
my $user = "Admin";
my $port = "22";
#my $timeout = "5";
my $key = "C:/Users/BeckerB/Desktop/SFTP Schluessel/Private.ppk";
#$ssh_cmd = "C:/Users/BeckerB/Desktop/SDH1/applikation/model/modules/N
+et/OpenSSH.pm";
print $key;
my $sftp = Net::SFTP::Foreign->new( $host, user=>$user, port=>$port, b
+ackend=>'Net_SSH2', timeout=>30, key_path=>$key );
print "\ntest1\n";
#$sftp = Net::SFTP::Foreign->new($host, user=>$user, key_path=>$key, s
+sh_cmd=>);
$sftp->die_on_error("SSH connection failed");
print "\nok\n";
I now get the following failure: "SSH connection failed: authentication failed: LIBSSH2_ERROR_AGENT_PROTOCOL (-42): failed connecting agent at C:\Users\BeckerB\Desktop\SDH1\applikation\controller\test.pl line 16" i already tryed to google the failure code but i couldnt find something, anybody got an idea what im still doing wrong?
| [reply] [d/l] |
Re: SFTP on Windows
by Poolstar (Acolyte) on Aug 03, 2018 at 09:33 UTC
|
Final Update: My script is running now, the problem was the key created by PuTTy-Gen, i now created a new key via Git Bash and now it works, thank you all for the help! My final script is:
use strict;
use Net::SFTP::Foreign;
use Net::SSH2;
#$Net::SFTP::Foreign::debug = -1;
my $host = "127.0.0.1";
my $user = "Admin";
my $port = "22";
my $key_path = "C:/Users/BeckerB/Desktop/SDH1/applikation/Private.ppk"
+;
my $publickey = "C:/Users/BeckerB/Desktop/SDH1/applikation/ssh/Private
+.ppk.pub";
my $ssh2 = Net::SSH2->new();
$ssh2->connect($host, 22) or die "Keine Verbindung";
$ssh2->auth_publickey($user, $publickey, $key_path) or die "Falscher S
+chlüssel";
my $sftp = Net::SFTP::Foreign->new(ssh2=> $ssh2, backend => 'Net_SSH2'
+);
$sftp->error and die "Keine SFTP Verbindung möglich" . $sftp->error;
#my $sftp = Net::SFTP::Foreign->new( $host, username=>$user, publickey
+=>$publickey , port=>$port, privatekey=>$key_path, backend=>'Net_SSH2
+', timeout=>30, );
print "\ntest1\n";
#$sftp->die_on_error("SSH connection failed");
print "\nok\n";
| [reply] [d/l] |