Ansible“无法通过ssh连接到主机

Ansible "Failed to connect to the host via ssh

我正在使用 VirtualBox、Vag运行t 和 Ansible。 在我 运行

之前它工作正常
ssh vagrant@10.10.10.10

并得到以下输出:

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)?

我输入了 "yes",从那以后每次我输入 vagrant provision,我都会得到:

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}

然后我从 ~/.ssh/known_hosts 中删除了生成的密钥,但我一直收到同样的错误。

经过大量时间寻找答案后,我找到了适合我的解决方案。我将以下几行添加到我的 Vagrantfile 并重新加载了 vm

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