Home > Archive > PERL Beginners > August 2007 > Net:SFTP Configuration
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Net:SFTP Configuration
|
|
| Kilaru Rajeev 2007-08-16, 4:03 am |
| Hi All,
I have installed Net:SFTP on my UNIX (SOLARIS) machine. I have generated the
Public and Private key pair. I have installed the Public on my remote
machine with the server as OpenSSH. All the dependent modules are also
installed. Please let me know what are all the remaining things I need to
configure and how I have to configure them.
Thanks,
Rajeev Kilaru
| |
| Jeff Pang 2007-08-16, 4:03 am |
|
-----Original Message-----
>From: kilaru rajeev <kilarurajeev@gmail.com>
>Sent: Aug 16, 2007 1:28 PM
>To: beginners@perl.org
>Subject: Net:SFTP Configuration
>
>Hi All,
>
>I have installed Net:SFTP on my UNIX (SOLARIS) machine. I have generated the
>Public and Private key pair. I have installed the Public on my remote
>machine with the server as OpenSSH. All the dependent modules are also
>installed. Please let me know what are all the remaining things I need to
>configure and how I have to configure them.
>
What're your left problems then?Can you login to that remote host with SSH key?If so,the left thing you need to do is to read Net::SFTP's document and program it.It not so,you need to check the SSH configuration and make it work fine.
--
Jeff Pang <pangj@earthlink.net>
http://home.arcor.de/jeffpang/
| |
| Kilaru Rajeev 2007-08-16, 7:59 am |
| Hi Jeff,
I could able to connect to the remote machine with normall ssh. When I treid
to connect through a perl program it is giving following error.
*Starting ftp for getting Fund files.Connecting to SFTP Server: tisact.txt
in new of perl mod ..
cfg object :Net::SSH::Perl::Config=HASH(0x10663c):
Received disconnect message: Too many authentication failures for crdadm
at /crd.dev/perl/lib/site_perl/5.6.1/Net/SSH/Perl/AuthMgr.pm line 142
*
I dont know how to proceed from here. Someone please guide me.
Thanks,
Rajeev Kilaru
On 8/16/07, Jeff Pang <pangj@earthlink.net> wrote:
>
>
>
> -----Original Message-----
> the
>
>
> What're your left problems then?Can you login to that remote host with SSH
> key?If so,the left thing you need to do is to read Net::SFTP's document and
> program it.It not so,you need to check the SSH configuration and make it
> work fine.
>
> --
> Jeff Pang <pangj@earthlink.net>
> http://home.arcor.de/jeffpang/
>
| |
| Chas Owens 2007-08-16, 7:01 pm |
| On 8/16/07, kilaru rajeev <kilarurajeev@gmail.com> wrote:
> Hi Jeff,
>
> I could able to connect to the remote machine with normall ssh. When I treid
> to connect through a perl program it is giving following error.
>
> *Starting ftp for getting Fund files.Connecting to SFTP Server: tisact.txt
> in new of perl mod ..
> cfg object :Net::SSH::Perl::Config=HASH(0x10663c):
> Received disconnect message: Too many authentication failures for crdadm
> at /crd.dev/perl/lib/site_perl/5.6.1/Net/SSH/Perl/AuthMgr.pm line 142
> *
> I dont know how to proceed from here. Someone please guide me.
snip
Can you ssh from the command line to the other box? Something like
ssh user@host
without typing a password? If so then something is wrong with the
library or your environment.
If you are using encrypted keys you should have a copy of ssh-agent
running that will given the ssh connection the unencrypted key, but
ssh doesn't know the pid of ssh-agent and must be told what it is with
an environmental variable. If the Perl code is running in an
environment that does not have this variable set it will fail.
Another common problem is that different versions of Unix (and Linux)
use different implementations of ssh. This isn't a problem for most
things, but they tend to use different formats for the private and
public key files. You may have to convert the key generated on one
platform to the format expected by another.
| |
| Kilaru Rajeev 2007-08-16, 7:01 pm |
| I had generated the Key pair. I installed the public key on the server. And,
while generating the keys I had not passed any *passphrase.* That is why, it
is not asking for the password/passphrase while connecting. I guess we need
to provide the configuration details in our program while connecting to the
server.
Thanks,
Rajeev Kilaru
On 8/16/07, Chas Owens <chas.owens@gmail.com> wrote:
>
> On 8/16/07, kilaru rajeev <kilarurajeev@gmail.com> wrote:
> treid
> tisact.txt
> snip
>
> Can you ssh from the command line to the other box? Something like
>
> ssh user@host
>
> without typing a password? If so then something is wrong with the
> library or your environment.
>
> If you are using encrypted keys you should have a copy of ssh-agent
> running that will given the ssh connection the unencrypted key, but
> ssh doesn't know the pid of ssh-agent and must be told what it is with
> an environmental variable. If the Perl code is running in an
> environment that does not have this variable set it will fail.
>
> Another common problem is that different versions of Unix (and Linux)
> use different implementations of ssh. This isn't a problem for most
> things, but they tend to use different formats for the private and
> public key files. You may have to convert the key generated on one
> platform to the format expected by another.
>
| |
| Chas Owens 2007-08-16, 7:01 pm |
| On 8/16/07, kilaru rajeev <kilarurajeev@gmail.com> wrote:
snip
snip[color=darkred]
> I had generated the Key pair. I installed the public key on the server. And,
> while generating the keys I had not passed any passphrase. That is why, it
> is not asking for the password/passphrase while connecting. I guess we need
> to provide the configuration details in our program while connecting to the
> server.
snip
If you did not provide a passphrase then the key is unencrypted.
Depending on what you want to do, this is a good thing. It is common
for program accounts (as opposed to user accounts) to have unencrypted
keys since it removes the complications of have to use ssh-agent.
However, your response did not answer the primary question: can you
connect to the other box from the command line without typing a
password?
If you can and Perl is having a problem doing the same then there is
something wrong with the installation of Net::SCP, if you can't then
the problem is most likely incompatible key types (since you have
ruled out encrypted keys as a problem).
| |
| Kilaru Rajeev 2007-08-24, 7:59 am |
| Hi Chas,
I was not given the proper arguments to the *new* function. That is why, it
was failed to connect. This time I have another trouble. As part of my code,
I have used the below to statments to list the files in the directory.
my @ls = $sftp->ls("$srcDir/");
print "\n----------------->@ls\n";
But I am not getting the output eventhough the directory got some files
except "------------------->" part. sometimes I am getting the output as
below:
---------------------> HASH(0xd03334) HASH(0xd033dc) HASH(0xd03498)
HASH(0xd03540) HASH(0xd035e8) HASH(0xd03690) HASH(0xd03738) HASH(0xd037e0)
HASH(0xd044a4) HASH(0xd0454c) HASH(0xd045f4) HASH(0xd0469c) HASH(0xd04744)
HASH(0xd047ec) HASH(0xd05da0) HASH(0xd05dac) HASH(0xd05e24) HASH(0xd05e9c)
HASH(0xd05f50) HASH(0xd0601c) HASH(0xd060c4) HASH(0xd0616c) HASH(0xd06214)
HASH(0xd062bc) HASH(0xd06364) HASH(0xcdbc20) HASH(0xcdbcc8) HASH(0xcdbd70)
HASH(0xcdbe18) HASH(0xcdbec0) HASH(0xcdbf68)
I am not sure about the return value of the $sftp->ls(). I thought it will
return a list as in Net::FTP. How I should use it? Please help me.
Thanks,
Rajeev Kilaru
On 8/16/07, Chas Owens <chas.owens@gmail.com> wrote:
>
> On 8/16/07, kilaru rajeev <kilarurajeev@gmail.com> wrote:
> snip
> snip
> And,
> it
> need
> the
> snip
>
> If you did not provide a passphrase then the key is unencrypted.
> Depending on what you want to do, this is a good thing. It is common
> for program accounts (as opposed to user accounts) to have unencrypted
> keys since it removes the complications of have to use ssh-agent.
> However, your response did not answer the primary question: can you
> connect to the other box from the command line without typing a
> password?
>
> If you can and Perl is having a problem doing the same then there is
> something wrong with the installation of Net::SCP, if you can't then
> the problem is most likely incompatible key types (since you have
> ruled out encrypted keys as a problem).
>
| |
| Chas Owens 2007-08-24, 7:01 pm |
| On 8/24/07, kilaru rajeev <kilarurajeev@gmail.com> wrote:
> Hi Chas,
>
> I was not given the proper arguments to the *new* function. That is why, it
> was failed to connect. This time I have another trouble. As part of my code,
> I have used the below to statments to list the files in the directory.
>
> my @ls = $sftp->ls("$srcDir/");
> print "\n----------------->@ls\n";
>
> But I am not getting the output eventhough the directory got some files
> except "------------------->" part. sometimes I am getting the output as
> below:
>
> ---------------------> HASH(0xd03334) HASH(0xd033dc) HASH(0xd03498)
> HASH(0xd03540) HASH(0xd035e8) HASH(0xd03690) HASH(0xd03738) HASH(0xd037e0)
> HASH(0xd044a4) HASH(0xd0454c) HASH(0xd045f4) HASH(0xd0469c) HASH(0xd04744)
> HASH(0xd047ec) HASH(0xd05da0) HASH(0xd05dac) HASH(0xd05e24) HASH(0xd05e9c)
> HASH(0xd05f50) HASH(0xd0601c) HASH(0xd060c4) HASH(0xd0616c) HASH(0xd06214)
> HASH(0xd062bc) HASH(0xd06364) HASH(0xcdbc20) HASH(0xcdbcc8) HASH(0xcdbd70)
> HASH(0xcdbe18) HASH(0xcdbec0) HASH(0xcdbf68)
>
> I am not sure about the return value of the $sftp->ls(). I thought it will
> return a list as in Net::FTP. How I should use it? Please help me.
from the docs:
$sftp->ls($remote [, $subref ])
Fetches a directory listing of $remote.
If $subref is specified, for each entry in the directory, $subref will
be called and given a reference to a hash with three keys: filename,
the name of the entry in the directory listing; longname, an entry in
a "long" listing like ls -l; and a, a Net::SFTP::Attributes object,
which contains the file attributes of the entry (atime, mtime,
permissions, etc.).
If $subref is not specified, returns a list of directory entries, each
of which is a reference to a hash as described in the previous paragraph.
So if you only want the filenames you can say
my @ls = map { $_->{filename} } $sftp->ls($srcDir);
| |
| Kilaru Rajeev 2007-08-24, 7:01 pm |
| Hi Chas,
It is perfect. Thanks a lot.
Regards,
Rajeev Kilaru
On 8/24/07, Chas Owens <chas.owens@gmail.com> wrote:
>
> On 8/24/07, kilaru rajeev <kilarurajeev@gmail.com> wrote:
> why, it
> code,
> HASH(0xd037e0)
> HASH(0xd04744)
> HASH(0xd05e9c)
> HASH(0xd06214)
> HASH(0xcdbd70)
> will
>
> from the docs:
> $sftp->ls($remote [, $subref ])
>
> Fetches a directory listing of $remote.
>
> If $subref is specified, for each entry in the directory, $subref will
> be called and given a reference to a hash with three keys: filename,
> the name of the entry in the directory listing; longname, an entry in
> a "long" listing like ls -l; and a, a Net::SFTP::Attributes object,
> which contains the file attributes of the entry (atime, mtime,
> permissions, etc.).
>
> If $subref is not specified, returns a list of directory entries, each
> of which is a reference to a hash as described in the previous
> paragraph.
>
> So if you only want the filenames you can say
>
> my @ls = map { $_->{filename} } $sftp->ls($srcDir);
>
| |
| Chas Owens 2007-08-27, 7:23 pm |
| On 8/27/07, kilaru rajeev <kilarurajeev@gmail.com> wrote:
snip
$sftp->get("/trading/tisissuer08260004.txt",".");
snip
> Couldn't stat remote file: No such file or directory at sample.pl line 32
> ERROR with get: No such file or directory
snip
> I am not getting what it meant. Could you please helpme?
snip
The file /trading/tisissuer08260004.txt does not exist on sacsun120.
Possible reasons include, but are not limited to:
* the file does not exist
* you misspelled the file name
* the file is really trading/tisissuer08260004.txt (a relative path vs absolute)
* you are connecting to the wrong host
|
|
|
|
|