Interview Prep/AWS/VPC and Connectivity

`Permission denied (publickey)` on a new EC2 instance.

IntermediateTroubleshootingVPC and Connectivity
Answer

Likely causes → Wrong key pair, wrong username, or wrong permissions on the key file.

Diagnose →

ssh -vvv -i key.pem ec2-user@host
chmod 400 key.pem
aws ec2 describe-instances --instance-ids i-0abc --query 'Reservations[].Instances[].KeyName'

Fix →

  1. Use correct user: ec2-user, ubuntu, admin
  2. Use the right key
  3. Use EC2 Instance Connect or SSM to inject a new key

Prevent → Document usernames per AMI.

aws All AWS questions Roadmap: AWS core services

More on VPC and Connectivity