Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

SCP help

by PyrexKidd (Monk)
on May 03, 2010 at 03:38 UTC ( #838026=perlquestion: print w/ replies, xml ) Need Help??
PyrexKidd has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to copy a file securely to my server. using the following line

system('scp -P 223 /home/my/local/file/whatever.txt root:root_password +\@foo.bar.com:/my/remote/path_name');
when I run it I get the following error:
ssh: Could not resolve hostname root: Name or service not known

what is going on?

Comment on SCP help
Select or Download Code
Re: SCP help
by ikegami (Pope) on May 03, 2010 at 05:08 UTC
    You would have gotten the same result from the prompt. Your problem has nothing to do with Perl.
    root:root_password@foo.bar.com:/my/remote/path_name
    means file root_password@foo.bar.com:/my/remote/path_name on machine root. The path should be
    root@foo.bar.com:/my/remote/path_name
    You could feed the password to its STDIN (probably), but it would be better if you used public key authentication (so you don't need to specify a password at all).
      You could feed the password to its STDIN (probably)
      Not really, ssh opens /dev/tty and reads the password from there.
Re: SCP help
by nagalenoj (Friar) on May 03, 2010 at 05:59 UTC

    If it's not an interactive kind of script, you could try copying the public key to the authorized keys file. ssh without password linux

    But, here the problem is in your syntax.

Re: SCP help
by codeacrobat (Chaplain) on May 03, 2010 at 06:23 UTC
    Hello, there are perl modules for this kind of job, e.g. Net::SFTP::Foreign, Net::SSH2. Maybe these modules help you to integrate ssh better into your perl scripts.

    print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
      ... and Net::OpenSSH that being on an Unix OS, maybe Linux, it's probably the easiest one to install and use for SCP file copy.
      use Net::OpenSSH; my $ssh = Net::OpenSSH->new('root@foo.bar.com', passwd => $passwd, port => 223); $ssh->scp_put("/home/my/local/file/whatever.txt", "/my/remote/path_name");

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-08-21 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (134 votes), past polls