File: example.pl

package info (click to toggle)
libnet-ssh2-perl 0.74-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 740 kB
  • sloc: perl: 2,762; pascal: 739; makefile: 10
file content (20 lines) | stat: -rw-r--r-- 413 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl -w

use Net::SSH2;

my $ssh2 = Net::SSH2->new();

# hostname of the server you are connecting to
$ssh2->connect('asdf') or die;

# username and password
$ssh2->auth_password('guest', 'guest') or die;

# run a program
my $chan = $ssh2->channel();
$chan->exec('touch test');

# print the contents of a file
my $sftp = $ssh2->sftp();
my $fh = $sftp->open('/etc/passwd') or die;
print $_ while <$fh>;