reviewboard.ssh.client¶
- class SSHHostKeys(storage)[source]¶
Bases:
HostKeys
Manages known lists of host keys.
This is a specialization of paramiko.HostKeys that interfaces with a storage backend to get the list of host keys.
- __init__(storage)[source]¶
Create a new HostKeys object, optionally loading keys from an OpenSSH style host-key file.
- Parameters:
filename (str) – filename to load host keys from, or
None
- save(filename)[source]¶
Save host keys into a file, in the format used by OpenSSH. The order of keys in the file will be preserved when possible (if these keys were loaded from a file originally). The single exception is that combined lines will be split into individual key lines, which is arguably a bug.
- Parameters:
filename (str) – name of the file to write
- Raises:
IOError
– if there was an error writing the file
New in version 1.6.1.
- __abstractmethods__ = frozenset({})¶
- class SSHClient(namespace=None, storage_backend=None)[source]¶
Bases:
SSHClient
A client for communicating with an SSH server.
SSHClient allows for communicating with an SSH server and managing all known host and user keys.
This is a specialization of paramiko.SSHClient, and supports all the same capabilities.
Key access goes through an SSHStorage backend. The storage backend knows how to look up keys and write them.
The default backend works with the site directory’s
data/.ssh
directory, and supports namespaced directories for LocalSites.- __init__(namespace=None, storage_backend=None)[source]¶
Initialize the client.
Changed in version 3.0.18: Renamed the old, unused
storage
parameter to a supportedstorage_backend
parameter.
- get_user_key()[source]¶
Returns the keypair of the user running Review Board.
This will be an instance of
paramiko.PKey
, representing a DSS or RSA key, as long as one exists. Otherwise, it may return None.
- delete_user_key()[source]¶
Deletes the user key for this client.
If no key exists, this will do nothing.
- get_public_key(key)[source]¶
Returns the public key portion of an SSH key.
This will be formatted for display.
- generate_user_key(bits=2048)[source]¶
Generates a new RSA keypair for the user running Review Board.
This will store the new key in the backend storage and return the resulting key as an instance of
paramiko.RSAKey
.If a key already exists, it’s returned instead.
Callers are expected to handle any exceptions. This may raise IOError for any problems in writing the key file, or paramiko.SSHException for any other problems.
- import_user_key(keyfile)[source]¶
Imports an uploaded key file into Review Board.
keyfile
is expected to be anUploadedFile
or a paramikoKeyFile
. If this is a valid key file, it will be saved in the storage backend and the resulting key as an instance ofparamiko.PKey
will be returned.If a key of this name already exists, it will be overwritten.
Callers are expected to handle any exceptions. This may raise IOError for any problems in writing the key file, or paramiko.SSHException for any other problems.
This will raise UnsupportedSSHKeyError if the uploaded key is not a supported type.