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