<commit_before>import logging
from ceph_deploy.lib import remoto
from ceph_deploy.connection import get_local_connection


def can_connect_passwordless(hostname):
    """
    Ensure that current host can SSH remotely to the remote
    host using the ``BatchMode`` option to prevent a password prompt.

    That attempt will error with an exit status of 255 and a ``Permission
    denied`` message or a``Host key verification failed`` message.
    """
    # Ensure we are not doing this for local hosts
    if not remoto.connection.needs_ssh(hostname):
        return True

    logger = logging.getLogger(hostname)
    with get_local_connection(logger) as conn:
        # Check to see if we can login, disabling password prompts
        command = ['ssh', '-CT', '-o', 'BatchMode=yes', hostname]
        out, err, retval = remoto.process.check(conn, command, stop_on_error=False)
        permission_denied_error = b'Permission denied '
        host_key_verify_error = b'Host key verification failed.'
        has_key_error = False
        for line in err:
            if permission_denied_error in line or host_key_verify_error in line:
                has_key_error = True

        if retval == 255 and has_key_error:
            return False
    return True<commit_msg>util: use 'true' when testing ssh connections<commit_after>import logging
from ceph_deploy.lib import remoto
from ceph_deploy.connection import get_local_connection


def can_connect_passwordless(hostname):
    """
    Ensure that current host can SSH remotely to the remote
    host using the ``BatchMode`` option to prevent a password prompt.

    That attempt will error with an exit status of 255 and a ``Permission
    denied`` message or a``Host key verification failed`` message.
    """
    # Ensure we are not doing this for local hosts
    if not remoto.connection.needs_ssh(hostname):
        return True

    logger = logging.getLogger(hostname)
    with get_local_connection(logger) as conn:
        # Check to see if we can login, disabling password prompts
        command = ['ssh', '-CT', '-o', 'BatchMode=yes', hostname, 'true']
        out, err, retval = remoto.process.check(conn, command, stop_on_error=False)
        permission_denied_error = b'Permission denied '
        host_key_verify_error = b'Host key verification failed.'
        has_key_error = False
        for line in err:
            if permission_denied_error in line or host_key_verify_error in line:
                has_key_error = True

        if retval == 255 and has_key_error:
            return False
    return True
{'fraction_non_alphanumeric': 0.0682699767261443, 'fraction_numerical': 0.004654771140418929, 'mean_word_length': 3.0678233438485805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '776072', 'n_tokens_mistral': 714, 'n_tokens_neox': 690, 'n_words': 262}