首页 文章

Terraform无法通过ssh连接到ec2实例

提问于
浏览
0

我在尝试应用terraform计划时收到的ssh错误没有增加:

ssh:握手失败:ssh:没有通用的密钥交换算法;客户提供:[curve25519-sha256@libssh.org ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 diffie-hellman-group14-sha1 diffie-hellman-group1-sha1],服务器提供:[diffie-hellman-组交换-SHA256]

可以使用指定的ssh键手动连接实例而不会出现问题 . 这是terraform连接字符串:

connection {
    type = "ssh"
    user = "ed209"
    private_key = "${file("${var.aws_key_path}")}"
    timeout = "2m"
    agent = true
    host = "${var.use_public_ip  ? aws_instance.castiron.public_ip : aws_instance.castiron.private_ip}" 
}

连接设置为通过我使用ssh手动连接的相同路由私下连接 . 关于尝试什么的任何想法?

1 回答

  • 0

    file 函数中使用变量的方法是错误的 . 应该:

    private_key = "${file(var.aws_key_path)}"
    

相关问题