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 class
static class
class
Each line in these files contains the following fields: markers (optional), hostnames, bits, exponent, modulus, comment.static class
static interface
static 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 String
adjustHostname
(String hostname, int port) static File
entries()
findExistingAlgorithms
(String hostname, int port) It is necessary to connect with the type of algorithm that matches an existing know_host entry.getFile()
protected boolean
hostKeyChangedAction
(String hostname, PublicKey key) protected boolean
hostKeyUnverifiableAction
(String hostname, PublicKey key) private void
toString()
boolean
This callback is invoked when the server's host key needs to be verified.void
write()
void
Append 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:HostKeyVerifier
This 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:
verify
in interfaceHostKeyVerifier
- Parameters:
hostname
- remote hostnameport
- remote portkey
- host key of server- Returns:
true
if key is acceptable,false
otherwise
-
findExistingAlgorithms
Description copied from interface:HostKeyVerifier
It 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:
findExistingAlgorithms
in 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
-