【问题标题】:Unable to connect through SSH无法通过 SSH 连接
【发布时间】:2021-04-29 12:40:46
【问题描述】:

我试图通过 terraform 部署一个 aws ubuntu 实例,但我无法访问它。我只希望我的 ip 能够访问它,所以这是我用于安全组的代码:

resource "aws_security_group" "security" {
name        = "security"
description = "Allow TLS inbound traffic"
vpc_id      = aws_vpc.my-vpc.id

ingress {
description      = "This is SSH"
from_port        = 22
to_port          = 22
protocol         = "tcp"
cidr_blocks      = ["here is my ip/32"]}

egress {
description      = "Any"
from_port        = 0
to_port          = 0
protocol         = "-1"
cidr_blocks      = ["0.0.0.0/0"]}}

我得到的错误是“连接超时”

我尝试在 AWS 控制台中做同样的事情,但仍然遇到同样的问题。 我已配置 .pem 密钥和 aws 凭据。

我在 > Main-Key.pem>> 进入我的 WSL 终端。

【问题讨论】:

  • 嗨 Rareex00,Terraform 日志是否表明在创建基础架构时存在任何问题?安全组是否可能未配置或未与实例关联?
  • Terraform 日志没有显示任何问题。此外,如果我在部署实例后检查实例的安全部分,它会显示我创建的安全组以及规则。
  • 如果您在 Web 控制台中编辑安全组并为“我的 IP”添加一条规则,让亚马逊为您添加您的 IP,会发生什么情况?
  • 我就是这样做的
  • 您可能缺少 IGW,即,如果您未将 IGW 分配给 VPC,通常会发生这种情况,尤其是在您未使用默认 VPC 时。

标签: amazon-web-services ssh terraform


【解决方案1】:

是否可以显示错误输出? 你有任何错误

vpc_id      = aws_vpc.my-vpc.id
and 
cidr_blocks      = ["here is my ip/32"]}

【讨论】:

    猜你喜欢
    • 2020-05-12
    • 2021-08-28
    • 2020-07-27
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多