Hi Salva,
I can't thank you enough for your help.
Thanks for the further explanation, and code sample for testing
I got "I am running two SFTP sessions in parallel" in the output from the code. So it looks like the server is allowing ONE SSH connection, but multiple SFTP sessions to be created.
Therefore, how would l keep the SSH connection alive - what command could run? Would keeping the sftp sessions alive suffice, or periodically open a new SFTP Connection? I am about to test for the latter now.
On a separate note, l have always used use Net::SFTP::Foreign directly, and know how to set Options like:
use Net::SFTP::Foreign
my @sftp_opts = ();
push @ssh_opt, "-o";
push @ssh_opts, "KexDHMin=1024";
push @sftp_opts, "-o";
push @sftp_opts, "KexAlgorithms=diffie-hellman-group14-sha1";
. . .
$sftp = Net::SFTP::Foreign->new(
$config{'hostname'},
user => $config{'username'},
port => $config{'port'},
stderr_discard => 1,
autodie => 0,
key_path => $config{'key'},
more => [ @sftp_options ]
);
However, l cannot figure out how to set these for Net::OpenSSH; - l tried the following to no avail
my @ssh_opts = ();
push @ssh_opts, "-o";
push @ssh_opts, "KexAlgorithms=diffie-hellman-group14-sha1";
push @ssh_opt, "-o";
push @ssh_opts, "KexDHMin=1024";
my $ssh = Net::OpenSSH->new($config{'host'}, user => $config{'user'},
+port => $config{'port'}, key_path => $config{'key_path'}, default_ssh
+_opts => [ @ssh_opts ]);
# Returns DH parameter offered by the server (1024 bits) is considered
+ insecure. You can lower the accepted minimum via the KexDHMin option
+.
#DH_GEX group out of range: 2048 !< 1024 !< 8192
my $ssh = Net::OpenSSH->new($config{'host'}, user => $config{'user'},
+port => $config{'port'}, key_path => $config{'key_path'}, ssh_opts =>
+ [ @ssh_opts ]);
# Returns Invalid or bad combination of options ('ssh_opts')
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.