StrictHostKeyChecking and
UserKnownHostsFile values from the ssh configuration.
The verifier can be given default known_hosts files in the constructor, which
will be used if the ssh config does not specify a UserKnownHostsFile.
If the ssh config does set UserKnownHostsFile, the verifier
uses the given files in the order given. Non-existing or unreadable files are
ignored.
StrictHostKeyChecking accepts the following values:
If StrictHostKeyChecking is not set, or set to any other value, the
default value ask is active.
This implementation relies on the ClientSession being a
JGitClientSession. By default Apache MINA sshd does not forward the
config file host entry to the session, so it would be unknown here which
entry it was and what setting of StrictHostKeyChecking should be
used. If used with some other session type, the implementation assumes
"ask".
Asking the user is done via a CredentialsProvider obtained from the
session. If none is set, the implementation falls back to strict host key
checking ("yes").
Note that adding a key to the known hosts file may create the file. You can specify in the constructor whether the user shall be asked about that, too. If the user declines updating the file, but the key was otherwise accepted (user confirmed for "ask", or "no" or "accept-new" are active), the key is accepted for this session only.
If several known hosts files are specified, a new key is always added to the first file (even if it doesn't exist yet; see the note about file creation above).
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final List | |
| private final Map | |
| private static final Logger | |
| private static final String | MARKER_CA
Marks CA keys used for SSH certificates. |
| private static final String | MARKER_REVOKED
Can be used to mark revoked known host lines. |
| private Random |
| Access | Constructor and Description |
|---|---|
| public | OpenSshServerKeyDatabase(boolean
whether to ask the user, if possible, about creating a new
non-existing known_hosts file askAboutNewFile, List<Path> typically ~/.ssh/known_hosts and ~/.ssh/known_hosts2. May be
empty or defaultFiles)null, in which case no default files are
installed. The files need not exist.Creates a new |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | accept(String
IP address the session tried to connect to connectAddress, InetSocketAddress IP address as reported for the remote end point remoteAddress, PublicKey received from the remote end serverKey, ServerKeyDatabase.giving access to potentially interesting configuration
settings config,for interacting with the user, if required; may be
provider)nullImplements org. Determines whether to accept a received server host key. |
| private void | addKeyToFile(OpenSshServerKeyDatabase.
|
| private List | |
| private String | createHostKeyLine(Collection<SshdSocketAddress> patterns, PublicKey key, ServerKeyDatabase.
|
| private boolean | find(Collection<SshdSocketAddress> candidates, PublicKey serverKey, List<KnownHostsServerKeyVerifier.
|
| private Collection | |
| private List | |
| private static boolean | |
| private static boolean | |
| private static boolean | |
| public List | lookup(String
IP address the session tried to connect to connectAddress, InetSocketAddress IP address as reported for the remote end point remoteAddress, ServerKeyDatabase.giving access to potentially interesting configuration
settings configImplements org. Retrieves all known and not revoked host keys for the given addresses. |
| private int | |
| private SshdSocketAddress | |
| private String | |
| private void | updateKnownHostsFile(Collection<SshdSocketAddress> candidates, PublicKey serverKey, Path path, ServerKeyDatabase.
|
| private void | updateModifiedServerKey(PublicKey serverKey, KnownHostsServerKeyVerifier.
|
| askAboutNewFile | back to summary |
|---|---|
| private final boolean askAboutNewFile | |
| defaultFiles | back to summary |
|---|---|
| private final List<OpenSshServerKeyDatabase. | |
| knownHostsFiles | back to summary |
|---|---|
| private final Map<Path, OpenSshServerKeyDatabase. | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| MARKER_CA | back to summary |
|---|---|
| private static final String MARKER_CA Marks CA keys used for SSH certificates. | |
| MARKER_REVOKED | back to summary |
|---|---|
| private static final String MARKER_REVOKED Can be used to mark revoked known host lines. | |
| prng | back to summary |
|---|---|
| private Random prng | |
| OpenSshServerKeyDatabase | back to summary |
|---|---|
| public OpenSshServerKeyDatabase(boolean askAboutNewFile, List<Path> defaultFiles) Creates a new | |
| accept | back to summary |
|---|---|
| public boolean accept(String connectAddress, InetSocketAddress remoteAddress, PublicKey serverKey, ServerKeyDatabase. Implements org. Doc from org. Determines whether to accept a received server host key.
| |
| addKeyToFile | back to summary |
|---|---|
| private void addKeyToFile(OpenSshServerKeyDatabase. | |
| addUserHostKeyFiles | back to summary |
|---|---|
| private List | |
| createHostKeyLine | back to summary |
|---|---|
| private String createHostKeyLine(Collection<SshdSocketAddress> patterns, PublicKey key, ServerKeyDatabase. | |
| find | back to summary |
|---|---|
| private boolean find(Collection<SshdSocketAddress> candidates, PublicKey serverKey, List<KnownHostsServerKeyVerifier. | |
| getCandidates | back to summary |
|---|---|
| private Collection | |
| getFilesToUse | back to summary |
|---|---|
| private List | |
| isBetterMatch | back to summary |
|---|---|
| private static boolean isBetterMatch(String keyType, String thisType, String modifiedType) | |
| isCertificateAuthority | back to summary |
|---|---|
| private static boolean isCertificateAuthority(KnownHostEntry entry) | |
| isRevoked | back to summary |
|---|---|
| private static boolean isRevoked(KnownHostEntry entry) | |
| lookup | back to summary |
|---|---|
| public List Implements org. Doc from org. Retrieves all known and not revoked host keys for the given addresses.
| |
| parsePort | back to summary |
|---|---|
| private int parsePort(String s) | |
| toSshdSocketAddress | back to summary |
|---|---|
| private SshdSocketAddress toSshdSocketAddress(String address) | |
| updateHostKeyLine | back to summary |
|---|---|
| private String updateHostKeyLine(String line, PublicKey newKey) throws IOException | |
| updateKnownHostsFile | back to summary |
|---|---|
| private void updateKnownHostsFile(Collection<SshdSocketAddress> candidates, PublicKey serverKey, Path path, ServerKeyDatabase. | |
| updateModifiedServerKey | back to summary |
|---|---|
| private void updateModifiedServerKey(PublicKey serverKey, KnownHostsServerKeyVerifier. | |
| Modifier and Type | Class and Description |
|---|---|
| private static enum | |
| public static enum |
| Modifier and Type | Field and Description |
|---|---|
| private final ServerKeyDatabase. | |
| private final CredentialsProvider |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public OpenSshServerKeyDatabase. | acceptModifiedServerKey(InetSocketAddress remoteAddress, PublicKey expected, PublicKey actual, Path path)
|
| public boolean | |
| private static boolean | |
| private OpenSshServerKeyDatabase. | |
| public boolean | |
| public void |
| config | back to summary |
|---|---|
| private final ServerKeyDatabase. | |
| provider | back to summary |
|---|---|
| private final CredentialsProvider provider | |
| AskUser | back to summary |
|---|---|
| public AskUser(ServerKeyDatabase. | |
| acceptModifiedServerKey | back to summary |
|---|---|
| public OpenSshServerKeyDatabase. | |
| acceptUnknownKey | back to summary |
|---|---|
| public boolean acceptUnknownKey(SocketAddress remoteAddress, PublicKey serverKey) | |
| askUser | back to summary |
|---|---|
| private static boolean askUser(CredentialsProvider provider, URIish uri, String prompt, String... messages) | |
| checkMode | back to summary |
|---|---|
| private OpenSshServerKeyDatabase. | |
| createNewFile | back to summary |
|---|---|
| public boolean createNewFile(Path path) | |
| revokedKey | back to summary |
|---|---|
| public void revokedKey(SocketAddress remoteAddress, PublicKey serverKey, Path path) | |
| Modifier and Type | Field and Description |
|---|---|
| public static final OpenSshServerKeyDatabase. | |
| public static final OpenSshServerKeyDatabase. | |
| public static final OpenSshServerKeyDatabase. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static OpenSshServerKeyDatabase. | |
| public static OpenSshServerKeyDatabase. |
| ALLOW | back to summary |
|---|---|
| public static final OpenSshServerKeyDatabase. | |
| ASK | back to summary |
|---|---|
| public static final OpenSshServerKeyDatabase. | |
| DENY | back to summary |
|---|---|
| public static final OpenSshServerKeyDatabase. | |
| Check | back to summary |
|---|---|
| private Check() | |
| valueOf | back to summary |
|---|---|
| public static OpenSshServerKeyDatabase. | |
| values | back to summary |
|---|---|
| public static OpenSshServerKeyDatabase. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final OpenSshServerKeyDatabase. | |
| public static final OpenSshServerKeyDatabase. | |
| public static final OpenSshServerKeyDatabase. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static OpenSshServerKeyDatabase. | |
| public static OpenSshServerKeyDatabase. |
| ALLOW | back to summary |
|---|---|
| public static final OpenSshServerKeyDatabase. | |
| ALLOW_AND_STORE | back to summary |
|---|---|
| public static final OpenSshServerKeyDatabase. | |
| DENY | back to summary |
|---|---|
| public static final OpenSshServerKeyDatabase. | |
| ModifiedKeyHandling | back to summary |
|---|---|
| private ModifiedKeyHandling() | |
| valueOf | back to summary |
|---|---|
| public static OpenSshServerKeyDatabase. | |
| values | back to summary |
|---|---|
| public static OpenSshServerKeyDatabase. | |
| Modifier and Type | Field and Description |
|---|---|
| private List |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public List | |
| private List |
| entries | back to summary |
|---|---|
| private List<KnownHostsServerKeyVerifier. | |
| HostKeyFile | back to summary |
|---|---|
| public HostKeyFile(Path path) | |
| get | back to summary |
|---|---|
| public List Implements java. Doc from java. Gets a result.
| |
| reload | back to summary |
|---|---|
| private List | |
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| private |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| RevokedKeyException | back to summary |
|---|---|
| private RevokedKeyException() | |