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 ] ); #### 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')