How do I secure access to a AWS classic EC2 machine from my LAN

Rpj

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#ec2-classic-security-groups

How do I secure access to a AWS classic EC2 machine from my LAN whose IP could change on a daily basis since we are connected to a local ISP provider

Naveen Vijay

The access restriction for EC2 Classic works at 2 levels one at the OS based User Name and Password ( SSH key if linux based instance ) and then Security Group.

Given that you have told that the IPs tend to change on a daily basis; these are the alternatives you can try

Manual Process :

  • Get the IP range from your ISP and put that to your allowed IP Range for Instance's SG.

Script Based Process :

  • You can write a simple cron script, which can obtain your public IP and go and change the specified Instance's Security group everyday

Python - Boto Script to Perform the Daily SG Public IP Change for SSH-22 to your public IP address

import boto
import urllib2

def get_public_ip():
    ext_ip = urllib2.urlopen("http://curlmyip.com").read()
    return ext_ip.strip()

sg_name = '<your security group name>' #enter your Security Group's NAME

ec2 = boto.connect_ec2()
sg = ec2.get_all_security_groups(groupnames=sg_name)
sg = sg[0]

#remove existing 22 SSH rules - old CIDR IP
for rule in sg.rules:
    if str(rule.from_port) == '22':
        ec2.revoke_security_group(group_name=sg_name,
                                  ip_protocol='tcp',
                                  from_port='22',
                                  to_port='22',
                                  cidr_ip=rule.grants[0])

#Authorize today's Public IP
ec2.authorize_security_group(group_name=sg_name,
                             ip_protocol='tcp',
                             from_port='22',
                             to_port='22',
                             cidr_ip=get_public_ip()+"/32")

Using 3rd Party Tools :

You can use 3rd Party provided like Dome9; they provide services like you can obtain the session / instance to be accessible for specific amount of time etc. Check whether they offer a solution for your scenario.

Their Product : Dome9 gives You 1-Click Secure Access To Any Server, Anywhere

Keep recycling your credentials for the instances; this for additional security.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I secure my firestore for anonymous access of product data

How do I tell all my AWS EC2 instances to pull from git / codecommit?

How do I access the web GUI of my NiFi instance running on an AWS machine?

How do I disconnect from my EC2 Instance?

How do I run the mysql command from the command line of an AWS RDS instance that is separate from the EC2 instance I am on?

How can I access my AWS MSK managed kafka queue from my local machine and EC2 instances in other regions

Not able to connect to AWS DocumentDB from my ubuntu EC2 machine

How do I establish MYSQL connection to AWS ec2 instance from local machine?

AWS EC2 - Secure connection from specific domain to database?

How do I copy data from AWS S3 to EC2 in a CloudFormation template?

How to hit an AWS EC2 instance private IP from company on premise machine brwoser to access application running on the EC2

Access ec2 instaces in AWS with private hostname from remote machine in a openvpn network

Do I really need a VPC if I can use AWS security groups to secure my MongoDB EC2 instance?

How to have AWS ECS automatically map ports of my container to the host machine(EC2)

How do I get access to the EC2 my developer has created?

How to correctly/safely access parameters from AWS SSM Parameter store for my Python script on EC2 instance?

How do I remotely access my ubuntu virtual machine?

My colleague often shuts down my machine through the LAN - how do I prevent it?

how can I access my server from outside of my lan?

How do I access Azure Storage "(Classic)" from an Azure Function

How can I give multiple vpc access to a classic ec2 instance using security groups

How to Access AWS EC2 docker tomcat instance running inside jenkins docker instance from my local browser

How to run a Python code on AWS EC2 and write a csv file from the server to my local machine?

How do I get to my spinnaker dashboard after Installing minnaker on my aws ec2

How can I use kubectl commands on my cluster hosted on ec2 instances from my local machine without ssh

How do I install JDK 17 on my AWS AMI Ec2 instance?

Access AWS RDS from local machine without EC2

aws - secrets manager - how to secure secrets when I want to access from ec2?

EC2 instance on my machine. I have lost key pair. But in Aws secret manager there is secret value of .ppk file. How i use that to login to EC2