skip to Main Content

I want using another SG’s port for SSH, not 22, but i get error.
For example:

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" ]
}

How fix it?

P.S. Maybee, this happing because i have free account?

2

Answers


  1. Chosen as BEST ANSWER

    I some hastened. Not working

    I tried connect PuTTY to port 28 and i got: Network error: Connection refused

    If i change SG's inbounds for SSH 22, then connect to port 22 without problem. But if i change 22-28, that's all guys )


  2. You mixed up your ports. Instead of

       from_port = 28
       to_port = 22
    

    it should be:

       from_port = 22
       to_port = 28
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search