amazon-web-servicesamazon-amicloud-initoraclelinux

Not able to connect to custom made Oracle Linux AMI in AWS


I'm relatively new in the world of creating AMIs for AWS in using VirtualBox.

As an experiment, I'm trying to create an AMI from Oracle Linux 9.4. I want to be able to let use AWS keypairs in de AMI.

First I installed Oracle Linux 9.4 with a minimal installation. I disabled SSH via root. As network interface I used a NAT instance.

After the installation, I installed cloud-init with:

yum install cloud-init

Then I looked at the config in /etc/cloud/cloud.cfg and left pretty much all the defaults, apart from

default_user:
   name: ec2-user

Just some settings which I verified:

users:
   - default

disable_root: true

ssh_pwauth: false

ssh_deletekeys: true
ssh_genkeytypes: ['rsa', 'ecdsa', 'ed25519']

cloud_init_modules:
...
   - ssh

I exported the AMI as an OVA and uploaded it to an S3 bucket and exported it as an OVA. However, if I do start an instance with this AMI and try to access it with instance connect, I have inbound port 22 open in my security group, I get message:

enter image description here

Anyone an idea what's missing?


Solution

  • The documentation describes how to install EC2 Instance Connect. After doing this, it all seems to work fine.

    mkdir /tmp/ec2-instance-connect
    curl https://amazon-ec2-instance-connect-us-west-2.s3.us-west-2.amazonaws.com/latest/linux_amd64/ec2-instance-connect.rpm -o /tmp/ec2-instance-connect/ec2-instance-connect.rpm
    curl https://amazon-ec2-instance-connect-us-west-2.s3.us-west-2.amazonaws.com/latest/linux_amd64/ec2-instance-connect-selinux.noarch.rpm -o /tmp/ec2-instance-connect/ec2-instance-connect-selinux.rpm
    sudo yum install -y /tmp/ec2-instance-connect/ec2-instance-connect.rpm /tmp/ec2-instance-connect/ec2-instance-connect-selinux.rpm