Cannot access instances of openstack on AWS - amazon-web-services

I've openstack(single node) installed on an AWS instance. I can log into the openstack dashboard and I'm also able to spawn instances but, I'm not able to connect via SSH or ping those instances.
In the security group setting section, I've allowed all types of protocols for the instances.

SSH into the AWS instance first, from there you can access the openstack instances.
If you need your spawned instances to be available over the public internet, you need to manage your public (floating) IPs.

Related

Turn on and off ssh access to EC2

I want the EC2 to be accessible only through session manager.
Originally I launched one, ssh into it, installed the ssm-manager, but then I found out I can't replace its ENI with a non-public-facing ENI.
So then I tried launching one with an ENI with only a private IP, associate a public EIP to it, but I fail to ssh into the machine, it keeps timing out.
After quite a lot of experimenting around I just can't find the solution to this problem, so here I am.
What do I need?
I want to know how to create an EC2 instance that has NO PUBLIC IP and NO PUBLIC SUBNET.
Attach a public IP to it and config it to work
SSH into it, install SSM agent
and then disable ALL PUBLIC FACING networking.
any suggestions? guides?
thanks
Create an AMI that has the SSM agent already installed and configured, or pick one of the existing AMIs that have SSM agent pre-installed. Then launch your EC2 instances from that AMI.

Using Session Manager to connect RDS without having EC2 instance

When I go through the documents, using session manager we can connect instance in private subnet without having bastion host itself [direct port forwarding from local to private ec2].
But in RDS case, even though we are making connection using session manager we need a EC2 instance in between local and private RDS.
Could you anyone explain me why it is like that? please share some document that explains that as well.
AWS Systems Manager Session Manager allows you to connect to an instance in a Private Subnet because the instance is actually running an 'SSM Agent'. This piece of code creates an outbound connection to the AWS Systems Manager service.
Then, when you request a connection to the instance, your computer connects to the AWS Systems Manager service, which forwards the request to the agent on the instance. The AWS Systems Manager service is effectively acting as a Bastion for your connection.
AWS Systems Manager Session Manager cannot provide a connection to an Amazon RDS server because there is no ability to 'login' to an Amazon RDS server. Given that your RDS server is running in a Private Subnet, it is therefore necessary to port-forward via an EC2 instance in the same VPC as the RDS server. This can be done via a traditional Bastion EC2 instance in a Public Subnet, or via an EC2 instance in a Private Subnet by taking advantage of the Port Forwarding capabilities of AWS Systems Manager Session Manager.
I have got answered the same question in the AWS repost by #Uwe K. Please refer below.
SSM allows many more functions - and changes! - to an instance then just connecting to it. Having full SSM functionality on an RDS instance thus would undermine the Shared Responsibility Model we use for RDS (you could also say: it would violate the "Black Box" principle of RDS). Therefore, you need an intermediary instance that forwards the TCP Port exposed by RDS to your local machine.
Further reading:
The RDS-specific Shared Responsibility Model is explained here https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.html
a general overview of the Shared responsibility model https://aws.amazon.com/compliance/shared-responsibility-model/
In order to connect to any EC2 instance with AWS systems manager, the SSM agent must be installed on that machine and the appropriate permissions need to be set up for the instance.
At the moment, AWS does not support this to RDS directly. In order for them to support such a setup, they'd probably need to install the agent on all RDS instances which generates quite some overhead and who knows what else the complexities of such a setup would have.
So at the present moment the most effective way to connect is setting up a tunnel via an EC2 instance.

Auto configure private DNS resolve in VPC network for EC2 instances running from AMI

I have AMI template server in EC2 AWS witch run my server.
For sure it's running in single VPC network.
I want to be able to connect any my server using ssh once it's running using hostname dns resolve.
For example I have gateway, server-01, server-02 in my ec2 instances list.
Once I launch one more server from my AMI (server-03), I need to connect to it from gateway server using ssh server-03
How I can do it?
I would suggest using terraform to manage your EC2 instances. This will allow you to do many things you would normally do manually.
You can have a private or public hosted zone assigned to your VPCs (public would require a bit more)
Then on terraform, you can have the following:
Your ec2 instance creation.
A tfvar file containing the variables for all your EC2 instances
Your Hosted Zone attaching the EC2 private IP to a DNS
Output afterwards to print out your new EC2 instance with the private DNS you can SSH to

