public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* sshd - sftp problem (perl demo)
@ 2010-07-27  5:40 Sisyphus
  2010-07-27  6:28 ` Sisyphus
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sisyphus @ 2010-07-27  5:40 UTC (permalink / raw)
  To: cygwin

Hi,

I have the following perl script that attempts to connect (from native 
Windows) to an sshd server (either localhost, which is a Cygwin sshd server, 
or a remote linux host)
and create a Net::SSH2::SFTP object.

###############################
use warnings;
use Net::SSH2;

my ($host, $user, $pass) = qw(blah blah blah);

my $ssh2 = Net::SSH2->new;
die "can't connect" unless $ssh2->connect($host);

print "Connected\n";

die "can't authenticate"
 unless $ssh2->auth(username => $user,
                    password => $pass);

print "Authenticated\n";

my $sftp = $ssh2->sftp;
print $sftp, "\n"; # Line 19

$ssh2->disconnect();
###############################

Works fine when connecting to the sshd server on the remote linux box. The 
script
then outputs:

C:\_32\pscrpt\net-ssh2>perl cygwin.pl
Connected
Authenticated
Net::SSH2::SFTP=SCALAR(0x2a92594)

But when I modify the script to connect to the Cygwin sshd server I get:

C:\_32\pscrpt\net-ssh2>perl cygwin.pl
Connected
Authenticated
Use of uninitialized value $sftp in print at cygwin.pl line 19.

No problem with the connection or the authentication, but the call to
$ssh2->sftp is clearly failing.

First thing that comes to mind is that I might need to install/run something
additional for SFTP to be enabled on Cygwin. All I've done is install
cygrunsrv and openssh, and then start the openssh server with 'net start
sshd'. Did I miss something ?

Second thing that comes to mind is that connecting via user cyg_server 
(using the password I created when I ran 'ssh-host-config -y') might not be 
the right thing to do. Is it ?

Third thing that comes to mind is that it might be permissions related.

Advice welcome.

I'm also unable to upload files to the Cygwin installation using SCP. 
(Again, no problems with SCP when connected to the remote linux box.)

Cheers,
Rob



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sshd - sftp problem (perl demo)
  2010-07-27  5:40 sshd - sftp problem (perl demo) Sisyphus
@ 2010-07-27  6:28 ` Sisyphus
  2010-07-27  7:12 ` Andrew DeFaria
  2010-07-27  7:12 ` AW: [bulk] - " DEWI - N. Zacharias
  2 siblings, 0 replies; 4+ messages in thread
From: Sisyphus @ 2010-07-27  6:28 UTC (permalink / raw)
  To: cygwin


----- Original Message ----- 
From: "Sisyphus" <sisyphus1@optusnet.com.au>

> I'm also unable to upload files to the Cygwin installation using SCP. 
> (Again, no problems with SCP when connected to the remote linux box.)

Where I've written "SCP", I meant "SCP over ssh".

