# Different ssh behavior on Linux and MacOSX

**URL:** <https://forum.ansible.com/t/different-ssh-behavior-on-linux-and-macosx/21009>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [March 29, 2016, 4:52pm UTC](https://forum.ansible.com/t/different-ssh-behavior-on-linux-and-macosx/21009 "2016-03-29T16:52:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spice](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@spice](https://forum.ansible.com/u/spice)\
**Post date:** [March 29, 2016, 4:52pm UTC](https://forum.ansible.com/t/different-ssh-behavior-on-linux-and-macosx/21009/1 "2016-03-29T16:52:43Z")

</div>

Ha all  
We use Ansible version 2.0.1.0 on MacOS X 10.11.3 (El Capitan) and Ubuntu 14.04

Ansible on MAcOS installed via #brew install ansible  
Today i’v got a strange behavior on my project  
In our role we change root password and then follow our tasks  
All ok in linux session, playbook wont stop and success, but if we run this playbook in macosx we got auth error

TASK [init\_server : Change root password] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
…  
changed: [LEASEWEB\_NL\_PGGN005] =\> {“append”: false, “changed”: true, “comment”: “root”, “group”: 0, “home”: “/root”, “invocation”: {“module\_args”: {“append”: false, “comment”: null, “createhome”: true, “expires”: null, “force”: false, “generate\_ssh\_key”: null, “group”: null, “groups”: null, “home”: null, “login\_class”: null, “move\_home”: false, “name”: “root”, “non\_unique”: false, “password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”, “remove”: false, “shell”: null, “skeleton”: null, “ssh\_key\_bits”: “2048”, “ssh\_key\_comment”: “ansible-generated on PGGN005”, “ssh\_key\_file”: null, “ssh\_key\_passphrase”: null, “ssh\_key\_type”: “rsa”, “state”: “present”, “system”: false, “uid”: null, “update\_password”: “always”}, “module\_name”: “user”}, “move\_home”: false, “name”: “root”, “password”: “NOT\_LOGGING\_PASSWORD”, “shell”: “/bin/bash”, “state”: “present”, “uid”: 0}

TASK [init\_server : Add public-keys users “XXX”] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /Users/ZZZ/workspace/devops/SGSansible/roles/init\_server/tasks/main.yml:27  
File lookup using /Users/ZZZ/…roles/init\_server/files/id\_rsa16\_XXX.pub as file  
File lookup using /Users/ZZZ/…/roles/init\_server/files/id\_rsa16\_YYY.pub as file  
**\<5.79.100.137\> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 5.79.100.137**  
**\<5.79.100.137\> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 5.79.100.137**  
fatal: [LEASEWEB\_NL\_PGGN005]: UNREACHABLE! =\> {“changed”: false, “msg”: “All items completed”, “results”: [{“item”: "ssh-rsa …, “msg”: **“Authentication failed.”** , “unreachable”: true}]}  
to retry, use: --limit @init.retry

My question is: why ansible on MacOS X creates ssh connection on every playbook step, but don’t do this under linux?

ansible.cfg

# config file for ansible – [http://ansible.com/](http://ansible.com/)

# ==============================================

[defaults]

inventory = inventory

remote\_port = 65321  
roles\_path = roles

host\_key\_checking = False

remote\_user = sgsansible

log\_path = log/ansible.log

private\_key\_file = keys/id\_rsa16\_ansible

[ssh\_connection]

ssh\_args = -o ControlMaster=auto -o ControlPersist=60s  
accelerate\_multi\_key = yes

WBR - Stanislav

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 29, 2016, 5:14pm UTC](https://forum.ansible.com/t/different-ssh-behavior-on-linux-and-macosx/21009/2 "2016-03-29T17:14:57Z")

</div>

Default transport is ‘smart’ which uses paramiko instead of openssh on OS X due to an issue with sshpass crashing the OS X kernel.

If you are NOT using ssh passwords (you are using keys) it should be OK to change the default to ‘ssh’ and it will work just like under Linux.

---

<div class="post-metadata">

**Author:** ![spice](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@spice](https://forum.ansible.com/u/spice)\
**Post date:** [March 30, 2016, 10:14am UTC](https://forum.ansible.com/t/different-ssh-behavior-on-linux-and-macosx/21009/3 "2016-03-30T10:14:10Z")

</div>

Brian, thnx for answer!

Unfortunately, we are using passwords on the initial deployment phase, keys are used later  
For avoiding problem in this case we use simple trick in our playebooks

- name: Finish prepare (restart)  
vars:  
ansible\_ssh\_pass: “{{ new\_generated\_pass\_stored\_in\_host\_vars }}”

WBR - Stanislav

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 31, 2016, 2:01am UTC](https://forum.ansible.com/t/different-ssh-behavior-on-linux-and-macosx/21009/4 "2016-03-31T02:01:59Z")

</div>

Change the default transport to ssh and set `connection: paramiko` for the tasks that use the password and push the keys. That should minimize the issue, for browny points set the connection conditionally to paramiko when localhost is OS X.
