# OpenSSHKnownHosts (sshj 0.4.0 API)
Date: 2011-06-06

## 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

Nested Class Summary
`static class` `OpenSSHKnownHosts.Entry`
`static class` `OpenSSHKnownHosts.HashedEntry`
`static class` `OpenSSHKnownHosts.SimpleEntry`

Field Summary
`protected List<OpenSSHKnownHosts.Entry>` `entries`
`protected File` `khFile`
`protected org.slf4j.Logger` `log`

Constructor Summary
`OpenSSHKnownHosts(File khFile)`

Method Summary
`static File` `detectSSHDir()`
`List<OpenSSHKnownHosts.Entry>` `entries()`
`File` `getFile()`
`protected boolean` `hostKeyChangedAction(OpenSSHKnownHosts.Entry entry, String hostname, PublicKey key)`
`protected boolean` `hostKeyUnverifiableAction(String hostname, PublicKey key)`
`static boolean` `isHashed(String line)`
`boolean` `verify(String hostname, int port, PublicKey key)` This callback is invoked when the server's host key needs to be verified.
`void` `write()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    protected final org.slf4j.Logger log

### khFile

    protected final File khFile

### entries

    protected final List<OpenSSHKnownHosts.Entry> entries

Constructor Detail

### OpenSSHKnownHosts

    public OpenSSHKnownHosts(File khFile)
                      throws IOException

Throws:
  `IOException`

Method Detail

### 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 hostname
    `port` - remote port
    `key` - 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.Entry entry,
                                           String hostname,
                                           PublicKey key)

### entries

    public List<OpenSSHKnownHosts.Entry> entries()

### write

    public void write()
               throws IOException

  Throws:
    `IOException`

### detectSSHDir

    public static File detectSSHDir()

### isHashed

    public static boolean isHashed(String line)

Copyright © 2009-2011. All Rights Reserved.