http://qs1969.pair.com?node_id=11123690


in reply to Re^3: REST API with SFTP Pooling
in thread REST API with SFTP Pooling

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')