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