reviewboard.ssh.client¶
-
class
SSHHostKeys
(storage)[source]¶ Bases:
paramiko.hostkeys.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.
-
class
SSHClient
(namespace=None, storage=None)[source]¶ Bases:
paramiko.client.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.
-
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.
Returns whether or not a public key is currently authorized.
-
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.
-