我正在尝试使用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
。
可能是什么原因?