Answer: B
Option A is incorrect because the IAM username and password are used for logging in to the AWS console and cannot log in to EC2 instances.
Option B is CORRECT because Key pairs consist of a public key and a private key. You use the private key to create a digital signature, and then AWS uses the corresponding public key to validate the signature. Key pairs can be used to SSH to Amazon EC2 instances.
Option C is incorrect because AWS Access Keys are used for logging in to the AWS console & services using the command line. They cannot be used to log in to EC2 instances.
Option D is incorrect because AWS SDK provides APIs for AWS services. It cannot be used to log in to EC2 instances.
For more information on AWS Security credentials, please visit the below URL:
https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html