2016-03-07 97 views
0

我剛剛創建了一個用於啓動EC2實例的劇本,我的原始圖像是ami-63b25203,並且所有內容都正常運行,但是當我將此圖像更改爲ami-9abea4fb時。我得到這個錯誤Ansible在連接到AWS時失敗

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 

誰能告訴我如何修復這個錯誤?

回答

1

首先,嘗試更改remote_user =只有user =,然後執行chmod 600 hoa_ly.pem文件,然後嘗試使用ssh。

你錯過了密鑰對的配置,我用這只是我的〜/ .ssh/config中添加新的SSH身份,以及:

IdentityFile的〜/ .ssh/hoa_ly.pem

+0

實際上,通過將'remote_user'更改爲'user'來修復。順便說一句,請你解釋一下爲什麼,因爲當我在Amazon Linux中使用'remote_user'時,這是不同的ami,這仍然是正常的 – Alexander

+0

什麼是你的可靠版本? –

+0

我的支持版本是1.9.3 – Alexander