reviewboard.ssh.storage¶
- class SSHStorage(namespace=None)[source]¶
Bases:
object
- 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 aparamiko.RSAKey
orparamiko.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.
- class FileSSHStorage(namespace=None)[source]¶
Bases:
SSHStorage
- DEFAULT_KEY_FILES = ((<class 'paramiko.rsakey.RSAKey'>, 'id_rsa'), (<class 'paramiko.dsskey.DSSKey'>, 'id_dsa'))[source]¶
- 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 aparamiko.RSAKey
orparamiko.DSSKey
.It may also raise
paramiko.SSHException
for key-related errors.
- delete_user_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.
- 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 existence 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.
- __annotations__ = {}¶
- set_ssh_storage_backend_path(storage_backend)[source]¶
Set the SSH storage backend to use for SSH.
This will store the backend in the database and make it available immediately for SSH sessions.
New in version 3.0.18.
- Parameters:
storage_backend (
unicode
) – The class path for the storage backend to set. This can beNone
to unset the storage backend, using the defaults instead.
- get_ssh_storage_backend_path()[source]¶
Return the SSH storage backend used for SSH.
This will return the version stored in the site configuration. It does not consider any legacy methods of storing the backend.
New in version 3.0.18.
- Returns:
The class path for the configured storage backend. This may be
None
.- Return type: