public class KnownHostsFile extends KnownHostsKeyVerification
KnownHostsKeyVerification.BlankEntry, KnownHostsKeyVerification.CertAuthorityEntry, KnownHostsKeyVerification.CommentEntry, KnownHostsKeyVerification.HostFileEntry, KnownHostsKeyVerification.InvalidEntry, KnownHostsKeyVerification.KeyEntry, KnownHostsKeyVerification.RevokedEntry, KnownHostsKeyVerification.Ssh2KeyEntry| Constructor and Description |
|---|
KnownHostsFile() |
KnownHostsFile(File file) |
| Modifier and Type | Method and Description |
|---|---|
File |
getKnownHostsFile() |
boolean |
isHostFileWriteable() |
protected void |
onHostKeyAdded(Set<String> names,
SshPublicKey key) |
protected void |
onHostKeyMismatch(String host,
List<SshPublicKey> allowedHostKey,
SshPublicKey actualHostKey)
Called by the
verifyHost method when the host key supplied
by the host does not match the current key recording in the known hosts
file. |
protected void |
onHostKeyRemoved(Set<String> names,
SshPublicKey key) |
protected void |
onHostKeyUpdated(Set<String> names,
SshPublicKey key) |
protected void |
onInvalidHostEntry(String entry) |
protected void |
onRevokedKey(String host,
SshPublicKey key)
Called by the
verifyHost method when the host key supplied
is listed as a revoked key. |
protected void |
onUnknownHost(String host,
SshPublicKey key)
Called by the
verifyHost method when the host key supplied
is not recorded in the known_hosts file. |
protected void |
save() |
void |
store() |
addEntry, addListener, allowHost, clear, encodeHost, encodeHost, getAlgorithmsForHost, getKeyEntries, isKnownHost, load, removeEntries, removeEntries, removeEntries, removeEntries, removeEntry, resolveNames, setComment, setHashHosts, setUseCanonicalHostnames, setUseReverseDNS, toString, updateHostKey, useCanonicalHostname, useHashHosts, useReverseDNS, verifyHostpublic KnownHostsFile(File file) throws SshException
SshExceptionpublic KnownHostsFile()
throws SshException
SshExceptionpublic void store()
throws IOException
IOExceptionpublic File getKnownHostsFile()
public boolean isHostFileWriteable()
isHostFileWriteable in class KnownHostsKeyVerificationprotected void onInvalidHostEntry(String entry) throws SshException
onInvalidHostEntry in class KnownHostsKeyVerificationSshExceptionprotected void onHostKeyMismatch(String host, List<SshPublicKey> allowedHostKey, SshPublicKey actualHostKey) throws SshException
KnownHostsKeyVerification
Called by the verifyHost method when the host key supplied
by the host does not match the current key recording in the known hosts
file.
onHostKeyMismatch in class KnownHostsKeyVerificationhost - the name of the hostallowedHostKey - the current key recorded in the known_hosts file.actualHostKey - the actual key supplied by the userSshException - if an error occursprotected void onUnknownHost(String host, SshPublicKey key) throws SshException
KnownHostsKeyVerification
Called by the verifyHost method when the host key supplied
is not recorded in the known_hosts file.
onUnknownHost in class KnownHostsKeyVerificationhost - the name of the hostkey - the public key supplied by the hostSshException - if an error occursprotected void onRevokedKey(String host, SshPublicKey key)
KnownHostsKeyVerificationverifyHost method when the host key supplied
is listed as a revoked key. This is informational, any changes made to
the current entries will still result in a failed host verification.onRevokedKey in class KnownHostsKeyVerificationprotected void onHostKeyUpdated(Set<String> names, SshPublicKey key)
onHostKeyUpdated in class KnownHostsKeyVerificationprotected void onHostKeyAdded(Set<String> names, SshPublicKey key)
onHostKeyAdded in class KnownHostsKeyVerificationprotected void onHostKeyRemoved(Set<String> names, SshPublicKey key)
onHostKeyRemoved in class KnownHostsKeyVerificationprotected void save()
Copyright © 2025. All rights reserved.