# transport=smart, SFTP failures and ssh connections

**URL:** <https://forum.ansible.com/t/transport-smart-sftp-failures-and-ssh-connections/14897>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [March 31, 2014, 2:34pm UTC](https://forum.ansible.com/t/transport-smart-sftp-failures-and-ssh-connections/14897 "2014-03-31T14:34:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![marc.petrivelli](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/marc.petrivelli/32/3773_2.png) [@marc.petrivelli](https://forum.ansible.com/u/marc.petrivelli)\
**Post date:** [March 31, 2014, 2:34pm UTC](https://forum.ansible.com/t/transport-smart-sftp-failures-and-ssh-connections/14897/1 "2014-03-31T14:34:15Z")

</div>

In my ansible.cfg I had the following set:

[defaults]

transport=smart

[ssh\_connection]  
scp\_if\_ssh=True

For one of my target hosts (specifically a VMware vCenter appliance) I received a SFTP disabled error. After investigating this host did in fact have SFTP disabled (on purpose). I am curious about a few things.

1. why is the paramiko python ssh lib defaulting to SFTP for file transfer? Is this intended? Is it more efficient?

2. Wouldn’t it make sense for the ansible connection module to detect this failure and alternatively try to use SCP to transfer the file?

In the end I had to force the host to use SSH (ansible\_connection=ssh in my inventory file) and then change

From:

ssh\_args = -o ControlMaster=auto -o ControlPersist=60s

To:  
ssh\_args = -o ControlMaster=auto

to get everything to work. It seems ansible is smart enough to detect which features the particular flavor of sshd supports when ssh transport is used. It seems the connection module using paramiko might be able to determine if SFTP is disabled and fail over to SCP.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [March 31, 2014, 8:04pm UTC](https://forum.ansible.com/t/transport-smart-sftp-failures-and-ssh-connections/14897/2 "2014-03-31T20:04:44Z")

</div>

Hi Marc, could you open a github issue for this? Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [March 31, 2014, 9:25pm UTC](https://forum.ansible.com/t/transport-smart-sftp-failures-and-ssh-connections/14897/3 "2014-03-31T21:25:25Z")

</div>

Ok so under ssh\_connection this parameter is only for the SSH transport.

Paramiko doesn’t have this. So what you have for controlling wouldn’t be handled by (1)

(2) is unlikely to be implemented.

So the question is really can paramiko scp all of the time –

I don’t particularly recall but I believe in some cases SCP can be disabled? If I’m wrong, this is reasonable.

If I am not, we can make a new configuration option for paramiko.

But paramiko shouldn’t obey the config section for the SSH transport.

---

<div class="post-metadata">

**Author:** ![Hans\_Lellelid](https://avatars.discourse-cdn.com/v4/letter/h/97f17d/32.png) [@Hans\_Lellelid](https://forum.ansible.com/u/Hans_Lellelid)\
**Post date:** [April 25, 2014, 8:18pm UTC](https://forum.ansible.com/t/transport-smart-sftp-failures-and-ssh-connections/14897/4 "2014-04-25T20:18:42Z")

</div>

I like the idea of having sftp vs scp be configurable for paramiko. We don’t use sftp in our infrastructure (except in a few cases), so having an scp option for paramiko would be nice. (Lots of CentOS 5.x in infrastructure, so paramiko is still desired.) Here is a custom paramiko plugin that uses scp instead of sftp: [https://gist.github.com/hozn/11301845](https://gist.github.com/hozn/11301845)

This uses the scp library: [https://pypi.python.org/pypi/scp/](https://pypi.python.org/pypi/scp/)

Making this a configuration option instead would obviously be pretty straightforward.

Hans

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 25, 2014, 8:58pm UTC](https://forum.ansible.com/t/transport-smart-sftp-failures-and-ssh-connections/14897/5 "2014-04-25T20:58:18Z")

</div>

A pull request would be welcome!

Thanks!

---

<div class="post-metadata">

**Author:** ![Hans\_Lellelid](https://avatars.discourse-cdn.com/v4/letter/h/97f17d/32.png) [@Hans\_Lellelid](https://forum.ansible.com/u/Hans_Lellelid)\
**Post date:** [April 28, 2014, 11:34am UTC](https://forum.ansible.com/t/transport-smart-sftp-failures-and-ssh-connections/14897/6 "2014-04-28T11:34:56Z")

</div>

Yes, I will do that once I have a little more testing with this setup.

Hans
