# ssh to FreeBSD is hanging

**URL:** <https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737>\
**Category:** Ansible Project\
**Created:** [October 21, 2013, 8:27pm UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737 "2013-10-21T20:27:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://forum.ansible.com/u/Brian_Candler)\
**Post date:** [October 21, 2013, 8:27pm UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/1 "2013-10-21T20:27:48Z")

</div>

I’m stuck on this; I can’t see the way forward.

I’ve installed FreeBSD 9.2 in a VM. I can ssh to it. I’ve also set “PermitRootLogins yes”, so I can login directly either as a normal user or as root.

---

<div class="post-metadata">

**Author:** ![Scott\_Sturdivant](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@Scott\_Sturdivant](https://forum.ansible.com/u/Scott_Sturdivant)\
**Post date:** [October 22, 2013, 1:11am UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/2 "2013-10-22T01:11:21Z")

</div>

Not sure how the inner workings of providing a password (and needing sshpass) go, but do make sure you set ansible\_python\_interpreter as suggested in #205 (and here: [http://www.ansibleworks.com/docs/faq.html#how-do-i-handle-python-pathing-not-having-a-python-2-x-in-usr-bin-python-on-a-remote-machine](http://www.ansibleworks.com/docs/faq.html#how-do-i-handle-python-pathing-not-having-a-python-2-x-in-usr-bin-python-on-a-remote-machine)) Perhaps once that’s resolved, it’ll be able to find sshpass.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://forum.ansible.com/u/Brian_Candler)\
**Post date:** [October 22, 2013, 8:21am UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/3 "2013-10-22T08:21:11Z")

</div>

I found ansible\_python\_interpreter. However that doesn’t make any difference to the sshpass problem.

If I kill the local-side sshpass process, then it terminates, but ansible doesn’t show the output collected so far from ssh -vvv. This doesn’t help. All it says is:

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [October 22, 2013, 2:59pm UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/4 "2013-10-22T14:59:27Z")

</div>

try using -c paramiko in the commandline, this will help narrow down the  
source of the issues.

---

<div class="post-metadata">

**Author:** ![john2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@john2](https://forum.ansible.com/u/john2)\
**Post date:** [October 30, 2013, 7:58pm UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/5 "2013-10-30T19:58:54Z")

</div>

I had the same problem. -c paramiko worked for me the first time. But then when I switched from using root to the user, that seemed to hang to, but later in the process.

I had already uploaded SSH keys in my initial playbook, so I switched back to using the keys and dropped the -c paramiko, and everything worked. I wish I knew more to help diagnose the problem.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [October 31, 2013, 2:49pm UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/6 "2013-10-31T14:49:44Z")

</div>

@john, using -vvvv with the problem would give you good diagnostic output, just guessing here but it sounds like it was waiting for a prompt in your case, either for password or known\_hosts.

---

<div class="post-metadata">

**Author:** ![Phil\_Regnauld](https://avatars.discourse-cdn.com/v4/letter/p/6bbea6/32.png) [@Phil\_Regnauld](https://forum.ansible.com/u/Phil_Regnauld)\
**Post date:** [September 11, 2015, 8:11am UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/7 "2015-09-11T08:11:03Z")

</div>

Hi,

I have the same problem as the original poster (Hi, bcandler!).

Same issue with sshpass hanging. Didn’t try with paramiko.

-vvv doesn’t help here, it just hangs, and ctrl-c shows this:

SSH password:  
\<some.machine.here\> ESTABLISH CONNECTION FOR USER: admin  
\<some.machine.here\> REMOTE\_MODULE ping  
\<some.machine.here\> EXEC [‘sshpass’, ‘-d7’, ‘ssh’, ‘-C’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/regnauld/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘Port=2222’, ‘-o’, ‘GSSAPIAuthentication=no’, ‘-o’, ‘PubkeyAuthentication=no’, ‘-o’, ‘User=admin’, ‘-o’, ‘ConnectTimeout=10’, ‘some.machine.here’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1441958968.83-124161391615192 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1441958968.83-124161391615192 && echo $HOME/.ansible/tmp/ansible-tmp-1441958968.83-124161391615192’”]

CTRL-C here

^CTraceback (most recent call last):  
File “/opt/local/bin/ansible”, line 226, in   
(runner, results) = cli.run(options, args)  
File “/opt/local/bin/ansible”, line 200, in run  
results = runner.run()  
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 1200, in run  
results = [self.\_executor(h, None) for h in hosts]  
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 532, in \_executor  
exec\_rc = self.\_executor\_internal(host, new\_stdin)  
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 629, in \_executor\_internal  
return self.\_executor\_internal\_inner(host, self.module\_name, self.module\_args, inject, port, complex\_args=complex\_args)  
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 815, in \_executor\_internal\_inner  
result = handler.run(conn, tmp, module\_name, module\_args, inject, complex\_args)  
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/action\_plugins/normal.py”, line 57, in run  
return self.runner.\_execute\_module(conn, tmp, module\_name, module\_args, inject=inject, complex\_args=complex\_args)  
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 411, in \_execute\_module  
tmp = self.\_make\_tmp\_path(conn)  
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 1020, in \_make\_tmp\_path  
result = self.\_low\_level\_exec\_command(conn, cmd, None, sudoable=False)  
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/ **init**.py”, line 948, in \_low\_level\_exec\_command  
in\_data=in\_data)  
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/runner/connection\_plugins/ssh.py”, line 285, in exec\_command  
rfd, wfd, efd = select.select(rpipes, , rpipes, 1)  
KeyboardInterrupt

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://forum.ansible.com/u/Brian_Candler)\
**Post date:** [September 14, 2015, 1:05pm UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/8 "2015-09-14T13:05:22Z")

</div>

I was rarely able to get anything useful with `-vvvv`, especially if the far end gave some unexpected prompt or there was some problem with sshpass, because the stdout/stderr is lost.

Try following the debugging process I outlined earlier:

- assemble the full ssh command line from the [‘pieces’, ‘shown’, ‘in’, ‘the’, ‘debug’, ‘output’], run it manually, and look for errors. Make sure you are including the sshpass part of the command line
- replace sshpass with a wrapper script which redirects stderr to a tempfile and execs the real sshpass; then run ansible
- make sure you have paramiko installed and used (I believe it’s used by default now)
- try setting up ssh key authentication, and making ansible talk to the FreeBSD box with that instead of password authentication

If the last case works then it’s a bit painful because it means you can’t use ansible to bootstrap the ssh key authentication - but at least it may work after that step.

HTH, Brian.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://forum.ansible.com/u/Brian_Candler)\
**Post date:** [September 14, 2015, 1:09pm UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/9 "2015-09-14T13:09:14Z")

</div>

Now I think about it, I may never have gotten to the bottom of this, and just gave up using password authentication with FreeBSD. If you can replicate it like this:

echo “xyzzy” \>ert  
sshpass -f ert ssh -vvv brian@bsdtest echo hi

then that shows that it’s an sshpass problem, rather than an ansible one.

Regards, Brian.

---

<div class="post-metadata">

**Author:** ![Phil\_Regnauld](https://avatars.discourse-cdn.com/v4/letter/p/6bbea6/32.png) [@Phil\_Regnauld](https://forum.ansible.com/u/Phil_Regnauld)\
**Post date:** [September 14, 2015, 1:21pm UTC](https://forum.ansible.com/t/ssh-to-freebsd-is-hanging/13737/10 "2015-09-14T13:21:37Z")

</div>

candlerb (b.candler) writes:

> Now I think about it, I may never have gotten to the bottom of this, and  
> just gave up using password authentication with FreeBSD. If you can  
> replicate it like this:
> 
> echo "xyzzy" \>ert  
> sshpass -f ert ssh -vvv brian@bsdtest echo hi  
> \<hang\>
> 
> then that shows that it's an sshpass problem, rather than an ansible one.

&nbsp;&nbsp;I did find it was an sshpass problem, and there's a bug registered  
&nbsp;&nbsp;for it. It's a problem with PAM:

&nbsp;&nbsp;[https://github.com/ansible/ansible/issues/11565](https://github.com/ansible/ansible/issues/11565)
