I am trying to send a file from a Windows machine to a Linux machine using JSch. Because of that I copied the host public key from the Linux machine to my Windows machine and added the key to my HostKeyRepository
. But for some reason I get "invalid key type" exception. Here is my code:
HostKeyRepository repo = jsch.getHostKeyRepository();
File file = new File("D:\\Uni\\Arbeit\\ssh_host_rsa_key.pub");
byte[] HK = Files.readAllBytes(file.toPath());
Session session=jsch.getSession(user, host, 22);
session.setPassword(password);
HostKey hk = new HostKey(null, HK);
repo.add(hk, null);
session.connect();