0

currently working on java code that needs to fetch data from an sftp server and send it to our local machine. We've tried various approaches (using different java packages) to connect the sftp server, but we're facing some problems with accessibility. so kindly help me to fix overcome this issue.

Used inputs:

JSch version: Jsch 0.1.55 Java version: Amazon Corretto 8.282.08.1 Error message: Exception:com.jcraft.jsch.JSchException: Algorithm negotiation fail

sample code:

try{
        Channel channel=null;
        ChannelSftp channelSftp=null;
        String username= "<sftp username>";
        String password= "<sftp password>";
        Properties config= new Properties();
        config.put("StrictHostkeyChecking","no");
        String host ="<sftp hostname>";
        JSch jsch= new JSch();
        Session session= jsch.getSession(username,host);
        session.setPassword(password);
        session.setConfig(config);
        session.connect();
        channel = session.openChannel("sftp");
        channel.connect();
        channelSftp = (ChannelSftp) channel;
        //ChannelSftp chennalsftp =  (ChannelSftp) session.openChannel("sftp");
        System.out.println("sesstion Connected:" +session.isConnected());

    }catch(Exception e){
    System.out.println("Exception:"+e);
    }

0 Answers0