terraform远程执行配置器未能连接到ec2实例

时间:2019-12-25 02:51:44

标签: terraform terraform-provider-aws

我正在尝试使用terraform在ec2中安装nginx,并在private_key行上用红色下划线标明“未知令牌:35:23 IDENT文件”

provisioner "remote-exec" {
    inline = [
        "sudo apt-get update -y",
        "sudo apt-get install nginx -y",
        "sudo /etc/init.d/nginx start"
    ]
    connection {
        type="ssh"
        user="ubuntu"
        private_key = file("./remoteexec.pem")
        host=self.public_ip
    }

terraform无法与ec2instance连接,并最终显示如下错误:

timeout - last error: SSH authentication failed (ubuntu@52.87.214.77:22): ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

可能是什么原因?

非常感谢任何帮助 enter image description here

0 个答案:

没有答案