# ssh difference between ansible ad-hoc and ansible-playbook for localhost

**URL:** <https://forum.ansible.com/t/ssh-difference-between-ansible-ad-hoc-and-ansible-playbook-for-localhost/21951>\
**Category:** Ansible Project\
**Created:** [July 7, 2016, 7:03pm UTC](https://forum.ansible.com/t/ssh-difference-between-ansible-ad-hoc-and-ansible-playbook-for-localhost/21951 "2016-07-07T19:03:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [July 7, 2016, 7:03pm UTC](https://forum.ansible.com/t/ssh-difference-between-ansible-ad-hoc-and-ansible-playbook-for-localhost/21951/1 "2016-07-07T19:03:48Z")

</div>

I noticed in troubleshooting SSH authentication that there is a difference between ansible ad-hoc and ansible-playbook in terms of SSH for localhost.

Specifically, I was able to get a playbook targeted at localhost to work but not ansible ad-hoc command targeted at localhost.

---

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [July 7, 2016, 7:08pm UTC](https://forum.ansible.com/t/ssh-difference-between-ansible-ad-hoc-and-ansible-playbook-for-localhost/21951/2 "2016-07-07T19:08:02Z")

</div>

To be more specific, ad-hoc command checks in ~/.ssh/authorized key whereas playbook does not. I didn’t specific any user in the playbook whereas I try to run as root/ubuntu/none with ad-hoc (-u).

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [July 7, 2016, 7:37pm UTC](https://forum.ansible.com/t/ssh-difference-between-ansible-ad-hoc-and-ansible-playbook-for-localhost/21951/3 "2016-07-07T19:37:59Z")

</div>

That sounds really - odd.

It sounds silly, but are you \_sure\_ ansible and ansible-playbook are  
at the same version?

ansible --version  
ansible-playbook --version

Maybe there's some symlink spaghetti going on or something??

If not, that sounds like a bug, I'd file an issue.

---

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [July 7, 2016, 8:56pm UTC](https://forum.ansible.com/t/ssh-difference-between-ansible-ad-hoc-and-ansible-playbook-for-localhost/21951/4 "2016-07-07T20:56:17Z")

</div>

Apparently ansible-playbook is a symlink on this system; I had /usr/bin/ansible owned by the group ansible before but I changed it back to root for testing & got so result. What is more weird is that if ansible-playbook is just a symlink why is the behavior different?

`  
root@ip-172-17-0-237:/etc/ansible# ansible --version  
ansible 2.1.0.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = Default w/o overrides

root@ip-172-17-0-237:/etc/ansible# ansible-playbook --version  
ansible-playbook 2.1.0.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = Default w/o overrides

root@ip-172-17-0-237:/etc/ansible# ll /usr/bin/ansible  
-rwxr-xr-x 1 root ansible 4201 May 25 13:03 /usr/bin/ansible\*

root@ip-172-17-0-237:/etc/ansible# ll /usr/bin/ansible-playbook  
lrwxrwxrwx 1 root root 7 May 25 13:03 /usr/bin/ansible-playbook → ansible\*

`

I checked on another older version and ansible-playbook is a script:

`

✘ antho@stratus  ~/.ssh  which ansible  
/usr/bin/ansible  
antho@stratus  ~/.ssh  which ansible-playbook  
/usr/bin/ansible-playbook  
antho@stratus  ~/.ssh  ll /usr/bin/ansible-playbook  
-rwxr-xr-x+ 1 antho antho 3.9K May 22 23:18 /usr/bin/ansible-playbook  
antho@stratus  ~/.ssh  ansible --version  
ansible 2.0.2.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = Default w/o overrides  
antho@stratus  ~/.ssh  ansible-playbook --version  
ansible-playbook 2.0.2.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = Default w/o overrides  
`

btw here’s the playbook i used for testing; nothing fancy:

`  
ot@ip-172-17-0-237:/etc/ansible# cat testing/test\_var.yml
