(guestaddr, sshprivkey, command, timeout=10, user='root', prefix=None)
Function to execute a command on the guest using SSH and return the output.
    Modified version of function from ozutil to allow us to deal with non-root
    authorized users on ec2
Function to execute a command on the guest using SSH and return the output.
    Modified version of function from ozutil to allow us to deal with non-root
    authorized users on ec2
Function to execute a command on the guest using SSH and return the output . Modified version of function from ozutil to allow us to deal with non - root authorized users on ec2
def ssh_execute_command(guestaddr, sshprivkey, command, timeout=10, user='root', prefix=None):
    """
    Function to execute a command on the guest using SSH and return the output.
    Modified version of function from ozutil to allow us to deal with non-root
    authorized users on ec2
    """
    # ServerAliveInterval protects against NAT firewall timeouts
    # on long-running commands with no output
    #
    # PasswordAuthentication=no prevents us from falling back to
    # keyboard-interactive password prompting
    #
    # -F /dev/null makes sure that we don't use the global or per-user
    # configuration files
    #
    # -t -t ensures we have a pseudo tty for sudo

    cmd = ["ssh", "-i", sshprivkey,
            "-F", "/dev/null",
            "-o", "ServerAliveInterval=30",
            "-o", "StrictHostKeyChecking=no",
            "-o", "ConnectTimeout=" + str(timeout),
            "-o", "UserKnownHostsFile=/dev/null",
            "-t", "-t",
            "-o", "PasswordAuthentication=no"]

    if prefix:
        command = prefix + " " + command

    cmd.extend(["%s@%s" % (user, guestaddr), command])

    if(prefix == 'sudo'):
        return subprocess_check_output_pty(cmd)
    else:
        return subprocess_check_output(cmd)
def ssh_execute_command ( guestaddr , sshprivkey , command , timeout = 10 , user = 'root' , prefix = None ) : # ServerAliveInterval protects against NAT firewall timeouts # on long-running commands with no output # # PasswordAuthentication=no prevents us from falling back to # keyboard-interactive password prompting # # -F /dev/null makes sure that we don't use the global or per-user # configuration files # # -t -t ensures we have a pseudo tty for sudo cmd = [ "ssh" , "-i" , sshprivkey , "-F" , "/dev/null" , "-o" , "ServerAliveInterval=30" , "-o" , "StrictHostKeyChecking=no" , "-o" , "ConnectTimeout=" + str ( timeout ) , "-o" , "UserKnownHostsFile=/dev/null" , "-t" , "-t" , "-o" , "PasswordAuthentication=no" ] if prefix : command = prefix + " " + command cmd . extend ( [ "%s@%s" % ( user , guestaddr ) , command ] ) if ( prefix == 'sudo' ) : return subprocess_check_output_pty ( cmd ) else : return subprocess_check_output ( cmd )