Unable to log in with the generated.pub access key

Lab 4: Creating session policies with session tags and IAM conditions

I’ve generated an SSH key pair using the terminal.
[cloudshell-user@ip-10-140-122-161 ~]$ ssh-keygen -t rsa -f ~/.ssh/Ec2instancekeypair
Generating public/private rsa key pair.
Created directory ‘/home/cloudshell-user/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/cloudshell-user/.ssh/Ec2instancekeypair
Your public key has been saved in /home/cloudshell-user/.ssh/Ec2instancekeypair.pub
The key fingerprint is:
SHA256:QmicFFRPoxE6wEZRgxxps73asMwEOXLcc4Do5n0+WRU [email protected]
The key’s randomart image is:
±–[RSA 3072]----+
| ==O*o+.o |
|. X+.= = E |
|.= =B.o . . |
|=o+.+o. . |
|++. +. S |
| .o… o |
| + =o o |
| = .+ |
| . |
±—[SHA256]-----+
[cloudshell-user@ip-10-140-122-161 ~]$ cd ~/.ssh
[cloudshell-user@ip-10-140-122-161 .ssh]$ ll
total 8
-rw-------. 1 cloudshell-user cloudshell-user 2643 Jul 12 18:08 Ec2instancekeypair
-rw-r–r–. 1 cloudshell-user cloudshell-user 600 Jul 12 18:08 Ec2instancekeypair.pub
[cloudshell-user@ip-10-140-122-161 .ssh]$

But, when I am checking “SSH Key is created in the terminal?” it showing not done.
Would you kindly assist me in solving the issue?

Thanks

Could you please include a link to the lab you’re referring to; it isn’t even clear which course you’re talking about.

https://learn.kodekloud.com/user/courses/aws-iam/module/8ffebc04-c194-403a-ac2e-2a2f0a6221ce/lesson/9a97bc33-ae09-467f-9d44-0f16315d80aa

Take a look at the solution tab for this sub-task; not only do you have to create the key pair (which you’re doing), you also need to register this key pair in the “Import the public key to AWS EC2 Key Pairs” step. As near as I can tell, you did not do this part of the task.