I encountered the the error message while running an Ansible Playbook against Ubuntu 24.04 Linux machine: “[WARNING]: sftp transfer mechanism failed on [192.168.1.205]. Use ANSIBLE_DEBUG=1 to see detailed information“. To get extra information regarding the error, I enabled debug in ansible.

export ANSIBLE_DEBUG=1

Then rerunning the playbook.

ansible-playbook playbook-name.yml

Get the exact version of ansible on your local system and try check against online pages if there is a known issue with it.

$ ansible --version
ansible [core 2.16.0]
  config file = None
  configured module search path = ['/Users/jkmutai/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/9.0.1/libexec/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/jkmutai/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.12.0 (main, Oct  2 2023, 12:03:24) [Clang 15.0.0 (clang-1500.0.40.1)] (/usr/local/Cellar/ansible/9.0.1/libexec/bin/python)
  jinja version = 3.1.2
  libyaml = True

There was not reported issue for my version.

On Debian based systems, installing openssh-sftp-server package will provide SFTP functionality. Make sure this package is installed on your remote Linux machine:

sudo apt install openssh-sftp-server

Next I opened SSH server configuration file on the remote machine:

sudo vim /etc/ssh/sshd_config

And commented below line.

#From 
Subsystem      sftp    /usr/lib/openssh/sftp-server
# To
#Subsystem      sftp    /usr/lib/openssh/sftp-server

I then added below to enable internal SFTP server within OpenSSH daemon.

Subsystem sftp internal-sftp

OpenSSH server must be restarted after the change.

sudo systemctl restart ssh

This change gave me a successful ansible execution.

LEAVE A REPLY

Please enter your comment!
Please enter your name here