Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`conch`.`client`.`knownhosts`.`KnownHostsFile``

class documentation

`class KnownHostsFile: (source)`

View In Hierarchy

A structured representation of an OpenSSH-format ~/.ssh/known_hosts file.

Class Method | `fromPath` | Create a new `KnownHostsFile`, potentially reading existing known hosts information from the given file.
Method | `__init__` | Create a new, empty KnownHostsFile.
Method | `addHostKey` | Add a new `HashedEntry` to the key database.
Method | `hasHostKey` | Check for an entry with matching hostname and key.
Method | `iterentries` | Iterate over the host entries in this file.
Method | `save` | Save this `KnownHostsFile` to the path it was loaded from.
Method | `verifyHostKey` | Verify the given host key for the given IP and host, asking for confirmation from, and notifying, the given UI about changes to this file.
Property | `savePath` | No summary
Instance Variable | `_added` | A list of `IKnownHostEntry` providers which have been added to this instance in memory but not yet saved.
Instance Variable | `_clobber` | A flag indicating whether the current contents of the save path will be disregarded and potentially overwritten or not. If `True`, this will be done. If `False`, entries in the save path will be read and new entries will be saved by appending rather than overwriting.
Instance Variable | `_savePath` | See `savePath` parameter of `__init__`.

@classmethod
def fromPath(cls, path): (source)

Create a new `KnownHostsFile`, potentially reading existing known hosts information from the given file.

Parameters
path:`FilePath` | A path object to use for both reading contents from and later saving to. If no file exists at this path, it is not an error; a `KnownHostsFile` with no entries is returned.
Returns
`KnownHostsFile` | A `KnownHostsFile` initialized with entries from `path`.

def __init__(self, savePath): (source)

Create a new, empty KnownHostsFile.

Unless you want to erase the current contents of `savePath`, you want to use `KnownHostsFile.fromPath` instead.

Parameters
savePath:`FilePath` | The `FilePath` to which to save new entries.

def addHostKey(self, hostname, key): (source)

Add a new `HashedEntry` to the key database.

Note that you still need to call `KnownHostsFile.save` if you wish these changes to be persisted.

Parameters
hostname:`bytes` | A hostname or IP address literal to associate with the new entry.
key:`Key` | The public key to associate with the new entry.
Returns
`HashedEntry` | The `HashedEntry` that was added.

def hasHostKey(self, hostname, key): (source)

Check for an entry with matching hostname and key.

Parameters
hostname:`bytes` | A hostname or IP address literal to check for.
key:`Key` | The public key to check for.
Returns
`bool` | `True` if the given hostname and key are present in this file, `False` if they are not.
Raises
`HostKeyChanged` | if the host key found for the given hostname does not match the given key.

def iterentries(self): (source)

Iterate over the host entries in this file.

Returns
iterable of `IKnownHostEntry` providers | An iterable the elements of which provide `IKnownHostEntry`. There is an element for each entry in the file as well as an element for each added but not yet saved entry.

def save(self): (source)

Save this `KnownHostsFile` to the path it was loaded from.

def verifyHostKey(self, ui, hostname, ip, key): (source)

Verify the given host key for the given IP and host, asking for confirmation from, and notifying, the given UI about changes to this file.

Parameters
ui | The user interface to request an IP address from.
hostname | The hostname that the user requested to connect to.
ip | The string representation of the IP address that is actually being connected to.
key | The public key of the server.
Returns
`Deferred` | a `Deferred` that fires with True when the key has been verified, or fires with an errback when the key either cannot be verified or has changed.

@property
savePath = (source)

See Also
`savePath` parameter of `__init__`

_added: `list` = (source)

A list of `IKnownHostEntry` providers which have been added to this instance in memory but not yet saved.

_clobber: `bool` = (source)

A flag indicating whether the current contents of the save path will be disregarded and potentially overwritten or not. If `True`, this will be done. If `False`, entries in the save path will be read and new entries will be saved by appending rather than overwriting.

_savePath = (source)

See `savePath` parameter of `__init__`.