Package paramiko :: Module hostkeys :: Class HostKeyEntry
[frames] | no frames]

Class HostKeyEntry

source code

Representation of a line in an OpenSSH-style "known hosts" file.

Instance Methods
 
__init__(self, hostnames=None, key=None) source code
 
to_line(self)
Returns a string in OpenSSH known_hosts file format, or None if the object is not in a valid state.
source code
 
__repr__(self) source code
Class Methods
 
from_line(cls, line)
Parses the given line of text to find the names for the host, the type of key, and the key data.
source code
Method Details

from_line(cls, line)
Class Method

source code 

Parses the given line of text to find the names for the host, the type of key, and the key data. The line is expected to be in the format used by the openssh known_hosts file.

Lines are expected to not have leading or trailing whitespace. We don't bother to check for comments or empty lines. All of that should be taken care of before sending the line to us.

Parameters:
  • line (str) - a line from an OpenSSH known_hosts file

to_line(self)

source code 

Returns a string in OpenSSH known_hosts file format, or None if the object is not in a valid state. A trailing newline is included.