Class DefaultKnownHostsServerKeyVerifier
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.util.io.ModifiableFileWatcher
-
- org.apache.sshd.client.keyverifier.KnownHostsServerKeyVerifier
-
- org.apache.sshd.client.keyverifier.DefaultKnownHostsServerKeyVerifier
-
- All Implemented Interfaces:
ModifiedServerKeyAcceptor,ServerKeyVerifier
public class DefaultKnownHostsServerKeyVerifier extends KnownHostsServerKeyVerifier
Monitors the~/.ssh/known_hostsfile of the user currently running the client, updating and re-loading it if necessary. It also (optionally) enforces the same permissions regime asOpenSSH.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.sshd.client.keyverifier.KnownHostsServerKeyVerifier
KnownHostsServerKeyVerifier.HostEntryPair
-
-
Field Summary
Fields Modifier and Type Field Description private booleanstrict-
Fields inherited from class org.apache.sshd.client.keyverifier.KnownHostsServerKeyVerifier
KNOWN_HOSTS_FILE_OPTION, STRICT_CHECKING_OPTION, updateLock
-
Fields inherited from class org.apache.sshd.common.util.io.ModifiableFileWatcher
options, STRICTLY_PROHIBITED_FILE_PERMISSION
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate)DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate, boolean strict)DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate, boolean strict, java.io.File file)DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate, boolean strict, java.nio.file.Path file, java.nio.file.LinkOption... options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisStrict()protected java.util.List<KnownHostsServerKeyVerifier.HostEntryPair>reloadKnownHosts(ClientSession session, java.nio.file.Path file)-
Methods inherited from class org.apache.sshd.client.keyverifier.KnownHostsServerKeyVerifier
acceptIncompleteHostKeys, acceptKnownHostEntries, acceptModifiedServerKey, acceptUnknownHostKey, findKnownHostEntries, getDelegateVerifier, getFallbackPublicKeyEntryResolver, getHostValueDigester, getKnownHostSupplier, getModifiedServerKeyAcceptor, handleKnownHostsFileUpdateFailure, handleModifiedServerKeyUpdateFailure, handleRevokedKey, prepareKnownHostEntry, prepareModifiedServerKeyLine, resolveHostKey, resolveHostNetworkIdentities, setLoadedHostsEntries, setModifiedServerKeyAcceptor, updateKnownHostsFile, updateModifiedServerKey, updateModifiedServerKey, verifyServerKey
-
Methods inherited from class org.apache.sshd.common.util.io.ModifiableFileWatcher
checkReloadRequired, exists, getPath, lastModified, resetReloadAttributes, size, toPathResource, toPathResource, toString, updateReloadAttributes, validateStrictConfigFilePermissions
-
-
-
-
Constructor Detail
-
DefaultKnownHostsServerKeyVerifier
public DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate)
-
DefaultKnownHostsServerKeyVerifier
public DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate, boolean strict)
-
DefaultKnownHostsServerKeyVerifier
public DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate, boolean strict, java.io.File file)
-
DefaultKnownHostsServerKeyVerifier
public DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate, boolean strict, java.nio.file.Path file, java.nio.file.LinkOption... options)
-
-
Method Detail
-
isStrict
public final boolean isStrict()
- Returns:
- If
truethen makes sure that the containing folder has 0700 access and the file 0644. Note: for Windows it does not check these permissions - See Also:
ModifiableFileWatcher.validateStrictConfigFilePermissions(Path, LinkOption...)
-
reloadKnownHosts
protected java.util.List<KnownHostsServerKeyVerifier.HostEntryPair> reloadKnownHosts(ClientSession session, java.nio.file.Path file) throws java.io.IOException, java.security.GeneralSecurityException
- Overrides:
reloadKnownHostsin classKnownHostsServerKeyVerifier- Parameters:
session- TheClientSessionthat triggered this requestfile- ThePathto reload from- Returns:
- A
Listof the loadedKnownHostsServerKeyVerifier.HostEntryPairs - may benull/empty - Throws:
java.io.IOException- If failed to parse the filejava.security.GeneralSecurityException- If failed to resolve the encoded public keys
-
-