net.schmizz.sshj.transport.verification
Class OpenSSHKnownHosts
java.lang.Object
net.schmizz.sshj.transport.verification.OpenSSHKnownHosts
- All Implemented Interfaces:
- HostKeyVerifier
- Direct Known Subclasses:
- ConsoleKnownHostsVerifier
public class OpenSSHKnownHosts
- extends Object
- implements HostKeyVerifier
A HostKeyVerifier
implementation for a known_hosts
file i.e. in the format used by OpenSSH.
- See Also:
- Hashed hostnames spec
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected final org.slf4j.Logger log
khFile
protected final File khFile
entries
protected final List<OpenSSHKnownHosts.HostEntry> entries
OpenSSHKnownHosts
public OpenSSHKnownHosts(File khFile)
throws IOException
- Throws:
IOException
getFile
public File getFile()
verify
public boolean verify(String hostname,
int port,
PublicKey key)
- 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 interface HostKeyVerifier
- Parameters:
hostname
- remote hostnameport
- remote portkey
- host key of server
- Returns:
true
if key is acceptable, false
otherwise
hostKeyUnverifiableAction
protected boolean hostKeyUnverifiableAction(String hostname,
PublicKey key)
hostKeyChangedAction
protected boolean hostKeyChangedAction(OpenSSHKnownHosts.HostEntry entry,
String hostname,
PublicKey key)
entries
public List<OpenSSHKnownHosts.HostEntry> entries()
write
public void write()
throws IOException
- Throws:
IOException
detectSSHDir
public static File detectSSHDir()
Copyright © 2009-2012. All Rights Reserved.