Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.5k views
in Java FTP by (1.3k points)
Suppose I have following entry in my known_host file
localhost ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAxZAAJ+Lqtq9Bz6tYX88xAk712moZaE+65LRTTc8jOy/y8c6zmiSaaI5Ip+/k+OjCCA1bgF+yrsmpAdMnzso+bA6BlFmw8SNx8t9+N3boB0xbV8o5kXcdimH0O41n2YjAOvcsFYm8LTIHXGW4dtCx69boTaU2YXtkuKfAE6xUOdk=


Using SSHFTPClient.getValidator().loadKnownHosts("known_host") will load this entry into the known host





...
Hashtable knownHost = sshFTPClient.getValidator().getKnownHosts();
Set<String> set = knownHost.keySet();
Iterator<String> itr = set.iterator();
while (itr.hasNext()) {
     String alg = itr.next();
     String fingerprint = (String) knownHost.get(alg);
     System.out.println(alg + " " + fingerprint);
}

will give me
ssh-rsa 1024: a0 8e 76 b7 c7 14 2e cd 88 d3 ec 45 d7 55 d8 41

Is it possible to get back the fingerprint in original format?, such as:
AAAAB3NzaC1yc2EAAAABIwAAAIEAxZAAJ+Lqtq9Bz6tYX88xAk712moZaE+65LRTTc8jOy/y8c6zmiSaaI5Ip+/k+OjCCA1bgF+yrsmpAdMnzso+bA6BlFmw8SNx8t9+N3boB0xbV8o5kXcdimH0O41n2YjAOvcsFYm8LTIHXGW4dtCx69boTaU2YXtkuKfAE6xUOdk=

2 Answers

0 votes
by (162k points)
No, it isn't possible. And looking back at this method getKnownHosts() I really wonder what use it is and why we wrote it.

The good news is, I've added 2 new methods.

public String[] getKnownHostnames() // to get a list of the host names in known_hosts

public SSHFTPPublicKey[] getKnownHostKeys(String hostname) // to get the public keys stored for this hostname

It'll be released as part of 3.0.1 later today - email us if you want to try it out now (support at enterprisedt dot com).
0 votes
by (162k points)
Now released in 3.0.1

Categories

...