Example #1
0
def is_key_valid(key):
    """
        Is the given key a valid SSH-key with RSA encryption?
    """
    if not isValidFile(key):
        return False

    file_content = readContentOf(key)
    if file_content == None:
        return False

    # File read! Now check if it's RSA encrypted ...
    if file_content[:8] != 'ssh-rsa ':
        return False

    return True
Example #2
0
def is_key_valid(key):
    """
        Is the given key a valid SSH-key with RSA encryption?
    """
    if not isValidFile(key):
        return False

    file_content = readContentOf(key)
    if not file_content:
        return False

    # File read! Now check if it's RSA encrypted ...
    if file_content[:8] != 'ssh-rsa ':
        return False

    return True
Example #3
0
def ask_user_to_use_default_ssh_public_key():
    """
        Ask the user if the default public SSH-key (RSA)
        shall be used.
    """
    default_rsa_public_key = get_default_ssh_key_path()

    # Check first if we actually have a default SSH public key.
    # If we don't then simply return nothing ("")
    if not isValidFile(default_rsa_public_key):
        return ""

    # Ok, found! Ask user if we should use this one ...
    question = raw_input("Found default key '{0}' . ".format(default_rsa_public_key) +
                         'Type "Yes" to use the default key: ')
    if question.lower() != 'yes':
        raise InputErrorException('SecurityQuestionDenied')

    return 0
Example #4
0
def ask_user_to_use_default_ssh_public_key():
    """
        Ask the user if the default public SSH-key (RSA)
        shall be used.
    """
    default_rsa_public_key = get_default_ssh_key_path()

    # Check first if we actually have a default SSH public key.
    # If we don't then simply return nothing ("")
    if not isValidFile(default_rsa_public_key):
        return ""

    # Ok, found! Ask user if we should use this one ...
    question = raw_input(
        "Found default key '{0}' . ".format(default_rsa_public_key) +
        'Type "Yes" to use the default key: ')
    if question.lower() != 'yes':
        raise InputErrorException('SecurityQuestionDenied')

    return 0
Example #5
0
def ask_user_to_use_default_ssh_public_key():
    """
        Ask the user if the default public SSH-key (RSA)
        shall be used.
    """
    if sys.platform == 'win32':
        default_rsa_public_key = os.path.expanduser('~')
    else:
        default_rsa_public_key = os.getenv("HOME") + "/.ssh/id_rsa.pub"

    # Check first if we actually have a default SSH public key.
    # If we don't then simply return nothing ("")
    if not isValidFile(default_rsa_public_key):
        return ""

    # Ok, found! Ask user if we should use this one ...
    question = raw_input("Found default key '{0}' . ".format(default_rsa_public_key) +
                         'Type "Yes" to use the default key: ')
    if question.lower() != 'yes':
        raise InputErrorException('SecurityQuestionDenied')

    return 0
Example #6
0
def ask_user_to_use_default_ssh_public_key():
    """
        Ask the user if the default public SSH-key (RSA)
        shall be used.
    """
    if sys.platform == 'win32':
        default_rsa_public_key = os.path.expanduser('~')
    else:
        default_rsa_public_key = os.getenv("HOME") + "/.ssh/id_rsa.pub"

    # Check first if we actually have a default SSH public key.
    # If we don't then simply return nothing ("")
    if not isValidFile(default_rsa_public_key):
        return ""

    # Ok, found! Ask user if we should use this one ...
    question = raw_input(
        "Found default key '{0}' . ".format(default_rsa_public_key) +
        'Type "Yes" to use the default key: ')
    if question.lower() != 'yes':
        raise InputErrorException('SecurityQuestionDenied')

    return 0