1

I am trying to connect to a remote server using the SshClient of java library Apache MINA SSHD.

I want to pass my known_hosts file also to the SshClient so that the hosts are also verified before connecting to the server. I need to use the class KnownHostsServerKeyVerifier to pass the known hosts the the client like below

ServerKeyVerifier hostsServerKeyVerifier = new KnownHostsServerKeyVerifier(null, Paths.get("<path_to_known_hosts>/known_hosts"));
client.setServerKeyVerifier(hostsServerKeyVerifier);

The contructor of KnownHostsServerKeyVerifier need below arguments

public KnownHostsServerKeyVerifier(ServerKeyVerifier delegate, Path file)

But I don't understand what and how to pass for the argument ServerKeyVerifier

Can someone explain me how to make this work or is there some other approach to pass the known_hosts file to the SshClient ?

0 Answers0