def add_authorized_key(public_key, application_name, user=None):
    """Add given key to the authorized_key file.

    :param public_key: Public key.
    :type public_key: str
    :param application_name: Name of application eg nova-compute-something
    :type application_name: str
    :param user: The user that the ssh asserts are for.
    :type user: str
    """
    with open(authorized_keys(application_name, user), 'a') as keys:
        keys.write("{}\n".format(public_key))
Add given key to the authorized_key file.

    :param public_key: Public key.
    :type public_key: str
    :param application_name: Name of application eg nova-compute-something
    :type application_name: str
    :param user: The user that the ssh asserts are for.
    :type user: str