# ansible paramiko fails with failed to open a SFTP connection (Channel closed.)

**URL:** <https://forum.ansible.com/t/ansible-paramiko-fails-with-failed-to-open-a-sftp-connection-channel-closed/19180>\
**Category:** Ansible Project\
**Created:** [September 3, 2015, 6:25pm UTC](https://forum.ansible.com/t/ansible-paramiko-fails-with-failed-to-open-a-sftp-connection-channel-closed/19180 "2015-09-03T18:25:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vadud3](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@vadud3](https://forum.ansible.com/u/vadud3)\
**Post date:** [September 3, 2015, 6:25pm UTC](https://forum.ansible.com/t/ansible-paramiko-fails-with-failed-to-open-a-sftp-connection-channel-closed/19180/1 "2015-09-03T18:25:44Z")

</div>

Hi All

I am trying to connect to some freebsd server with custom password prompt. So I need to use paramiko since sshpass hangs on custom password prompt.

With -c paramiko now I get the following error…

$ ansible -vvvv -m ping -c paramiko remote  
 ESTABLISH CONNECTION FOR USER: root on PORT 22 TO remote  
 REMOTE\_MODULE ping  
 EXEC /bin/sh -c ‘mkdir -p /export/home/axisys/.ansible/tmp/ansible-tmp-1441304559.02-141114907172308 && chmod a+rx /export/home/axisys/.ansible/tmp/ansible-tmp-1441304559.02-141114907172308 && echo /export/home/axisys/.ansible/tmp/ansible-tmp-1441304559.02-141114907172308’  
 PUT /tmp/tmpPcx8Lk TO /export/home/axisys/.ansible/tmp/ansible-tmp-1441304559.02-141114907172308/ping  
remote | FAILED =\> failed to open a SFTP connection (Channel closed.)

Any suggestion on how to get a workaround.

Thanks

---

<div class="post-metadata">

**Author:** ![vadud3](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@vadud3](https://forum.ansible.com/u/vadud3)\
**Post date:** [September 10, 2015, 12:36am UTC](https://forum.ansible.com/t/ansible-paramiko-fails-with-failed-to-open-a-sftp-connection-channel-closed/19180/2 "2015-09-10T00:36:30Z")

</div>

Still looking for some help … I still cannot connect to these freebsd servers

---

<div class="post-metadata">

**Author:** ![vadud3](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@vadud3](https://forum.ansible.com/u/vadud3)\
**Post date:** [September 10, 2015, 2:31am UTC](https://forum.ansible.com/t/ansible-paramiko-fails-with-failed-to-open-a-sftp-connection-channel-closed/19180/3 "2015-09-10T02:31:46Z")

</div>

Looks like a pull request is pending to make scp default for paramiko instead of sftp

[https://groups.google.com/forum/#topic/ansible-project/pjFYB8tBGgE](https://groups.google.com/forum/#topic/ansible-project/pjFYB8tBGgE)

Any suggestion how to make scp default for paramiko? I am using ansible 1.7.1

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 10, 2015, 2:38am UTC](https://forum.ansible.com/t/ansible-paramiko-fails-with-failed-to-open-a-sftp-connection-channel-closed/19180/4 "2015-09-10T02:38:30Z")

</div>

Paramiko does not support SCP to my knowledge, only SFTP. To use SCP you need to use the ssh transport and set scp\_if\_ssh.

It sounds to me like you have a busted SFTP configuration. You might try using SFTP manually to see what happens.

---

<div class="post-metadata">

**Author:** ![vadud3](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@vadud3](https://forum.ansible.com/u/vadud3)\
**Post date:** [September 10, 2015, 2:52am UTC](https://forum.ansible.com/t/ansible-paramiko-fails-with-failed-to-open-a-sftp-connection-channel-closed/19180/5 "2015-09-10T02:52:13Z")

</div>

> Paramiko does not support SCP to my knowledge, only SFTP. To use SCP you need to use the ssh transport and set scp\_if\_ssh.

I cannot use ssh since sshpass hangs on these freebsd custom prompts

I see some discussion on adding scp.py into paramiko

> It sounds to me like you have a busted SFTP configuration. You might try using SFTP manually to see what happens.

sftp is not allowed on most of these freebsd systems

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 10, 2015, 11:01am UTC](https://forum.ansible.com/t/ansible-paramiko-fails-with-failed-to-open-a-sftp-connection-channel-closed/19180/6 "2015-09-10T11:01:36Z")

</div>

Then it sounds like you know exactly what the problem is.

---

<div class="post-metadata">

**Author:** ![vadud3](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@vadud3](https://forum.ansible.com/u/vadud3)\
**Post date:** [September 10, 2015, 1:52pm UTC](https://forum.ansible.com/t/ansible-paramiko-fails-with-failed-to-open-a-sftp-connection-channel-closed/19180/7 "2015-09-10T13:52:34Z")

</div>

> Then it sounds like you know exactly what the problem is.

While waiting on that looks like updating the pam config for pam\_unix.so fixes the sshpass hangs  
as explained here

[https://forums.freebsd.org/threads/sshd-custom-password-prompt.38184/](https://forums.freebsd.org/threads/sshd-custom-password-prompt.38184/)

auth required pam\_unix.so no\_warn try\_first\_pass authtok\_prompt=Password:
