I was checking out videos on accessing aws using ssh. 

He just added a IAM role while creating EC2 instance. When I ssh to EC2 instance from cli I was easily able to run "aws s3 ls". My question is how does it will know whether I belong to that IAM role or not?

While starting ssh connection I gave only the public IP of EC2 and keypair related to that EC2 instance. 

> 
> **So where exactly I allowed my identity to be shared with aws?**
> 
> 
> 

When I didnot added the role while creating ec2 instance I have to explicitly give my keys for accessing aws services. 

> 
> So what IAM role do on the fly that it donot ask for credentials?
> 
> 
>