Class OpenSSHKnownHosts
java.lang.Object
net.schmizz.sshj.transport.verification.OpenSSHKnownHosts
- All Implemented Interfaces:
HostKeyVerifier
- Direct Known Subclasses:
ConsoleKnownHostsVerifier
A
HostKeyVerifier implementation for a known_hosts file i.e. in the format used by OpenSSH.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classclassEach line in these files contains the following fields: markers (optional), hostnames, bits, exponent, modulus, comment.static classstatic interfacestatic enum -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOpenSSHKnownHosts(File khFile) OpenSSHKnownHosts(File khFile, LoggerFactory loggerFactory) OpenSSHKnownHosts(Reader reader) OpenSSHKnownHosts(Reader reader, LoggerFactory loggerFactory) -
Method Summary
Modifier and TypeMethodDescriptionprivate StringadjustHostname(String hostname, int port) static Fileentries()findExistingAlgorithms(String hostname, int port) It is necessary to connect with the type of algorithm that matches an existing know_host entry.getFile()protected booleanhostKeyChangedAction(String hostname, PublicKey key) protected booleanhostKeyUnverifiableAction(String hostname, PublicKey key) private voidtoString()booleanThis callback is invoked when the server's host key needs to be verified.voidwrite()voidAppend a single entry
-
Field Details
-
log
protected final org.slf4j.Logger log -
khFile
-
entries
-
LS
-
-
Constructor Details
-
OpenSSHKnownHosts
- Throws:
IOException
-
OpenSSHKnownHosts
- Throws:
IOException
-
OpenSSHKnownHosts
- Throws:
IOException
-
OpenSSHKnownHosts
- Throws:
IOException
-
-
Method Details
-
readEntries
- Throws:
IOException
-
adjustHostname
-
getFile
-
verify
Description copied from interface:HostKeyVerifierThis callback is invoked when the server's host key needs to be verified. The return value indicates to the caller whether the SSH connection should proceed. Note: host key verification is the basis for security in SSH, therefore exercise due caution in implementing!- Specified by:
verifyin interfaceHostKeyVerifier- Parameters:
hostname- remote hostnameport- remote portkey- host key of server- Returns:
trueif key is acceptable,falseotherwise
-
findExistingAlgorithms
Description copied from interface:HostKeyVerifierIt is necessary to connect with the type of algorithm that matches an existing know_host entry. This will allow a match when we later verify with the negotiated keyHostKeyVerifier.verify- Specified by:
findExistingAlgorithmsin interfaceHostKeyVerifier- Parameters:
hostname- remote hostnameport- remote port- Returns:
- existing key types or empty list if no keys known for hostname
-
hostKeyUnverifiableAction
-
hostKeyChangedAction
-
entries
-
write
- Throws:
IOException
-
write
Append a single entry- Throws:
IOException
-
detectSSHDir
-
toString
-