# ssh error from ad-hoc command

**URL:** <https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562>\
**Category:** Ansible Project\
**Created:** [February 3, 2021, 6:21pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562 "2021-02-03T18:21:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ken\_Cheng](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@Ken\_Cheng](https://forum.ansible.com/u/Ken_Cheng)\
**Post date:** [February 3, 2021, 6:21pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/1 "2021-02-03T18:21:03Z")

</div>

hi,

i’m sorry if this was already covered but why does ansible’s ping module giving me an ssh error?

i installed ansible version 2.9.17 on a centos vm. that vm can ping & ssh to my test destination router from the command line. for some reason “ansible lab -m ping” gives me an ssh error. my /etc/ansible/hosts file looks ok (i just started with ansible this monday). what am i missing?

[xyz@centos inventory]$ ansible lab -m ping  
The authenticity of host ‘10.116.16.50 (10.116.16.50)’ can’t be established.  
RSA key fingerprint is SHA256:iAuKXO+RbJ+p6sODXTI4c3Uo8WArXLE+/XQSbWU9vWw.  
Are you sure you want to continue connecting (yes/no/[fingerprint])? lab891 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@ WARNING: UNPROTECTED PRIVATE KEY FILE! @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nPermissions 0644 for ‘/home/xyz/.ssh/known\_hosts’ are too open.\r\nIt is required that your private key files are NOT accessible by others.\r\nThis private key will be ignored.\r\nLoad key "/home/xyz/.ssh/known\_hosts": bad permissions\r\nxyz@10.116.16.50: Permission denied (publickey,keyboard-interactive,password).”,  
“unreachable”: true  
}  
[xyz@centos inventory]$ ping 10.116.16.50

PING 10.116.16.50 (10.116.16.50) 56(84) bytes of data.  
64 bytes from 10.116.16.50: icmp\_seq=1 ttl=251 time=0.635 ms  
64 bytes from 10.116.16.50: icmp\_seq=2 ttl=251 time=0.719 ms  
^C

[xyz@centos inventory]$ cat /etc/ansible/hosts

[lab]  
10.116.16.50

---

<div class="post-metadata">

**Author:** ![Antony\_Stone](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Antony\_Stone](https://forum.ansible.com/u/Antony_Stone)\
**Post date:** [February 3, 2021, 6:47pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/2 "2021-02-03T18:47:40Z")

</div>

> i'm sorry if this was already covered but why does ansible's ping module  
> giving me an ssh error?
> 
> i installed ansible version 2.9.17 on a centos vm. that vm can ping & ssh  
> to my test destination router from the command line. for some reason  
> "ansible lab -m ping" gives me an ssh error. my /etc/ansible/hosts file  
> looks ok (i just started with ansible this monday). what am i missing?

Not to put too fine a point on it, I think what you are missing is reading the  
error message:

> Permissions 0644 for '/home/xyz/.ssh/known\_hosts' are too open.  
> It is required that your private key files are NOT accessible by others.  
> This private key will be ignored.

So, change that mode 644 to 600 and all should be fine.

Antony.

---

<div class="post-metadata">

**Author:** ![nagaraju\_balusa](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@nagaraju\_balusa](https://forum.ansible.com/u/nagaraju_balusa)\
**Post date:** [February 3, 2021, 6:48pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/3 "2021-02-03T18:48:44Z")

</div>

please _don’t_ CC me.

---

<div class="post-metadata">

**Author:** ![Antony\_Stone](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Antony\_Stone](https://forum.ansible.com/u/Antony_Stone)\
**Post date:** [February 3, 2021, 6:51pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/4 "2021-02-03T18:51:10Z")

</div>

> please \*don't\* CC me.

Who did?

---

<div class="post-metadata">

**Author:** ![Ken\_Cheng](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@Ken\_Cheng](https://forum.ansible.com/u/Ken_Cheng)\
**Post date:** [February 3, 2021, 7:05pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/5 "2021-02-03T19:05:52Z")

</div>

hi Antony,

i changed the permissions of my ssh config file with **chmod 600 ~/.ssh/config** but it didnt help. why would i get an ssh error when i’m trying to ping?

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [February 3, 2021, 7:07pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/6 "2021-02-03T19:07:23Z")

</div>

> hi Antony,
> 
> i changed the permissions of my ssh config file with \*chmod 600 ~/.ssh/config \*but it didnt help. why would i get an ssh  
> error when i'm trying to ping?

Because an Ansible ping is really testing the (SSH) connection to the target machine.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Tej-Singh-Rana](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tej-Singh-Rana](https://forum.ansible.com/u/Tej-Singh-Rana)\
**Post date:** [February 3, 2021, 7:26pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/7 "2021-02-03T19:26:39Z")

</div>

It’s a permission denied error. Enable the password authentication in the target server. Or add parameters in the ansible’s hosts ansible\_ssh\_pass=password.

Regards,

---

<div class="post-metadata">

**Author:** ![Antony\_Stone](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Antony\_Stone](https://forum.ansible.com/u/Antony_Stone)\
**Post date:** [February 3, 2021, 7:41pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/8 "2021-02-03T19:41:42Z")

</div>

> hi Antony,
> 
> i changed the permissions of my ssh config file with \*chmod 600  
> ~/.ssh/config \*but it didnt help.

Try changing the permissions on the file mentioned in the error message.

Antony.

---

<div class="post-metadata">

**Author:** ![Joseph\_Alexander](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@Joseph\_Alexander](https://forum.ansible.com/u/Joseph_Alexander)\
**Post date:** [February 3, 2021, 7:48pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/9 "2021-02-03T19:48:19Z")

</div>

your private key (id\_rsa) has the wrong permissions. It needs to be 0600 and you:you and having said that the .ssh/ directory its in needs to be 0700 and also owned by you:you

---

<div class="post-metadata">

**Author:** ![Ken\_Cheng](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@Ken\_Cheng](https://forum.ansible.com/u/Ken_Cheng)\
**Post date:** [February 4, 2021, 1:09pm UTC](https://forum.ansible.com/t/ssh-error-from-ad-hoc-command/34562/10 "2021-02-04T13:09:33Z")

</div>

Gotcha, thx
