#!/usr/bin/perl -w use strict; use Net::SSH2 qw(LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE LIBSSH2_CHANNEL_FLUSH_ALL LIBSSH2_HOSTKEY_POLICY_ASK); use 5.010; use lib "template_stuff"; use config2; # none of this makes any sense until you run # ssh-keygen -t rsa my $sub_hash = "my_sftp"; my $domain = $config{$sub_hash}->{'domain'}; my $username = $config{$sub_hash}->{'username'}; say "values are $domain"; my $pass = "ringo"; my $ssh2 = Net::SSH2->new( debug => 1 ); $ssh2->trace(-1); $ssh2->timeout(5000); $ssh2->connect($domain) or $ssh2->die_with_error; $ssh2->check_hostkey(LIBSSH2_HOSTKEY_POLICY_ASK); $ssh2->auth_publickey($username, '/home/bob/.ssh/id_rsa.pub', '/home/bob/.ssh/id_rsa', $pass ); my $success = $ssh2->mkdir("perlmonks"); say "success is $success"; return 0; __END__