0
jsch.setKnownHosts(new FileInputStream(SSHHostKey));
jsch.addIdentity(SSHKey);
session = jsch.getSession(user, host, port);
if (hostKey == null)
{
    session.setConfig("StrictHostKeyChecking", "no");
}
session.setPassword(pass);
session.connect();
channel = session.openChannel("sftp");
channel.connect();
sftp = (ChannelSftp) channel;

still I get the same exception. Can anybody tell me how to get/retrive HostKey? I am using Windows.

Domysee
  • 12,718
  • 10
  • 53
  • 84
Shilpa
  • 9
  • 2
  • We do not know if your `hostKey` is null or not. If it is not null, your question is a duplicate to http://stackoverflow.com/q/2003419/850848 If it is null, make sure you understand that you lose security by setting `StrictHostKeyChecking` to `no`. – Martin Prikryl Nov 02 '15 at 14:58
  • I want to use StrictHostKeyChecking", "Yes". I have created HostKey manually looks like it gives me exception. – Shilpa Nov 03 '15 at 09:54
  • How did you *"created HostKey manually"*? What's your question actually? Are you looking for a correct format of the `hostKey`? Or for a way to pass it to JSch? What's wrong with the answers available at http://stackoverflow.com/q/2003419/850848 – Martin Prikryl Nov 03 '15 at 10:00
  • I have created HostKey manually looks like "SeverName ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAmyK7A4O/1XKsCyRpZDV7y+eW9yU9aZc2baSv" . I am checking Hostkey for null because If I want to make connection without key [with userName & Password ]. My problem is where I will get HostKey. – Shilpa Nov 03 '15 at 10:02
  • Do you mean where should you **put** the host key? – Martin Prikryl Nov 03 '15 at 10:05
  • Correct format of Host Key or from where I can Get directly hostKey. Currently I am having Private & Public keys with me. – Shilpa Nov 03 '15 at 10:05
  • How to generate HostKey? – Shilpa Nov 03 '15 at 13:28

0 Answers0