Why I cannot access via SSH to an EC2 instance through another EC2 instance without providing the .pem?

I need that all instances that I launch in a public subnet of a VPC can access via SSH without providing a .pem, just with its private IP. Additionally, I need to create an OpenVPN server in one of them so anyone that can access to the subnet via VPN can access to any instance via SSH without providing a .pem using its private IP too.
I do not know if this is possible, but if there is another way to do that I would appreciate it if you could tell me.
Yes, it's possible, you can access your instances without .pem file by using AWS System Manager.
Use Session Manager service of AWS System manager through the AWS console page.
Session Manager: Users who want to connect to an instance with just one click from the browser or AWS CLI without having to provide SSH keys.
A user who wants to monitor and track instance access and activity, close down inbound ports on instances or enable connections to instances that do not have a public IP address.

Amazon Linux 2 instances won't appear in Systems Manager

I think I've done everything listed as a pre-req for this, but I just can't get the instances to appear in Systems Manager as managed instances.
I've picked an AMI which i believe should have the agent in by default.
ami-032598fcc7e9d1c7a
PS C:\Users\*> aws ec2 describe-images --image-ids ami-032598fcc7e9d1c7a
{
"Images": [
{
"ImageLocation": "amazon/amzn2-ami-hvm-2.0.20200520.1-x86_64-gp2",
"Description": "Amazon Linux 2 AMI 2.0.20200520.1 x86_64 HVM gp2",
I've also created my own Role, and included the following policy which i've used previously to get instances into Systems Manager.
Finally I've attached the role to the instances.
I've got Systems Manager set to a 30 min schedule and waited this out and the instances don't appear. I've clearly missed something here, would appreciate suggestions of what.
Does the agent use some sort of backplane to communicate, or should I have enabled some sort of communication with base in the security groups?
Could this be because the instances have private IPs only? Previous working examples had public IPs, but I dont want that for this cluster.
Besides the role for ec2 instances, SSM also needs to be able to assume role to securely run commands on the instances. You only did the first step. All the steps are described in AWS documentation for SSM.
However, I strongly recommend you use the Quick Setup feature in System Manager to setup everything for you in no time!
In AWS Console:
Go to Systems Manager
Click on Quick Setup
Leave all the defaults
In the Targets box at the bottom, select Choose instances manually and tick your ec2 instance(s)
Finish the setup
It will automatically create AmazonSSMRoleForInstancesQuickSetup Role and assign it to the selected ec2 instance(s) and also create proper AssumeRole for SSM
Go to EC2 Console, find that ec2 instance(s), right-click and reboot it by choosing Instance State > Reboot
Wait for a couple of minutes
Refresh the page and try to Connect via Session Manager tab
Notes:
It's totally fine and recommended to create your ec2 instances in private subnets if you don't need them to be accessed from internet. However, make sure the private subnet has internet access itself via NAT. It's a hidden requirement of SSM!
Some of the AmazonLinux2 images like amzn2-ami-hvm-2.0.20200617.0-x86_64-gp2 does not have proper SSM Agent pre-installed. So, recreate your instance using a different AMI and try again with the above steps if it didn't work.
Could this be because the instances have private IPs only? Previous working examples had public IPs, but I don't want that for this cluster.
If you place your instance in a private subnet (or in a public subnet but without a public IP), then the SSM agent can't connect to the SSM Service. Thus it can't register to it.
There are two solutions to this issue:
Setup VPC Interface endpoint in a private subnet for SSM System Manger. With this your intances will be able to connect to the SSM service without the internet.
Create a public subnet with NAT gateway/instance, and setup route tables to route internet traffic from the private subnets to the NAT gateway. This way your private instances will be able to access the SSM service over internet through the NAT device.