Package ganeti :: Module ssh
[hide private]
[frames] | no frames]

Module ssh

source code

Module encapsulating ssh functionality.

Classes [hide private]
  SshRunner
Wrapper for SSH commands.
Functions [hide private]
tuple; (string, string, string)
GetUserFiles(user, mkdir=False, dircheck=True, kind=constants.SSHK_DSA, _homedir_fn=None)
Return the paths of a user's SSH files.
source code
tuple; (string, dict with string as key, tuple of (string, string) as value)
GetAllUserFiles(user, mkdir=False, dircheck=True, _homedir_fn=None)
Wrapper over GetUserFiles to retrieve files for all SSH key types.
source code
 
WriteKnownHostsFile(cfg, file_name)
Writes the cluster-wide equally known_hosts file.
source code

Imports: os, logging, utils, errors, constants, netutils, pathutils, vcluster, compat, ssconf


Function Details [hide private]

GetUserFiles(user, mkdir=False, dircheck=True, kind=constants.SSHK_DSA, _homedir_fn=None)

source code 

Return the paths of a user's SSH files.

Parameters:
  • user (string) - Username
  • mkdir (bool) - Whether to create ".ssh" directory if it doesn't exist
  • dircheck (bool) - Whether to check if ".ssh" directory exists
  • kind (string) - One of constants.SSHK_ALL
Returns: tuple; (string, string, string)
Tuple containing three file system paths; the private SSH key file, the public SSH key file and the user's authorized_keys file
Raises:
  • errors.OpExecError - When home directory of the user can not be determined
  • errors.OpExecError - Regardless of the mkdir parameters, this exception is raised if ~$user/.ssh is not a directory and dircheck is set to True

GetAllUserFiles(user, mkdir=False, dircheck=True, _homedir_fn=None)

source code 

Wrapper over GetUserFiles to retrieve files for all SSH key types.

See GetUserFiles for details.

Returns: tuple; (string, dict with string as key, tuple of (string, string) as value)