Jump to >


class SSHStorage(namespace=None)[source]

Bases: object


Reads the user key.

This will return an instance of paramiko.PKey representing the user key, if one exists. Otherwise, it will return None.


Writes a user key.

The user key will be stored, and can be accessed later by read_user_key.

This will raise UnsupportedSSHKeyError if key isn’t a paramiko.RSAKey or paramiko.DSSKey.

It may also raise paramiko.SSHException for key-related errors.


Deletes a user key.

The user key, if it exists, will be removed from storage.

If no user key exists, this will do nothing.


Reads a list of authorized keys.

The authorized keys are returned as a list of raw key data, which can then be converted into classes as needed.


Reads a list of known host keys.

This known host keys are returned as a list of raw key data, which can then be converted into classes as needed.

add_host_key(hostname, key)[source]

Adds a known key for a given host.

This will store a mapping of the key and hostname so that future access to the server will know the host is legitimate.

replace_host_key(hostname, old_key, new_key)[source]

Replaces a host key in the known hosts list with another.

This is used for replacing host keys that have changed.

class FileSSHStorage(namespace=None)[source]

Bases: reviewboard.ssh.storage.SSHStorage

DEFAULT_KEY_FILES = ((<class ‘paramiko.rsakey.RSAKey’>, u’id_rsa’), (<class ‘paramiko.dsskey.DSSKey’>, u’id_dsa’))[source]
SSH_DIRS = (u’.ssh’, u’ssh’)[source]
add_host_key(hostname, key)[source]
replace_host_key(hostname, old_key, new_key)[source]

Returns the path to the known host keys file.


Returns the path to the SSH directory on the system.

By default, this will attempt to find either a .ssh or ssh directory. If ssh_dir_name is specified, the search will be skipped, and we’ll use that name instead.


Ensures the existance of the .ssh directory.

If the directory doesn’t exist, it will be created. The full path to the directory will be returned.

Callers are expected to handle any exceptions. This may raise IOError for any problems in creating the directory.