Jump to >

reviewboard.ssh.storage

class SSHStorage(namespace=None)[source]

Bases: object

__init__(namespace=None)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

read_user_key()[source]

Reads the user key.

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

write_user_key(key)[source]

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.

delete_user_key(key)[source]

Deletes a user key.

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

If no user key exists, this will do nothing.

read_authorized_keys()[source]

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.

read_host_keys()[source]

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]
get_user_key_info()[source]
read_user_key()[source]
write_user_key(key)[source]
delete_user_key()[source]
read_authorized_keys()[source]
read_host_keys()[source]
add_host_key(hostname, key)[source]
replace_host_key(hostname, old_key, new_key)[source]
get_host_keys_filename()[source]

Returns the path to the known host keys file.

get_ssh_dir(ssh_dir_name=None)[source]

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.

ensure_ssh_dir()[source]

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.