ssh error from ad-hoc command

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

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.

please don’t CC me.

please *don't* CC me.

Who did?

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?

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
         Racke

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,

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.

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

Gotcha, thx