# ansible with win11 + ssh - failed to create temporary directory

**URL:** <https://forum.ansible.com/t/ansible-with-win11-ssh-failed-to-create-temporary-directory/43795>\
**Category:** Get Help\
**Tags:** windows, ssh\
**Created:** [July 9, 2025, 11:01am UTC](https://forum.ansible.com/t/ansible-with-win11-ssh-failed-to-create-temporary-directory/43795 "2025-07-09T11:01:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ans00b](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@ans00b](https://forum.ansible.com/u/ans00b)\
**Post date:** [July 9, 2025, 11:01am UTC](https://forum.ansible.com/t/ansible-with-win11-ssh-failed-to-create-temporary-directory/43795/1 "2025-07-09T11:01:38Z")

</div>

Hi,  
using ansible control node on debian 12.

~/ansible/hosts

```auto
[windows]
win11 ansible_host=192.168.20.100 ansible_ssh_user=username ansible_ssh_password=password

```

**ansible all -i hosts -m win\_ping**

```auto
win11 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \"` echo ~/.ansible/tmp `\"&& mkdir \"` echo ~/.ansible/tmp/ansible-tmp-1752053110.016204-4679-123677624522219 `\" && echo ansible-tmp-1752053110.016204-4679-123677624522219=\"` echo ~/.ansible/tmp/ansible-tmp-1752053110.016204-4679-123677624522219 `\" ), exited with result 1",
    "unreachable": true
}

```

How to fix this ?

---

<div class="post-metadata">

**Author:** ![Lyle\_McKarns](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lyle_mckarns/32/8142_2.png) [@Lyle\_McKarns](https://forum.ansible.com/u/Lyle_McKarns)\
**Post date:** [July 9, 2025, 2:31pm UTC](https://forum.ansible.com/t/ansible-with-win11-ssh-failed-to-create-temporary-directory/43795/2 "2025-07-09T14:31:47Z")

</div>

Hi @ans00b, a few things

1. Do you have the `win11` machine setup with ssh? Ansible also provides `winrm`, which requires its own setup/configuration

2. Can you run the command with `-vvv` to get additional details, please?

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [July 10, 2025, 2:57am UTC](https://forum.ansible.com/t/ansible-with-win11-ssh-failed-to-create-temporary-directory/43795/3 "2025-07-10T02:57:47Z")

</div>

Have a read through [Windows SSH — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/os_guide/windows_ssh.html#ansible-configuration). You need to configure `ansible_shell_type` for your host so Ansible knows it is a Windows target and to avoid using things that won’t work on Windows.

---

<div class="post-metadata">

**Author:** ![ans00b](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@ans00b](https://forum.ansible.com/u/ans00b)\
**Post date:** [July 15, 2025, 5:31am UTC](https://forum.ansible.com/t/ansible-with-win11-ssh-failed-to-create-temporary-directory/43795/4 "2025-07-15T05:31:34Z")

</div>

thanks @ALL

this works for me:

inventory\_psrp.yaml

```auto
[windows]
win11 ansible_host=192.168.20.92 ansible_ssh_user=Administrator ansible_ssh_password=your_password

vars:
        ansible_user: Administrator
        ansible_password: your_password
        ansible_connection: psrp
        ansible_psrp_protocol: http
        ansible_psrp_message_encryption: never
        ansible_psrp_auth: credssp

```

win\_info.yaml

```auto
---
- name: Detect Windows Version, Edition, and Build (one line output)
  hosts: windows
  gather_facts: yes

  vars:
    win_version_map:
      '26100': '24H2'
      '22631': '23H2'
      '22621': '22H2'
      '22000': '21H2'

  tasks:
    - name: Extract build number from version string
      set_fact:
        win_build: "{{ ansible_distribution_version.split('.')[2] }}"

    - name: Map build number to Windows version label
      set_fact:
        win_version_label: "{{ win_version_map.get(win_build, 'Unknown') }}"

    - name: Show Windows Edition, Version, and Build in one line
      debug:
        msg: "Edition: {{ ansible_facts.os_caption | default(ansible_facts.os_edition | default(ansible_facts.os_name | default('Unknown'))) }}, Version: {{ win_version_label }}, Build: {{ ansible_distribution_version }}"

```

**ansible-playbook -i inventory\_psrp.yaml -e ‘ansible\_shell\_type=powershell’ win\_info.yaml**
