t.c.c.k.KnownHostsFile(object) : class documentation

Part of twisted.conch.client.knownhosts View Source View In Hierarchy

A structured representation of an OpenSSH-format ~/.ssh/known_hosts file.
Method __init__ Create a new, empty KnownHostsFile.
Method savePath
Method iterentries Iterate over the host entries in this file.
Method hasHostKey Check for an entry with matching hostname and key.
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.
Method addHostKey Add a new HashedEntry to the key database.
Method save Save this KnownHostsFile to the path it was loaded from.
Class Method fromPath Create a new KnownHostsFile, potentially reading existing known hosts information from the given file.
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. (type: bool)
Instance Variable _savePath See savePath parameter of __init__.
_added =
A list of IKnownHostEntry providers which have been added to this instance in memory but not yet saved.
_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. (type: bool)
_savePath =
See savePath parameter of __init__.
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.

ParameterssavePathThe FilePath to which to save new entries. (type: FilePath)
@property
def savePath(self): (source)
See AlsosavePath parameter of __init__
def iterentries(self): (source)
Iterate over the host entries in this file.
ReturnsAn 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. (type: iterable of IKnownHostEntry providers)
def hasHostKey(self, hostname, key): (source)
Check for an entry with matching hostname and key.
ParametershostnameA hostname or IP address literal to check for. (type: bytes)
keyThe public key to check for. (type: Key)
ReturnsTrue if the given hostname and key are present in this file, False if they are not. (type: bool)
RaisesHostKeyChangedif the host key found for the given hostname does not match the given key.
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.
ParametersuiThe user interface to request an IP address from.
hostnameThe hostname that the user requested to connect to.
ipThe string representation of the IP address that is actually being connected to.
keyThe public key of the server.
Returnsa 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. (type: Deferred)
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.

ParametershostnameA hostname or IP address literal to associate with the new entry. (type: bytes)
keyThe public key to associate with the new entry. (type: Key)
ReturnsThe HashedEntry that was added. (type: HashedEntry)
def save(self): (source)
Save this KnownHostsFile to the path it was loaded from.
@classmethod
def fromPath(cls, path): (source)
Create a new KnownHostsFile, potentially reading existing known hosts information from the given file.
ParameterspathA 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. (type: FilePath)
ReturnsA KnownHostsFile initialized with entries from path. (type: KnownHostsFile)
API Documentation for Twisted, generated by pydoctor at 2014-05-12 18:27:00.