AWS Level 2: Configuring Secure SSH Access to an EC2 Instance

i have created key using the below mentioned command.
ssh-keygen -t rsa -b 2048 -f ~/.ssh/nautilus-key -N “”

I uploaded the key to the AWS using the below mentioned command.
aws ec2 import-key-pair
–key-name nautilus-key
–public-key-material fileb://~/.ssh/nautilus-key.pub

After creating the key, I used the below mentioned command to create the ec2 Instancce consuming the aove mentioned key

aws ec2 run-instances
–image-id ami-00ca32bbc84273381
–count 1
–instance-type t2.micro
–key-name nautilus-key
–security-group-ids sg-XXX
–subnet-id subnet-XXX
–tag-specifications ‘ResourceType=instance,Tags=[{Key=Name,Value=nautilus-ec2}]’

Instance got created and i was able to connect to the instance using the bleow mentioned command without any issue(I added an inboud rule for 22 port from the connection server to the security group).
ssh -i ~/.ssh/nautilus-key ec2-user@XXX

but still the task is failing. Please point out the issue.

I suppose you are talking about AWS level 2 - Task 4, if so could you please check this?

After finishing the task, check if you are able to login as root to the instance and without being asked for password.
I assume the validation goes something like this:
ssh root@<instance_public_ip>

Note: For the validation to work you shouldn’t have to specify the private_key path while trying to login to the instance (at least for this task).