簡體   English   中英

Terraform AWS 如何使用安全組的另一個端口 SSH 22

[英]Terraform AWS How use Security Group's port another that 22 for SSH

我想為 SSH 使用另一個 SG 的端口,而不是 22,但我得到了錯誤。 例如:

resource "aws_security_group" "ws_sg" {
    name = "WS SG"
    vpc_id = "${aws_vpc.ws_net.id}"
    tags = {
      "Name" = "WS SG"
    }
}

resource "aws_security_group_rule" "inbound_ssh" {
    from_port = 28
    protocol = "TCP"
    security_group_id = aws_security_group.ws_sg.id
    to_port = 22
    type = "ingress"
    cidr_blocks = [ "0.0.0.0/0" ]
}

resource "aws_security_group_rule" "egress" {
    from_port = 0
    protocol = "all"
    security_group_id = aws_security_group.ws_sg.id
    to_port = 0
    type = "egress"
    cidr_blocks = [ "0.0.0.0/0" ]
}

怎么修?

PS Maybee,這是因為我有免費帳戶嗎?

你混淆了你的端口。 代替

   from_port = 28
   to_port = 22

它應該是:

   from_port = 22
   to_port = 28

我有些趕忙。 不工作

我嘗試將 PuTTY 連接到端口 28 並得到:網絡錯誤:連接被拒絕

如果我將 SG 的入站更改為 SSH 22,則毫無問題地連接到端口 22。 但是如果我改變22-28,那就是所有家伙)

明白了。 我想轉發端口,以便 SSH 具有標准 22 以外的端口。安全組只需打開端口即可。 誤導“from_port”“to_port”。

總的來說,我決定簡單。 在該實例中,例如,我將“端口 28”添加到 /ets/ssh/sshd_config 並在安全組中打開它。 就這樣。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM