ssh to FreeBSD is hanging

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.

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) Perhaps once that’s resolved, it’ll be able to find sshpass.

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:

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

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.

@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.

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

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.

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.

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.

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

  https://github.com/ansible/ansible/issues/11565