Cheers,
Rob


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sshd - sftp problem (perl demo)
  2010-07-27  5:40 sshd - sftp problem (perl demo) Sisyphus
  2010-07-27  6:28 ` Sisyphus
@ 2010-07-27  7:12 ` Andrew DeFaria
  2010-07-27  7:12 ` AW: [bulk] - " DEWI - N. Zacharias
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew DeFaria @ 2010-07-27  7:12 UTC (permalink / raw)
  To: cygwin


On 07/26/2010 10:36 PM, Sisyphus wrote:
> Hi,
>
> I have the following perl script that attempts to connect (from native 
> Windows) to an sshd server (either localhost, which is a Cygwin sshd 
> server, or a remote linux host)
> and create a Net::SSH2::SFTP object.
>
> ###############################
> use warnings;
> use Net::SSH2;
>
> my ($host, $user, $pass) = qw(blah blah blah);
>
> my $ssh2 = Net::SSH2->new;
> die "can't connect" unless $ssh2->connect($host);
>
> print "Connected\n";
>
> die "can't authenticate"
> unless $ssh2->auth(username => $user,
>                    password => $pass);
>
> print "Authenticated\n";
>
> my $sftp = $ssh2->sftp;
> print $sftp, "\n"; # Line 19
>
> $ssh2->disconnect();
> ###############################
>
> Works fine when connecting to the sshd server on the remote linux box. 
> The script
> then outputs:
>
> C:\_32\pscrpt\net-ssh2>perl cygwin.pl
> Connected
> Authenticated
> Net::SSH2::SFTP=SCALAR(0x2a92594)
>
> But when I modify the script to connect to the Cygwin sshd server I get:
>
> C:\_32\pscrpt\net-ssh2>perl cygwin.pl
> Connected
> Authenticated
> Use of uninitialized value $sftp in print at cygwin.pl line 19.
>
> No problem with the connection or the authentication, but the call to
> $ssh2->sftp is clearly failing.
Have you ever heard of the Perl debugger? Simply start your script with 
perl -d <script> and wham you're in it! Then you don't have to be 
telling us things like line 19 and you can set a break point at line 19 
and examine variables, etc. Actually there are tons of things you can do 
and if you plan on working with Perl at all it behooves you to look into 
the debugger.

That said, my first thought is, well obviously the sftpd is configured a 
lot better on the Linux system than it is on your Cygwin system. My 
second thought is - why are you even bothering with sftp? Just use scp.
> First thing that comes to mind is that I might need to install/run 
> something
> additional for SFTP to be enabled on Cygwin. All I've done is install
> cygrunsrv and openssh, and then start the openssh server with 'net start
> sshd'. Did I miss something ?
Have you tried actually using the sftp command at a command line prompt?
> Second thing that comes to mind is that connecting via user cyg_server 
> (using the password I created when I ran 'ssh-host-config -y') might 
> not be the right thing to do. Is it ?
>
> Third thing that comes to mind is that it might be permissions related.
>
> Advice welcome.
>
> I'm also unable to upload files to the Cygwin installation using SCP. 
> (Again, no problems with SCP when connected to the remote linux box.)
So again I ask you, if you can scp remotehost:/path/file to 
localhost:/path/file why do you care about using sftp?

Regarding your other post where you say you mean "scp is scp over ssh" 
that's a pretty meaningless statement. Of course scp is *cp* over ssh, 
that's why it's called *s*cp!
-- 
Andrew DeFaria <http://defaria.com>
As the shopper placed her groceries on the checkout stand, the bagger 
asked her paper or plastic? Doesn't matter, she replied, I'm bisackual.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* AW: [bulk] - sshd - sftp problem (perl demo)
  2010-07-27  5:40 sshd - sftp problem (perl demo) Sisyphus
  2010-07-27  6:28 ` Sisyphus
  2010-07-27  7:12 ` Andrew DeFaria
@ 2010-07-27  7:12 ` DEWI - N. Zacharias
  2 siblings, 0 replies; 4+ messages in thread
From: DEWI - N. Zacharias @ 2010-07-27  7:12 UTC (permalink / raw)
  To: cygwin




Hi,

> Von: Sisyphus
> Gesendet: Dienstag, 27. Juli 2010 07:37
> An: cygwin
> Betreff: [bulk] - sshd - sftp problem (perl demo)
>
> Hi,
>
> I have the following perl script that attempts to connect (from native
> Windows) to an sshd server (either localhost, which is a Cygwin sshd server,
> or a remote linux host)
> and create a Net::SSH2::SFTP object.
>
> ###############################
> use warnings;
> use Net::SSH2;
>
> my ($host, $user, $pass) = qw(blah blah blah);
>
> my $ssh2 = Net::SSH2->new;
> die "can't connect" unless $ssh2->connect($host);
>
> print "Connected\n";
>
> die "can't authenticate"
>  unless $ssh2->auth(username => $user,
>                     password => $pass);

Have a look at
http://prlmnks.org/html/569657.html
they mentioned that auth does not work

# authorize
# this works but I use keys below
# $ssh2->auth_password('z','foopass') or die "Unable to login $@ \n";

#this dosn't work
#$ssh2->auth(username=>'z', interact => 1);

Maybe it helps.

Have fun
Norbert

--------------------------------------------------------------------------
Dipl. Phys.
Norbert Zacharias
Wind Measurements & Power Curve Measurements
DEWI GmbH
Ebertstrasse 96
26382 Wilhelmshaven
Germany


Tel.:   +49 4421 4808 876

Fax:    +49 4421 4808 843


Email:  N.Zacharias@dewi.de
Home:   http://http://www.dewi.de

DEWI GmbH - Deutsches Windenergie-Institut, Wilhelmshaven
Commercial Register No.: Amtsgericht Oldenburg, HRB 130241
Managing Director: Jens Peter Molly
Chairman of the supervisory board: Ministerialrat Dr. Niels Kämpny

P Please consider the environment before printing this email.



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-07-27  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-27  5:40 sshd - sftp problem (perl demo) Sisyphus
2010-07-27  6:28 ` Sisyphus
2010-07-27  7:12 ` Andrew DeFaria
2010-07-27  7:12 ` AW: [bulk] - " DEWI - N. Zacharias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).