AdnanHodzic / containerized-wordpress-project

Automagically deploy & run WordPress with Let's Encrypt HTTPS encryption using Ansible & Docker
https://foolcontrol.org/?p=2002
GNU General Public License v3.0
42 stars 22 forks source link

Add correct host key error #4

Closed avidsapp closed 5 years ago

avidsapp commented 5 years ago

I keep getting the following error:

UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nThe ECDSA host key for... Add correct host key in /Users/.../.ssh/known_hosts to get rid of this message.

Even after ssh-keygen -R domainoripaddress it still spit back this error. I had it working before and I can ssh into the box just fine. Any ideas?

AdnanHodzic commented 5 years ago

Yes, but this has nothing to do with containerized-wordpress-project but with your SSH config, add StrictHostKeyChecking no to be part of your ~/.ssh/config file to get rid of this error.

avidsapp commented 5 years ago

Ok. I did that and I'm certain I have the right .pem and permissions. I'm now getting this error:

fatal: [domain.name]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ubuntu@domain.name: Permission denied (publickey).\r\n", "unreachable": true}

AdnanHodzic commented 5 years ago

Ok, I'm sorry but this has nothing to do with containerized-wordpress-project as it solely concerns your SSH config and local setup.

I'd advise you to read one of these:

avidsapp commented 5 years ago

In my initial issue message, I mentioned I was able to ssh in just fine so that wasn't the issue. I use a unique ssh config set up. In order to get your automagic ansible solution running, the key dir path must be defined in the hosts file:

[aws-wp] domain.name ansible_ssh_private_key_file=path/to/privatekey

Also, the playbook is failing when rebooting the server, but works upon a second pass. The error:

TASK [AdnanHodzic.system-upgrade : Wait for server to come back up after reboot] **************************************************************** fatal: [domain.name -> localhost]: FAILED! => {"changed": false, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

AdnanHodzic commented 5 years ago

Okay, thanks for bringing that to my attention, as I have multiple SSH keys and I never had to use ansible_ssh_private_key_file. However, next time I'm making changes I'll re-evaluate it and if necessary add it to code.

Regarding server reboot after upgrade, I've noticed that this had tendency to fail. I've also added this to my ToDo list when it comes to containerized-wordpress project and will address it in next version iteration.

Again, thanks and I apologize for the misunderstanding.

avidsapp commented 5 years ago

No worries. I'm still new to Ansible so I was troubleshooting why it wasn't working for me. My SSH keys aren't located in /Users/.../.ssh/ so that is why ansible_ssh_private_key_file path is probably necessary for my use case and may not be worth merging into yours