# failing to connect through ssh

**URL:** <https://forum.ansible.com/t/failing-to-connect-through-ssh/25298>\
**Category:** Ansible Project\
**Tags:** gcp\
**Created:** [August 21, 2017, 3:54pm UTC](https://forum.ansible.com/t/failing-to-connect-through-ssh/25298 "2017-08-21T15:54:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gcpconsole](https://avatars.discourse-cdn.com/v4/letter/g/e19adc/32.png) [@gcpconsole](https://forum.ansible.com/u/gcpconsole)\
**Post date:** [August 21, 2017, 3:54pm UTC](https://forum.ansible.com/t/failing-to-connect-through-ssh/25298/1 "2017-08-21T15:54:31Z")

</div>

I used the below example to execute from GIT  
[https://github.com/GoogleCloudPlatform/compute-ansible-gluster](https://github.com/GoogleCloudPlatform/compute-ansible-gluster)

**I am getting the following error:**

```auto
fatal: [35.184.19.164]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nIT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\r\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\r\nIt is also possible that a host key has just been changed.\r\nThe fingerprint for the ECDSA key sent by the remote host is\n05:88:4d:7f:50:ec:21:38:12:d9:b8:0f:b1:29:0c:33.\r\nPlease contact your system administrator.\r\nAdd correct host key in /root/.ssh/known_hosts to get rid of this message.\r\nOffending ECDSA key in /root/.ssh/known_hosts:17\r\nChallenge/response authentication is disabled to avoid man-in-the-middle attacks.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n", "unreachable": true}
fatal: [35.202.50.199]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nIT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\r\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\r\nIt is also possible that a host key has just been changed.\r\nThe fingerprint for the ECDSA key sent by the remote host is\n23:8a:d0:e0:50:be:97:9a:c7:64:c1:24:b1:f2:42:1f.\r\nPlease contact your system administrator.\r\nAdd correct host key in /root/.ssh/known_hosts to get rid of this message.\r\nOffending ECDSA key in /root/.ssh/known_hosts:13\r\nChallenge/response authentication is disabled to avoid man-in-the-middle attacks.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n", "unreachable": true}
fatal: [35.193.161.39]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nIT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\r\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\r\nIt is also possible that a host key has just been changed.\r\nThe fingerprint for the ECDSA key sent by the remote host is\nc1:65:32:ac:b6:97:a9:ec:55:38:ba:ac:49:1e:5e:6e.\r\nPlease contact your system administrator.\r\nAdd correct host key in /root/.ssh/known_hosts to get rid of this message.\r\nOffending ECDSA key in /root/.ssh/known_hosts:12\r\nChallenge/response authentication is disabled to avoid man-in-the-middle attacks.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n", "unreachable": true}
        to retry, use: --limit @/home/gcpconsole/compute-ansible-gluster/gluster.retry

PLAY RECAP ************************************************************************************************************
127.0.0.1 : ok=7 changed=6 unreachable=0 failed=0   
35.184.19.164 : ok=0 changed=0 unreachable=1 failed=0   
35.193.161.39 : ok=0 changed=0 unreachable=1 failed=0   
35.202.232.100 : ok=0 changed=0 unreachable=1 failed=0   
35.202.50.199 : ok=0 changed=0 unreachable=1 failed=0  

```

```auto

```

```auto
***********************************************************************************************************************************************

```

```auto
I have added all the necessary key in the GCP console....

```

```auto

```

```auto

```

```auto
Please help me soving this

```

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 22, 2017, 3:47am UTC](https://forum.ansible.com/t/failing-to-connect-through-ssh/25298/2 "2017-08-22T03:47:13Z")

</div>

Hi

As the errors state this is a problem with how the SSH keys are set-up.  
The github URL has quite elaborate documentation (as usual with Google tools), and it includes a URL to an even more elaborate page specifically for setting up SSH keys (for completeness: [https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys?hl=en](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys?hl=en)).  
Check those steps again.

One hint could be that apparently you’re running this playbook as root.  
Could it be that you’ve set up SSH keys in a different/your account, but that you are running the playbook with ‘sudo’? That would explain things.  
If that’s the case: don’t do that. Run the playbook as the user that you’ve setup SSH keys for.

Dick

---

<div class="post-metadata">

**Author:** ![gcpconsole](https://avatars.discourse-cdn.com/v4/letter/g/e19adc/32.png) [@gcpconsole](https://forum.ansible.com/u/gcpconsole)\
**Post date:** [August 22, 2017, 6:34am UTC](https://forum.ansible.com/t/failing-to-connect-through-ssh/25298/3 "2017-08-22T06:34:25Z")

</div>

Hi Dick

Thanks a lot for your reply Dick… I tied the same steps as you have suggested in the link, still the error is coming and i have also tried running the playbook as user rather than root, but still error is coming.

```auto
TASK [Gathering Facts] *****************************************************************************************
fatal: [35.202.234.156]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added '35.202.234.156' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n", "unreachable": true}
fatal: [35.202.50.199]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added '35.202.50.199' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n", "unreachable": true}
fatal: [35.202.232.100]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added '35.202.232.100' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n", "unreachable": true}
fatal: [35.184.19.164]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added '35.184.19.164' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n", "unreachable": true}
 [WARNING]: Could not create retry file '/home/gcpconsole/compute-ansible-gluster/gluster.retry'.
[Errno 13] Permission denied: u'/home/gcpconsole/compute-ansible-gluster/gluster.retry'

PLAY RECAP *****************************************************************************************************
127.0.0.1 : ok=7 changed=6 unreachable=0 failed=0   
35.184.19.164 : ok=0 changed=0 unreachable=1 failed=0   
35.202.232.100 : ok=0 changed=0 unreachable=1 failed=0   
35.202.234.156 : ok=0 changed=0 unreachable=1 failed=0   
35.202.50.199 : ok=0 changed=0 unreachable=1 failed=0   

```

```auto
:-( 

```

```auto

```

```auto
Thanks in advance

```

```auto
chandana

```

```auto

```

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 22, 2017, 9:24am UTC](https://forum.ansible.com/t/failing-to-connect-through-ssh/25298/4 "2017-08-22T09:24:28Z")

</div>

Hi

> Hi Dick
> 
> Thanks a lot for your reply Dick..... I tied the same steps as you have suggested in the link, still the error is coming and i have also tried running the playbook as user rather than root, but still error is coming.

Actually, it is a different error, and also a warning (at the end).  
To fix one thing at a time - can you make sure the permissions are  
fixed, and then run the playbook again?

Dick
