mccli.ssh_wrapper

ssh_wrap(ssh_args, username, token, str_get_token=None, dry_run=False, set_remote_env=False)

Runs the ssh command given by list of ssh_args, using given username and given token as password.

When dry_run is true, it only prints the sshpass command; when the string representation of the command to get the token is not defined (str_get_token), the actual token is printed.

When set_remote_env is true, it sets the environment variable OIDC_SOCK on the remote host to the forwarded oidc agent socket. This is useful for non-interactive ssh sessions, when the user does not have a shell on the remote host.

scp_wrap(scp_args, username=None, tokens=None, str_get_tokens=None, num_prompts=1, dry_run=False)

Runs the scp command given by list of scp_args.

If username and tokens are both None, we are in the NO_MOTLEY_CUE case and the process is simply started as it is; the user will interact with the process for any needed authentication; there is no motley_cue handling.

If username is set, we are in the SINGLE_REMOTE case, where there is a single motley_cue instance in the arguments, so the user can be passed as an ssh option with ‘-o User’. The tokens argument must be a string in this case. The command will prompt for the token num_prompts times.

If username is not set, but tokens is (must be a list), then we are in the MULTIPLE_REMOTES case, where the scp_args have been already augmented with usernames obtained from the motley_cue service(s). The tokens have to be input when prompted, in the given order. There should not be more prompts than tokens; any subsequent prompts will be forwarded to the user to handle.

When dry_run is true, it only prints the needed command(s); if str_get_tokens is set, it prints the string representation(s) of the command(s) to get the token(s) instead of the actual token(s).

get_hostname(ssh_args)

Try to get the ssh host from ssh_args by executing the ssh command with -G option and parsing the output for the actual HOSTNAME.