我刚创建了一个剧本来调出一个EC2实例,我的原始图像为ami-63b25203
,一切正常,但是当我将此图像更改为ami-9abea4fb
时。我收到了这个错误
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
并且,这是我在github上的剧本:https://github.com/hly189/Ansible/blob/master/ec2.yml
,这是我的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
有人能告诉我如何修复此错误吗?
答案 0 :(得分:1)
首先,尝试仅通过user =更改remote_user =,然后执行chmod 600 hoa_ly.pem文件,并尝试使用ssh。
你错过了密钥对配置,我只是在我的〜/ .ssh / config上添加了一个新的ssh标识:
IdentityFile~ / .ssh / hoa_ly.pem