I keep getting Permission denied (publickey) error every time I try to ssh into my ec2 instances using anything except for the master pems. I've tried going through the aws dashboard to create pem files and using the aws cli; neither work. I've tried with more than one instance, same thing everytime; master pem works all others don't.
When connecting to a Linux computer using SSH, the following process takes place:
~/.ssh/authorized_keys
file for that user (eg ec2-user
)Therefore, to login to a Linux computer:
~/.ssh/authorized_keys
file for that userWhen launching an Amazon EC2 instance for the first time, you can specify a keypair. The EC2 service will automatically place the corresponding public key in the /home/ec2-user/.ssh/authorized_keys
file. This is why your "master key" is working.
Simply creating keypairs in the console does not grant access to an instance. This is why your "other" keys are not granting access. For each of them that you want to work, you will need to put the corresponding public key in the ~/.ssh/authorized_keys
file. You can put these public keys in other home directories too (eg /home/badhabit/.ssh/authorized_keys
). This will permit the user with the matching private keypair to login as the badhabit
user.