Hi

I am trying to connect to a server, to transfer a file.

I have added remote to the known host file of source server and generated public key.
From terminal i am able to login to remote server without password, but here through java , i am getting below error :-reject HostKey: remote server ip.

I need to run code with config.put("StrictHostKeyChecking", "yes");
With no it is not working fine. Any help will be appriciated.

       `Inline Code Example Here`
        JSch jsch = new JSch();

        jsch.setKnownHosts("known_hosts.txt");

        session = jsch.getSession(sftpUser, sftpHost, sftpPort);

        Hashtable<String, String> config = new Hashtable<String, String>();

        config.put("StrictHostKeyChecking", "yes");

        session.setConfig(config);

        session.connect();

hi
The Jsch with StrictKey Checking true worked, when i gave path to the public key generated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.