Trying to connect to my ec2 instance with Ansible
Read AWS' documentation on how to add keys. AWS doesn't allow password authentication, so you will have to add the key as per AWS' documentation.
If you have no setup in the VM, it's probably easiest to delete it and start afresh - and pay attention to the choices you make as you create the VM. If you have configuration in it, AWS provides documentation on how to gain access to it, by attaching the storage to a different VM and manually editing it.
Second, don't prepend commands with sudo
by default. There's no reason to run ssh-copy-id
as root in your scenario.
Third, why do you want to have a custom filename for the key on your computer? That may make sense in some scenarios, but overall it will only make use more complex.