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.