### Summary

The reboot module waits until it can SSH to the server again. It keeps trying until either it succeeds or for the specified timeout.

When the SSH connection fails because the user does not have access to the server it just keeps waiting until the timeout expires and eventually reports a generic "timeout expired" message, which is unhelpful. It would be helpful if the module:

1. Reported the actual error it got on the last attempt before it gave up.
2. Ideally, distinguished permission errors like "Permission denied (publickey)." or "Your account has expired; please contact your system administrator." from the server not being up yet and gave up without waiting out the timeout for permission errors. (Or maybe those errors should have a separate timeout, lower by default?)

### Issue Type

Bug Report

### Component Name

ansible.builtin.reboot

### Ansible Version

```console
$ ansible --version
ansible [core 2.14.9]
  config file = /media/sf_work/lops/ansible/ansible.cfg
  configured module search path = ['/home/em/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/em/.direnv/python-3.9.5/lib/python3.9/site-packages/ansible
  ansible collection location = /home/em/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/em/.direnv/python-3.9.5/bin/ansible
  python version = 3.9.5 (default, Nov 23 2021, 15:27:38) [GCC 9.3.0] (/home/em/.direnv/python-3.9.5/bin/python3.9)
  jinja version = 3.1.2
  libyaml = True
```


### Configuration

```console
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /media/sf_work/lops/ansible/ansible.cfg
DEFAULT_BECOME(/media/sf_work/lops/ansible/ansible.cfg) = True
DEFAULT_FILTER_PLUGIN_PATH(/media/sf_work/lops/ansible/ansible.cfg) = ['/media/sf_work/lops/ansible/filter_plugins']
DEFAULT_HASH_BEHAVIOUR(/media/sf_work/lops/ansible/ansible.cfg) = merge
DEFAULT_LOG_PATH(/media/sf_work/lops/ansible/ansible.cfg) = /media/sf_work/lops/ansible/ansible.log
DEFAULT_LOOKUP_PLUGIN_PATH(/media/sf_work/lops/ansible/ansible.cfg) = ['/media/sf_work/lops/ansible/lookup_plugins']
DEFAULT_ROLES_PATH(/media/sf_work/lops/ansible/ansible.cfg) = ['/media/sf_work/lops/ansible/roles']
DEFAULT_STDOUT_CALLBACK(/media/sf_work/lops/ansible/ansible.cfg) = debug
DEFAULT_TRANSPORT(/media/sf_work/lops/ansible/ansible.cfg) = smart
DEFAULT_VAULT_PASSWORD_FILE(/media/sf_work/lops/ansible/ansible.cfg) = /media/sf_work/lops/ansible/tools/vault-keyring.sh
DIFF_ALWAYS(/media/sf_work/lops/ansible/ansible.cfg) = True
RETRY_FILES_ENABLED(/media/sf_work/lops/ansible/ansible.cfg) = False
TRANSFORM_INVALID_GROUP_CHARS(/media/sf_work/lops/ansible/ansible.cfg) = ignore

CONNECTION:
==========

ssh:
___
pipelining(/media/sf_work/lops/ansible/ansible.cfg) = True
```


### OS / Environment

Ubuntu 22.04 target, Linux Mint 20 control machine

### Steps to Reproduce

Run a playbook that somehow disables the user it connects as (in my case I added `AllowGroups` to /etc/ssh/sshd_config and the user it connected as was not a member of that group) and then runs the `reboot` module.

### Expected Results

The target machine reboots and the `reboot` module then fails with an error like "Connection failed due to SSH error: Permission denied (publickey)." - preferably without waiting 10 minutes (the default timeout).

### Actual Results

The target machine reboots as expected, but the Ansible play appears to hang in the reboot module.

With ANSIBLE_DEBUG=1 I can see the real problem:

```console
148477 1692889630.14999: reboot: last boot time check fail 'Failed to connect to the host via ssh: ssh: connect to host MYHOST port 22: Connection refused', retrying in 12.3 seconds...
148477 1692889643.07223: reboot: last boot time check fail 'Failed to connect to the host via ssh: ubuntu@MYHOST: Permission denied (publickey).', retrying in 12.84 seconds...
... then more of the same until the timeout expires
```

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
BOOT_TIME_COMMANDS = {
        'freebsd': '/sbin/sysctl kern.boottime',
        'openbsd': '/sbin/sysctl kern.boottime',
        'macosx': 'who -b',
        'solaris': 'who -b',
        'sunos': 'who -b',
        'vmkernel': 'grep booted /var/log/vmksummary.log | tail -n 1',
        'aix': 'who -b',
    }
    SHUTDOWN_COMMANDS = {
        'alpine': 'reboot',
        'vmkernel': 'reboot',
    }
    SHUTDOWN_COMMAND_ARGS = {
        'alpine': '',
        'void': '-r +{delay_min} "{message}"',
        'freebsd': '-r +{delay_sec}s "{message}"',
        'linux': DEFAULT_SHUTDOWN_COMMAND_ARGS,
        'macosx': '-r +{delay_min} "{message}"',
        'openbsd': '-r +{delay_min} "{message}"',
        'solaris': '-y -g {delay_sec} -i 6 "{message}"',
        'sunos': '-y -g {delay_sec} -i 6 "{message}"',
        'vmkernel': '-d {delay_sec}',
        'aix': '-Fr',
    }
    TEST_COMMANDS = {
        'solaris': 'who',
        'vmkernel': 'who',
    }
    def __init__(self, *args, **kwargs):