kirthan shetty
kirthan shetty

Reputation: 491

AWS Lightsail allow ssh only for specifc IP Adddress

I have created a ubuntu server in aws lightsail, I wanted to allow ssh from only specific IP, I tried using iptables in server but its not working, Is there any way to do it ?

Upvotes: 0

Views: 740

Answers (3)

kirthan shetty
kirthan shetty

Reputation: 491

Now in lightsail they have updated, in network tab you can specify IP address address you want to allow, previously there was no option.

Upvotes: 0

fazlu
fazlu

Reputation: 956

Goto Lightsail panel and in the instances tab you will se your all instances lightsail panel

Open the instance on which you want to apply rule of ip filtering for ssh After clicking on instance you will see the following image: lightsail details

Go to networking tab and scroll to firewall section as shown in image firewall showing opened incoming ports

Click on edit icon infront of ssh port and it will show you some options. One of them will be Restrict to IP address as shown below. On choosing the option it will show you field to add ip address. firewall options to edit port open state

After adding your ip, click save and you are good to go.

Upvotes: 2

Chris Williams
Chris Williams

Reputation: 35188

This is not possible via any kind of security groups for Lightsail. Its firewall rules are a basic allow a rule to the world.

I would suggest allowing SSH via Lightsail, and then running

sudo iptables -A INPUT -p tcp -s X.X.X.X/32 --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT

Replace the X.X.X.X with your IP address to restrict SSH access to only you.

Upvotes: 0

Related Questions