## scp.pl ## use strict; use warnings; use Net::SSH2; die "Usage: perl scp.pl host username password" unless @ARGV == 3; my $host = $ARGV[0]; my $user = $ARGV[1]; my $password = $ARGV[2]; my $ssh2 = Net::SSH2->new(); $ssh2->debug(1); print "\nconnecting to $host...\n"; $ssh2->connect($host) or die $ssh2->error; print "\nauth to $host...\n"; $ssh2->auth_password($user,$password) or die $ssh2->error; printf "Auth OK: %s\n", $ssh2->auth_ok; print "scp put\n"; my $ret = $ssh2->scp_put("rub'bish.txt", "rub'bish.txt"); print "ret: $ret\n"; $ssh2->disconnect(); ### print("...\n\n"); $ssh2=undef; $ssh2=Net::SSH2->new(); $ssh2->debug(1); $ssh2->connect($host) or die $ssh2->error; $ssh2->auth_password($user,$password) or die $ssh2->error; $ssh2->scp_get("rub'bish.txt", "more-rub'bish.txt"); printf("SSH Error (%s): '%s' - '%s'\n",$ssh2->error); $ssh2->disconnect(); print("...\n\n"); $ssh2=undef; $ssh2=Net::SSH2->new(); $ssh2->debug(1); $ssh2->connect($host) or die $ssh2->error; $ssh2->auth_password($user,$password) or die $ssh2->error; $ret=$ssh2->scp_get("06 School's Out.mp3", "06 School's Out.mp3"); printf("SSH Error (%s): '%s' - '%s'\n",$ssh2->error); $ssh2->disconnect();