Issue 1:
ISSUE TYPE

Bug Report

Feature Idea

COMPONENT NAME

modules/core/system/setup.py

ANSIBLE VERSION

ansible 2.2.1.0
config file = /home/k0ste/.ansible.cfg
configured module search path = ['/home/k0ste/ansible/my_modules/']

CONFIGURATION

OS / ENVIRONMENT

GNU/Linux

SUMMARY

If private ssh key chmod is 644, we have error "SSH Error: data could not be sent to the remote host.", if such error was received by non expert, he will not be able to correct it.

STEPS TO REPRODUCE

[k0ste@WorkStation ansible]$ chmod 644 id_rsa

[k0ste@WorkStation ansible]$ ansible -m setup gate.opentech.local --private-key=id_rsa -vvvvv

EXPECTED RESULTS

Print to stderr about "private_key_file is group/world readable".

ACTUAL RESULTS

Using /home/k0ste/.ansible.cfg as config file
Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/system/setup.py
<gate.opentech.local> ESTABLISH SSH CONNECTION FOR USER: k0ste
<gate.opentech.local> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<gate.opentech.local> SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)
<gate.opentech.local> SSH: ANSIBLE_REMOTE_PORT/remote_port/ansible_port set: (-o)(Port=22)
<gate.opentech.local> SSH: ANSIBLE_PRIVATE_KEY_FILE/private_key_file/ansible_ssh_private_key_file set: (-o)(IdentityFile="id_rsa")
<gate.opentech.local> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<gate.opentech.local> SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User=k0ste)
<gate.opentech.local> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<gate.opentech.local> SSH: PlayContext set ssh_common_args: ()
<gate.opentech.local> SSH: PlayContext set ssh_extra_args: ()
<gate.opentech.local> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/tmp/ansible-ssh-%h-%p-%r)
<gate.opentech.local> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=k0ste -o ConnectTimeout=10 -o ControlPath=/tmp/ansible-ssh-%h-%p-%r gate.opentech.local '/bin/sh -c '"'"'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python && sleep 0'"'"''
gate.opentech.local | UNREACHABLE! => {
"changed": false,
"msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh",
"unreachable": true
}

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

ssh connection plugin

ANSIBLE VERSION

spatel@spatel ~ ansible --version
ansible 2.1.0.0
config file =
configured module search path = Default w/o overrides

CONFIGURATION

OS / ENVIRONMENT

Mac OSX Yosemite

SUMMARY

Incorrect SSH key permissions yields an invalid error message

STEPS TO REPRODUCE

If the ssh key that you are using to connect to an instance does not have the following perms

chmod 0400 yourkey.pem

Then the following error is produced

fatal: [52.38.79.205]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}

The host in this case is reachable but the permissions on the key are incorrect, which is what I would expect the error message to say. Running chmod 0400 key.pem fixed the issue.

<52.38.79.205> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="infrastructure/keys/samirpatelme.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/Users/spatel/.ansible/cp/ansible-ssh-%h-%p-%r 52.38.79.205 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1467733345.17-128997728504951 `" && echo ansible-tmp-1467733345.17-128997728504951="` echo $HOME/.ansible/tmp/ansible-tmp-1467733345.17-128997728504951 `" ) && sleep 0'"'"''

EXPECTED RESULTS

Invalid permissions on key file

ACTUAL RESULTS

fatal: [52.38.79.205]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}