# Sudo: timed out reading password error

**URL:** <https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294>\
**Category:** Get Help\
**Created:** [August 14, 2025, 7:24am UTC](https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294 "2025-08-14T07:24:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmohanraj](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@bmohanraj](https://forum.ansible.com/u/bmohanraj)\
**Post date:** [August 14, 2025, 7:24am UTC](https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294/1 "2025-08-14T07:24:57Z")

</div>

**shell module hangs and fails with timed out reading password error.**

- I am trying to run a command that requires sudo, I could run manually and it works fine.
- when tried to run from the shell module, the tasks hangs and fails with timed out reading password error.
- provided below the playbook used and the error response.
- playbook used

```auto
- name: Get machine info.
  vars:
    ansible_python_interpreter: /usr/bin/python
  hosts: all
  gather_facts: yes
  tasks:
    - name: Run pvs command
      shell: |
        sudo pvs

ansible command used:

ansible-playbook com.yml -i hosts -u rmdev -k -K

Error response: 
fatal: [swhdev3456]: FAILED! => {
    "changed": true,
    "cmd": "echo \"---------------------- date --------------------------------\"\nsudo pvs\n",
    "delta": "0:05:02.321612",
    "end": "2025-08-14 07:58:17.859787",
    "invocation": {
        "module_args": {
            "_raw_params": "echo \"---------------------- date --------------------------------\"\nsudo pvs\n",
            "_uses_shell": true,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true,
            "warn": false
        }
    },
    "msg": "non-zero return code",
    "rc": 1,
    "start": "2025-08-14 07:53:15.538175",
    "stderr": "sudo: timed out reading password\nsudo: a password is required",
    "stderr_lines": [
        "sudo: timed out reading password",
        "sudo: a password is required"
    ],
    "stdout": "---------------------- date --------------------------------",
    "stdout_lines": [
        "---------------------- date --------------------------------"
    ]
}

I updated the playbook like this, but still same error

- name: Get machine info.
  vars:
    ansible_python_interpreter: /usr/bin/python
  hosts: all
  gather_facts: yes
  become: yes
  become_user: rmdev
  become_method: sudo
  tasks:
    - name: Run pvs command
      shell: |
        sudo pvs

```

how to fix this issue?

Thanks,

Mohan

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [August 14, 2025, 11:31am UTC](https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294/2 "2025-08-14T11:31:16Z")

</div>

The option **`-K`** `quote: `_`“ask for privilege escalation password”`_`. See`[`Understanding privilege escalation: become`](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_privilege_escalation.html)`. Instead of executing ` **`sudo`** ` in the command,` escalate the privilege on the task level

```yaml
- name: Run pvs command
  become: true
  shell: pvs

```

Then, the option **-K** works as expected.

Note: The option **-k** quote: _“ask for connection password”_ has nothing to do with the escalation.

---

<div class="post-metadata">

**Author:** ![bmohanraj](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@bmohanraj](https://forum.ansible.com/u/bmohanraj)\
**Post date:** [August 14, 2025, 12:37pm UTC](https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294/3 "2025-08-14T12:37:47Z")

</div>

```auto
Thanks vbotka 

I updated the playbook as

- name: Get machine info.
  vars:
    ansible_python_interpreter: /usr/bin/python
  hosts: all
  gather_facts: yes
  tasks:
    - name: Run pvs command
      shell: pvs
      become: true

```

now getting below error

```auto
fatal: [swhdev3456]: FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to swhdev3456 closed.\r\n",
    "module_stdout": "\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

```

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [August 14, 2025, 12:44pm UTC](https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294/4 "2025-08-14T12:44:21Z")

</div>

> [@bmohanraj](#):
>
> `"module_stderr": "Shared connection to swhdev3456 closed.\r\n",`

This is a connection problem. See **`man ansible-playbook :`**

```auto
-v, --verbose
   ... connection debugging might require -vvvv.

```

---

<div class="post-metadata">

**Author:** ![bmohanraj](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@bmohanraj](https://forum.ansible.com/u/bmohanraj)\
**Post date:** [August 14, 2025, 1:18pm UTC](https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294/5 "2025-08-14T13:18:55Z")

</div>

```auto
with -vvvv
fatal: [swhdev3456]: FAILED! => {
    "changed": false,
    "module_stderr": "OpenSSH_8.0p1, OpenSSL 1.1.1k FIPS 25 Mar 2021\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host swhdev3456 originally swhdev3456\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'\r\ndebug2: match not found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: configuration requests final Match pass\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host swhdev3456 originally swhdev3456\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'\r\ndebug2: match found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 152294\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to swhdev3456 closed.\r\n",
    "module_stdout": "\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

```

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [August 14, 2025, 1:33pm UTC](https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294/6 "2025-08-14T13:33:08Z")

</div>

> [@bmohanraj](#):
>
> `"module_stderr": ...`
> 
> `debug3: mux_client_request_session: session request sent\r\n`
> 
> `debug3: mux_client_read_packet: read header failed: Broken pipe\r\n`
> 
> `debug2: Received exit status from master 1\r\n`
> 
> `Shared connection to swhdev3456 closed.\r\n",`

Your mux session is losing connection. To proceed, try to isolate the Ansible problem, if any, and provide [Minimal reproducible example](https://en.wikipedia.org/wiki/Minimal_reproducible_example#:~:text=In%20computing%2C%20a%20minimal%20reproducible,to%20be%20demonstrated%20and%20reproduced.).

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [August 14, 2025, 4:26pm UTC](https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294/7 "2025-08-14T16:26:10Z")

</div>

FYI, fact gathering already gathers LVM information

---

<div class="post-metadata">

**Author:** ![bmohanraj](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@bmohanraj](https://forum.ansible.com/u/bmohanraj)\
**Post date:** [August 18, 2025, 9:22am UTC](https://forum.ansible.com/t/sudo-timed-out-reading-password-error/44294/8 "2025-08-18T09:22:22Z")

</div>

with -c paramiko, I could identify that my user does have permission to run the Ansible python script as root user. I wonder why openssh error were not clear.  
thanks for all the troubleshooting help.

```auto
Sorry, user rmdev is not allowed to execute '/bin/sh -c echo BECOME-SUCCESS-asdfewqvocjyxzasddoikqezkdsseijok ; /usr/bin/python /home/rmdev/.ansible/tmp/ansible-tmp-1755186449.9872587-12357-118527423543084/AnsiballZ_command.py' as root on swhdev3456.

```
