Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Help required for SFTP code in Perl..urgent !!!

by Hitarth1987 (Initiate)
on May 24, 2011 at 03:37 UTC ( [id://906406]=perlquestion: print w/replies, xml ) Need Help??

Hitarth1987 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I am supposed to write a perl code that uses SFTP to transfer one file from my server to another server. The arguments are supposed to be read from a separate configuration file. The name of the config file is interface.cfg, and the name of the main perl file is interface.pl ---------- Configuration file format:

# Ftp to machine - interface hash_ref_Ftp_address= <server address> hash_ref_Ftp_user= <user_id> hash_ref_Ftp_passwd= <password>
...

(Currently I am using FTP...) Now I want to make this into an SFTP with RSA key(s) included. How should I add the argument? ---------- Perl file format: I am currently taking parameters like these-

{$ FTP_address}->{FTP_user}=<value>

Similarly I need to take keys as parameters from the configuration file. ---------- Execution: How would I create an SFTP connection and how would I log in? and How would I take keys as arguments? This are the commands I need to execute:

my $sftp = Net::SFTP->new($v_sftp_address, Debug => 1,..) $sftp->login($v_sftp_user, $v_sftp_passwd,..)

Do I only need to install Net::SFTP module for all this? I am a complete newbie so please help urgently !!!

Replies are listed 'Best First'.
Re: Help required for SFTP code in Perl..urgent !!!
by ww (Archbishop) on May 24, 2011 at 04:28 UTC
    Why "urgently?"

    Is your homework due in the morning? Is your probationary period about to end?

    Your problem statement also involves multiple questions with little evidence you're expended any effort on any one of them.

    So, do a little work toward on your own. See what CPAN might offer; for example, read the documentation for Net::SFTP. Search CPAN for "RSA."

    Oh yes, re-read your own post: What you wrote makes this challenge sound like homework -- which we'll help with but NOT do for you
          ...but in such a case, we prefer immediate disclosure by the Seeker.

Re: Help required for SFTP code in Perl..urgent !!!
by John M. Dlugosz (Monsignor) on May 24, 2011 at 04:29 UTC
    The documentation for Net::SFTP shows how to pass arguments, including ssh_args: see this link.

    I think you refer to the key by name or filename, not give the key itself. So whatever you need to pass as ssh_args, you can add to your configuration file.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://906406]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2026-03-08 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.