Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I run:

ansible all -a "/bin/echo hello" -u myuser

I get back: | FAILED => failed to open a SFTP connection (Channel closed.)

The SFTP subsystem is disabled on the managed node I'm trying to connect to.

Is SFTP required on the managed nodes? The Ansible docs don't mention SFTP specifically:

I tried setting this value in ansible.cfg:


...but it had no effect. (Thanks to Fred the Magic Wonder Dog for the suggestion.)

I also ensured that my non-interactive shell doesn't produce any output as suggested here.

share|improve this question

Yes, ansible depends on being able to transfer files to the remote machine. It uses sftp to do this by default. You can override this to use scp using

Occasionally users may be managing a remote system that doesn’t have SFTP enabled. If set to True, we can cause scp to be used to transfer remote files instead:

There’s really no reason to change this unless problems are encountered, and then there’s also no real drawback to managing the switch. Most environments support SFTP by default and this doesn’t usually need to be changed.

The above information was taken from this page:

share|improve this answer
I uncommented "scp_if_ssh = True", but it had no effect. I still get the same error message. – braveterry Mar 14 '14 at 18:47
up vote 1 down vote accepted

Here's what I ended up doing:

  1. Copied /etc/ansible/ansible.cfg to ~/.ansible.cfg
  2. Edited ~/.ansible.cfg.
  3. Changed #scp_if_ssh = False to scp_if_ssh = True
  4. Added ssh_args = to [ssh_connection] section.
  5. Ran my command with -c SSH flag

Thanks to Fred the Magic Wonder Dog for pointing me in the right direction.

share|improve this answer
better to have code segment for your settings (ansible.cfg), i noticed scp_if_ssh=True shall be put below [ssh_connection], ssh_args is optional depends on each configuration. – larrycai Sep 1 '14 at 6:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.