简体   繁体   中英

Ansible "Failed to connect to the host via ssh

I am working with VirtualBox, Vagrant and Ansible. It worked fine until I ran

ssh vagrant@10.10.10.10

and got the following output:

The authenticity of host '10.10.10.10 (10.10.10.10)' can't be established.
ECDSA key fingerprint is
SHA256:IIbQq8qenKqUEpurYCMbbaRBCHXEgWK4Br7KSusmyw4.
Are you sure you want to continue connecting (yes/no)?

I typed "yes", and since then every time I type vagrant provision , I keep getting:

fatal: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added '10.10.10.10' (ECDSA) to the list of known hosts.\r\nPermission denied ().\r\n", "unreachable": true}

I then removed the generated key from ~/.ssh/known_hosts , but I keep getting the same error.

After a ton of time searching for the answer I found the solution that worked for me. I added the following few lines to my Vagrantfile and reloaded vm

ansible.raw_arguments = [
"--private-key=~/path/to/.vagrant/machines/default/virtualbox/private_key"
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM