Reputation:
I just created a playbook to bring up an EC2 instance, my original image is ami-63b25203
and everything runs normally, but when I changed this image to ami-9abea4fb
. I got this error
fatal: [ec2-52-34-133-13.us-west-2.compute.amazonaws.com] => SSH Error: Permission denied (publickey).
while connecting to 52.34.133.13:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
TASK: [Jenkins | Add Jenkins repository] **************************************
FATAL: no hosts matched or all hosts have already failed -- aborting
and, this is my playbook on github: https://github.com/hly189/Ansible/blob/master/ec2.yml
and, this is the configuration for my ansible.cfg
[defaults]
#ask_sudo_pass = True
host_key_checking = False
remote_user = ec2-user
[ssh_connection]
control_path = "%(directory)s/%%h-%%r"
ssh_args = -o ForwardAgent=yes
Can anyone show me of how to fix this error?
Upvotes: 0
Views: 440
Reputation: 1136
First, try changing remote_user= by only user=, then do a chmod 600 hoa_ly.pem file, and try with ssh.
You miss the key pair configuration, I use this just adding a new ssh identity on my ~/.ssh/config as well:
IdentityFile ~/.ssh/hoa_ly.pem
Upvotes: 0