前提・実現したいこと
実行コマンド:
ansible-playbook -u wangzj --private-key /home/wangzj/.ssh/id_rsa -i inventories/hosts setup.yml
実行するとエラーが発生してしまった
事前に作ったPrivateKey
wangzj@wangzj-virtual-machine:~$ ssh-keygen -C Comment Generating public/private rsa key pair. Enter file in which to save the key (/home/wangzj/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/wangzj/.ssh/id_rsa. Your public key has been saved in /home/wangzj/.ssh/id_rsa.pub. The key fingerprint is: SHA256:mMreCmLMxB9ZE74meODdLT+WpfnPxb+8PZryl5x/5UI Comment The key's randomart image is: +---[RSA 2048]----+ | . | | . . | | . + | |o + + +o | | = * =o.S. | |+ o.+.o = . E .| |.+..o B +..+| |.. o .. o ... =*+| | o.. ..oo+o*O| +----[SHA256]-----+
発生している問題・エラーメッセージ
TASK [Gathering Facts] ********************************************************* fatal: [192.168.255.5]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n", "unreachable": true} [WARNING]: Could not create retry file '/etc/ansible/all-in-one/aaa.retry'. [Errno 13] Permission denied: u'/etc/ansible/all-in-one/aaa.retry'
sudo ansible -m ping allを実行しました。
もしかして、/etc/ansible/hostsに設定が足りないでしょうか?
wangzj@wangzj-virtual-machine:~$ sudo ansible -m ping all [sudo] wangzj のパスワード: [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
/etc/ansible/hostsの内容↓:
# This is the default ansible 'hosts' file. # # It should live in /etc/ansible/hosts # # - Comments begin with the '#' character # - Blank lines are ignored # - Groups of hosts are delimited by [header] elements # - You can enter hostnames or ip addresses # - A hostname/ip can be a member of multiple groups # Ex 1: Ungrouped hosts, specify before any group headers. ## green.example.com ## blue.example.com ## 192.168.100.1 ## 192.168.100.10 # Ex 2: A collection of hosts belonging to the 'webservers' group ## [webservers] ## alpha.example.org ## beta.example.org ## 192.168.1.100 ## 192.168.1.110 # If you have multiple hosts following a pattern you can specify # them like this: ## www[001:006].example.com # Ex 3: A collection of database servers in the 'dbservers' group ## [dbservers] ## ## db01.intranet.mydomain.net ## db02.intranet.mydomain.net ## 10.25.1.56 ## 10.25.1.57 # Here's another example of host ranges, this time there are no # leading 0s:
試したこと
下記、確認しました。問題ないはずです。
- 間違った鍵で接続しようとしている。キーペアは正しいか確認する
- 間違ったユーザー名で接続しようとしている。正しいユーザー名かどうか確認する
- ホスト名が間違っている。ホスト名が正しいかどうか確認する。
terminalにコマンド
ssh wangzj@192.168.255.5
でログインしてみました、成功しました。
上記以外、何か原因がかんがえられますでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。