x2go.checkhosts module¶
Providing mechanisms to X2GoControlSession* backends for checking host validity.
-
class
x2go.checkhosts.X2GoAutoAddPolicy(caller=None, session_instance=None, fake_hostname=None)[source]¶
-
class
x2go.checkhosts.X2GoInteractiveAddPolicy(caller=None, session_instance=None, fake_hostname=None)[source]¶ Bases:
x2go.checkhosts.X2GoMissingHostKeyPolicyPolicy for making host key information available to Python X2Go after a Paramiko/SSH connect has been attempted. This class needs information about the associated
x2go.session.X2GoSessioninstance.Once called, the
missing_host_key()method of this class will try to callX2GoSession.HOOK_check_host_dialog(). This hook method—if not re-defined in your application—will then try to call theX2GoClient.HOOK_check_host_dialog(), which then will returnTrueby default if not customized in your application.To accept host key checks, make sure to either customize the
X2GoClient.HOOK_check_host_dialog()method or theX2GoSession.HOOK_check_host_dialog()method and hook some interactive user dialog to either of them.-
missing_host_key(client, hostname, key)[source]¶ Handle a missing host key situation. This method calls
Once called, the
missing_host_key()method will try to callX2GoSession.HOOK_check_host_dialog(). This hook method—if not re-defined in your application—will then try to call theX2GoClient.HOOK_check_host_dialog(), which then will returnTrueby default if not customized in your application.To accept host key checks, make sure to either customize the
X2GoClient.HOOK_check_host_dialog()method or theX2GoSession.HOOK_check_host_dialog()method and hook some interactive user dialog to either of them.Parameters: - client (
X2GoControlSession*instance) – SSH client (X2GoControlSession*) instance - hostname (
str) – remote hostname - key (Paramiko/SSH key instance) – host key to validate
Raises: - X2GoHostKeyException – if the X2Go server host key is not in the
known_hostsfile - X2GoSSHProxyHostKeyException – if the SSH proxy host key is not in the
known_hostsfile - SSHException – if this instance does not know its {self.session_instance}
- client (
-
-
class
x2go.checkhosts.X2GoMissingHostKeyPolicy(caller=None, session_instance=None, fake_hostname=None)[source]¶ Bases:
paramiko.client.MissingHostKeyPolicySkeleton class for Python X2Go’s missing host key policies.
-
get_client()[source]¶ Retrieve the Paramiko SSH/Client.
Returns: the associated X2Go control session instance. Return type: X2GoControlSession*instance
-
get_hostname()[source]¶ Retrieve the server hostname:port expression of the server to be validated.
Returns: hostname:port Return type: str
-
get_hostname_name()[source]¶ Retrieve the server hostname string of the server to be validated.
Returns: hostname Return type: str
-
get_hostname_port()[source]¶ Retrieve the server port of the server to be validated.
Returns: port Return type: str
-
get_key()[source]¶ Retrieve the host key of the server to be validated.
Returns: host key Return type: Paramiko/SSH key instance
-
get_key_fingerprint()[source]¶ Retrieve the host key fingerprint of the server to be validated.
Returns: host key fingerprint Return type: str
-
-
x2go.checkhosts.check_ssh_host_key(x2go_sshclient_instance, hostname, port=22)[source]¶ Perform a Paramiko/SSH host key check by connecting to the host and validating the results (i.e. by validating raised exceptions during the connect process).
Parameters: - x2go_sshclient_instance (
X2GoControlSession*instance) – a Paramiko/SSH client instance to be used for testing host key validity. - hostname (
str) – hostname of server to validate - port (
int) – port of server to validate (Default value = 22)
Returns: returns a tuple with the following components (<host_ok>, <hostname>, <port>, <fingerprint>, <fingerprint_type>)
Return type: tupleRaises: SSHException – if an SSH exception occurred, that we did not provocate in
X2GoInteractiveAddPolicy.missing_host_key() <x2go.checkhosts.X2GoInteractiveAddPolicy.missing_host_key()- x2go_sshclient_instance (