Ansible: ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey、password)

作成日 2016年12月20日  ·  70コメント  ·  ソース: ansible/ansible

192.168.1.113 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n", 
    "unreachable": true
}

このエラーが発生しました。virtualboxでDebianStretchとゲストmanjaroを使用しています。

affects_2.3

最も参考になるコメント

良い、
コマンドでallを指定すると、デバッグが少し難しくなります。

hostsファイルのすべての行にコメントを付けますこの行を追加します

[webserver]
35.165.79.66 ansible_user=ubuntu 

実行してみてください:

$: ansible webserver -m ping -vvv

そして、出力を見せてください。
よろしく

全てのコメント70件

同じ問題に直面しています。 続く。

より多くの出力を得るために、オプション-vvvvを使用して同じコマンドを起動できますか? お願いします !

guru@tj-lp140:/etc/ansible$ ansible all -m ping -vvv
Using /etc/ansible/ansible.cfg as config file
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/system/ping.py
<35.165.79.66> ESTABLISH SSH CONNECTION FOR USER: None
<35.165.79.66> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/guru/.ansible/cp/ansible-ssh-%h-%p-%r 35.165.79.66 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/ansible-tmp-1482309322.49-151682117578429 `" && echo ansible-tmp-1482309322.49-151682117578429="` echo /tmp/ansible-tmp-1482309322.49-151682117578429 `" ) && sleep 0'"'"'' 

ありがとう。
出力から、ansible_userが指定されていないことがわかります。

<35.165.79.66> ESTABLISH SSH CONNECTION FOR USER: None

インベントリファイルの内容も表示しますか?

# 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]
35.165.79.66

# 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:

## db-[99:101]-node.example.com

[email protected]接続が確立されます。 しかし、ansibleコマンドを完了できません。

良い、
コマンドでallを指定すると、デバッグが少し難しくなります。

hostsファイルのすべての行にコメントを付けますこの行を追加します

[webserver]
35.165.79.66 ansible_user=ubuntu 

実行してみてください:

$: ansible webserver -m ping -vvv

そして、出力を見せてください。
よろしく

guru@tj-lp140:/etc/ansible$ ansible webservers -m ping -vvv
Using /etc/ansible/ansible.cfg as config file
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/system/ping.py
<35.165.79.66> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<35.165.79.66> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/guru/.ansible/cp/ansible-ssh-%h-%p-%r 35.165.79.66 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1482312980.96-238945640414494 `" && echo ansible-tmp-1482312980.96-238945640414494="` echo $HOME/.ansible/tmp/ansible-tmp-1482312980.96-238945640414494 `" ) && sleep 0'"'"''
<35.165.79.66> PUT /tmp/tmpxll2kJ TO /home/ubuntu/.ansible/tmp/ansible-tmp-1482312980.96-238945640414494/ping.py
<35.165.79.66> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/guru/.ansible/cp/ansible-ssh-%h-%p-%r '[35.165.79.66]'
<35.165.79.66> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<35.165.79.66> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/guru/.ansible/cp/ansible-ssh-%h-%p-%r 35.165.79.66 '/bin/sh -c '"'"'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1482312980.96-238945640414494/ /home/ubuntu/.ansible/tmp/ansible-tmp-1482312980.96-238945640414494/ping.py && sleep 0'"'"''
<35.165.79.66> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<35.165.79.66> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/guru/.ansible/cp/ansible-ssh-%h-%p-%r -tt 35.165.79.66 '/bin/sh -c '"'"'/usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1482312980.96-238945640414494/ping.py; rm -rf "/home/ubuntu/.ansible/tmp/ansible-tmp-1482312980.96-238945640414494/" > /dev/null 2>&1 && sleep 0'"'"''
35.165.79.66 | FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_name": "ping"
    }, 
    "module_stderr": "Shared connection to 35.165.79.66 closed.\r\n", 
    "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", 
    "msg": "MODULE FAILURE"
}
<192.168.1.113> ESTABLISH SSH CONNECTION FOR USER: fulgor
<192.168.1.113> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=fulgor -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.1.113 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1482330370.75-42265180130710 `" && echo ansible-tmp-1482330370.75-42265180130710="` echo $HOME/.ansible/tmp/ansible-tmp-1482330370.75-42265180130710 `" ) && sleep 0'"'"''
192.168.1.113 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n", 
    "unreachable": true
}

仮想ボックスのイメージディスクを変更してsshキーが再生成されましたが、この時点からエラーメッセージが表示されます。

私たちを手伝ってくれますか ?

マスターノードでsshキーを生成します。

root<strong i="6">@master</strong>:~# ssh-keygen -t rsa -C "[email protected]"

次に、公開鍵をssh-copy-idを使用してサーバーにコピーします。

root<strong i="10">@master</strong>:~# ssh-copy-id [email protected]
root<strong i="11">@master</strong>:~# ssh-copy-id [email protected]

私はこのウェブサイトhttps://valdhaus.co/writings/ansible-post-install/でこの情報を入手し、それは機能しています

@ guruprasad85リモートマシン(35.165.79.66)で「python」を見逃しているようです。

"module_name": "ping"
},
"module_stderr": "Shared connection to 35.165.79.66 closed.\r\n",
"module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n",
"msg": "MODULE FAILURE"
}

こんにちは、
私は解決策を見つけました。
ami(ubuntu 16)OSを使用している場合は、Pythonがインストールされていないため、インストールする必要があります。 以下のコマンドを使用してPythonをインストールします-

sudo apt-get install python-minimal -y

また

ami(ubuntu 14)OSを使用する必要があります。 Python2.7があります。

注:システムに搭載されているOSのバージョンを確認してください。

解決策を見つけてよかったです。

Ansibleコントロールマシン(UBUNTU 14.04 VMにインストールされている)からcentOSインスタンスにpingを実行しようとしています。
どちらもGoogleCloudインスタンスです(Pythonがインストールされています)。
それらの間の接続状態がわかりません。 以下のansibleall -m pingの結果から、SSHに問題があることがわかりました。

35.185.191.25 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n",
    "unreachable": true
# ansible all -m ping -vvv
Using /etc/ansible/ansible.cfg as config file
META: ran handlers
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/system/ping.py
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/21f0e6a9ae 127.0.0.1 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/system/ping.py
<35.185.191.25> ESTABLISH SSH CONNECTION FOR USER: gane
<35.185.191.25> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=gane -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/4596e88996 35.185.191.25 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<127.0.0.1> (255, '', 'Permission denied (publickey).\r\n')
127.0.0.1 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey).\r\n",
    "unreachable": true
}
<35.185.191.25> (255, '', 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n')
35.185.191.25 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n",
    "unreachable": true
}

VM間の接続を実現することを提案していただけませんか。

私は同じ問題を@ganfotryで抱えています。 この問題の原因は何ですか? 正しい方向に教えてください。

両方のVMでキーを生成してから、キーをコピーすることで修正しました
authorized_keys内の逆。
その時、私は以下の応答を得ました:)

ansible -m ping all
127.0.0.1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
35.186.***.*** | SUCCESS => {
    "changed": false,
    "ping": "pong"

私は同じ問題を抱えていました:

$ ansible local -m ping
127.0.0.1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n",
"unreachable": true
}

次のコマンドを使用してsshpassをインストールすることにより、問題を解決しました。

sudo apt-get install sshpass

sshpassをインストールした後、次のコマンドを実行しました。
` json ansible local -m ping --ask-pass SSH password: 127.0.0.1 | SUCCESS => { "changed": false, "ping": "pong" }
お役に立てれば!!!

これは私のために働いたので、あなたにも役立つかもしれません。
キーチェーンに秘密鍵を登録してみてください

ssh-agent bash
ssh-add <path to private key>

これが機能する場合は、〜/ .ssh / configファイルにキーを追加してみてください

こんにちは、
ansibleタワーのGUIモードでコマンドを実行しているときに、以下のエラーが発生します。

192.168.122.136 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '192.168.122.136' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,password).\r\n", 
    "unreachable": true 
}

しかし、サーバーでCLIモードで結果を取得することはできます。

[root<strong i="10">@node2</strong> ~]# ansible -m ping testservers
openstack | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

以下は説明された出力です

[root<strong i="14">@node2</strong> ~]# ansible testservers -m ping -vvv
Using /etc/ansible/ansible.cfg as config file
META: ran handlers
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/ping.py
<192.168.122.136> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.122.136> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/859aa03053 192.168.122.136 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<192.168.122.136> (0, '/root\n', '')
<192.168.122.136> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.122.136> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/859aa03053 192.168.122.136 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1497787246.45-142355876761696 `" && echo ansible-tmp-1497787246.45-142355876761696="` echo /root/.ansible/tmp/ansible-tmp-1497787246.45-142355876761696 `" ) && sleep 0'"'"''
<192.168.122.136> (0, 'ansible-tmp-1497787246.45-142355876761696=/root/.ansible/tmp/ansible-tmp-1497787246.45-142355876761696\n', '')
<192.168.122.136> PUT /tmp/tmpkAYqIN TO /root/.ansible/tmp/ansible-tmp-1497787246.45-142355876761696/ping.py
<192.168.122.136> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/859aa03053 '[192.168.122.136]'
<192.168.122.136> (0, 'sftp> put /tmp/tmpkAYqIN /root/.ansible/tmp/ansible-tmp-1497787246.45-142355876761696/ping.py\n', '')
<192.168.122.136> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.122.136> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/859aa03053 192.168.122.136 '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1497787246.45-142355876761696/ /root/.ansible/tmp/ansible-tmp-1497787246.45-142355876761696/ping.py && sleep 0'"'"''
<192.168.122.136> (0, '', '')
<192.168.122.136> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.122.136> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/859aa03053 -tt 192.168.122.136 '/bin/sh -c '"'"'/usr/bin/python /root/.ansible/tmp/ansible-tmp-1497787246.45-142355876761696/ping.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1497787246.45-142355876761696/" > /dev/null 2>&1 && sleep 0'"'"''
<192.168.122.136> (0, '\r\n{"invocation": {"module_args": {"data": null}}, "changed": false, "ping": "pong"}\r\n', 'Shared connection to 192.168.122.136 closed.\r\n')
openstack | SUCCESS => {
    "changed": false, 
    "invocation": {
        "module_args": {
            "data": null
        }
    }, 
    "ping": "pong"
}
META: ran handlers
META: ran handlers

ありがとう

ターミナル上のサーバーに手動でアクセスしてみてください。リモートサーバーをsshできる場合は、ローカルユーザーのホームディレクトリから.ansibleディレクトリを削除してください。 これは私のために働きます。 (y)

わたしも!
-iディレクティブを渡さなくても、ターミナル経由でサーバーをsshできます。

ssh [email protected]

作品

コマンドの実行:

ansible all -m ping

エラーが発生します:

    "msg": "Failed to connect to the host via ssh: Permission denied (publickey).\r\n",  
    "unreachable": true

@lkjangirが.ansibleディレクトリを削除しても機能しませんでした。 =(

これを試して、ec2-userを設定したユーザー名に置き換えてください。

ansible all -u ec2-user -m ping -vvv

@aelkz:の/ etc / ansible / hostsファイルに、あなたが置くことができる: [email protected]の代わりにserver.com当時としてみてくださいansible all -m ping
それ以外の場合、/ etc / ansible / hostsでuser1を指定しなかった場合は、ansibleコマンドでユーザーを指定する必要があります: ansible all -m ping -u user1
同じエラーが発生し、その解決策で問題が解決しました。

私が間違っていない場合、これはsshキーの問題が原因です。 エラーを回避するために、新しいキーのレートをリネレートするか、キーをopensshformateに変換します。

--ask-passを-uパラメーターと一緒に使用するとうまくいきました。

@ Hai-minhDあなたの解決策は私のために働いた、ありがとう。 コントロールマシンで使用していたのと同じユーザーとしてrootユーザーがいるホストでテストしていました。 上記で報告された障害が発生したこの特定のホストには、別のユーザーがいます。 このユーザー名を持つホストをAnsiblehostsファイルに追加することを解決しました: username @host

試す-

ansible webserver -m ping --ask-pass -i path_to_local_hosts_file

スレーブにPythonをインストールしましたが、うまくいきました。

同じ問題があります。
解決策を見つけました:/ etc / ansible / hostsを追加します:
ansible_ssh_user =ansible_ssh_pass =

お役に立てれば。

エラーが発生します。 ここshivslaveは、IP 192.168.0.5とVirtualboxの上の別のVMであると私はそれを接続することができる午前[email protected]成功したがAnsibleコマンドが機能していません。 ホストファイルには

[例]192.168.0.5

shivmaster @ shivmaster-VirtualBox :〜$ ansibleの例-mping -u shivslave -vvv
ansible 2.4.1.0
設定ファイル= / etc / ansible / ansible.cfg
構成されたモジュール検索パス= [u '/ home / shivmaster / .ansible / plugins / modules'、u '/ usr / share / ansible / plugins / modules']
ansiblepythonモジュールの場所= / usr / lib / python2.7 / dist-packages / ansible
実行可能ファイルの場所= / usr / bin / ansible
pythonバージョン= 2.7.6(デフォルト、2016年10月26日、20:30:19)[GCC 4.8.4]
/etc/ansible/ansible.cfgを構成ファイルとして使用する
iniプラグインを使用して/ etc / ansible / hostsインベントリソースを解析しました
META:ハンドラーを実行しました
モジュールファイル/usr/lib/python2.7/dist-packages/ansible/modules/system/ping.pyを使用する
<192.168.0.5>ユーザーのSSH接続を確立する:shivslave
<192.168.0.5> SSH:EXEC ssh -C -o ControlMaster = auto -o ControlPersist = 60s -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic、gssapi-keyex、hostbased、publickey -o PasswordAuthentication = no -o User = shivslave -o ConnectTimeout = 10 -o ControlPath = /home/shivmaster/.ansible/cp/e51c1eb9be 192.168.0.5 '/ bin / sh -c' "'"' echo〜 && sleep 0 '"'" ''
<192.168.0.5>(255、 ''、 'アクセスが拒否されました(publickey、password)。\ r \ n')
192.168.0.5 | 到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey、password)。\ r \ n"、
「到達不能」:true
}
shivmaster @ shivmaster-VirtualBox :〜$

@lktslionel
私は同じ問題を抱えています、私は上記のすべてのオプションを試しました、ここで助けてください

ansible 2.4.2.0
設定ファイル= / etc / ansible / ansible.cfg
構成されたモジュール検索パス= [u '/ root / .ansible / plugins / modules'、u '/ usr / share / ansible / plugins / modules']
ansiblepythonモジュールの場所= / usr / lib / python2.7 / dist-packages / ansible
実行可能ファイルの場所= / usr / bin / ansible
pythonバージョン= 2.7.12(デフォルト、2017年11月20日、18:23:56)[GCC 5.4.0 20160609]
/etc/ansible/ansible.cfgを構成ファイルとして使用する
ansible.cfgでdeprecation_warnings = Falseを設定することで無効にできます。
インベントリプラグインの設定
iniプラグインを使用して/ etc / ansible / hostsインベントリソースを解析しました
最小タイプのコールバックプラグインv2.0を/usr/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pycからロードしています
META:ハンドラーを実行しました
モジュールファイル/usr/lib/python2.7/dist-packages/ansible/modules/system/ping.pyを使用する
<10.0.3.36>ユーザーのSSH接続を確立する:root
<10.0.3.36> SSH:EXEC ssh -vvv -C -o ControlMaster = auto -o ControlPersist = 60s -o StrictHostKeyChecking = no -o Port = 22 -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic、gssapi- keyex、hostbased、publickey -o PasswordAuthentication = no -o User = root -o ConnectTimeout = 10 -o ControlPath = / root / .ansible / cp / c8171a76d6 10.0.3.36 '/ bin / sh -c' "'"' echo〜 &&スリープ0 '"'" ''
<10.0.3.36>(255、 ''、 'OpenSSH_7.2p2 Ubuntu-4ubuntu2.2、OpenSSL 1.0.2g 2016年3月1日\ r \ ndebug1:構成データの読み取り/ etc / ssh / ssh_config \ r \ ndebug1:/ etc / ssh / ssh_config 19行目: \ r \ ndebug1のオプションを適用していますsh / id_dsa-certタイプ-1 \ r \ ndebug1:IDファイル/root/.ssh/id_ecdsaタイプ3 \ r \ ndebug1:key_load_public:そのようなファイルまたはディレクトリはありません\ r \ ndebug1:IDファイル/root/.ssh/id_ecdsa -cert type -1 \ r \ ndebug1:key_load_public:そのようなファイルまたはディレクトリはありません\ r \ ndebug1:IDファイル/root/.ssh/id_ed25519 type -1 \ r \ ndebug1:key_load_public:そのようなファイルまたはディレクトリはありません\ r \ ndebug1 :IDファイル/root/.ssh/id_ed25519-cert type -1 \ r \ ndebug1:プロトコル2.0の互換性モードを有効にする\ r \ ndebug1:ローカルバージョン文字列SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 \ r \ ndebug1 :リモートプロトコルバージョン2.0、リモートソフトウェアバージョンOpenSSH_7.2p2 Ubuntu-4ubuntu2.2 \ r \ ndebug1:一致:OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH compat 0x04000000 \ r \ ndebug2:fd3設定O_NONBLOCK \ r \ ndebug1: 10.0.3.36:22に\ 'root \' \ r \ ndebug3:hostkeys_foreach:読み取りファイル "/root/.ssh/known_hosts" \ r \ ndebug3:record_hostkey:ファイル/root/.ssh/でキータイプECDSAが見つかりましたknown_hosts:1 \ r \ ndebug3:load_hostkeys:10.0から1つのキーをロードしました .3.36 \ r \ ndebug3:order_hostkeyalgs:hostkeyalgsを優先:ecdsa-sha2-nistp256-cert-v01 @ openssh.com、ecdsa-sha2-nistp384-cert-v01 @ openssh.com、ecdsa-sha2-nistp521-cert-v01 @ openssh.com、ecdsa-sha2-nistp256、ecdsa-sha2-nistp384、ecdsa-sha2-nistp521 \ r \ ndebug3:パケットの送信:タイプ20 \ r \ ndebug1:SSH2_MSG_KEXINITの送信\ r \ ndebug3:パケットの受信:タイプ20 \ r \ ndebug1:SSH2_MSG_KEXINITを受信しました\ r \ ndebug2:ローカルクライアントKEXINIT提案\ r \ ndebug2:KEXアルゴリズム:curve25519-sha256 @ libssh.org、ecdh-sha2-nistp256、ecdh-sha2-nistp384、ecdh-sha2-nistp521、diffie- hellman-group-exchange-sha256、diffie-hellman-group-exchange-sha1、diffie-hellman-group14-sha1、ext-info-c \ r \ ndebug2:ホストキーアルゴリズム:ecdsa-sha2-nistp256-cert-v01 @ openssh.com、ecdsa-sha2-nistp384-cert-v01 @ openssh.com、ecdsa-sha2-nistp521-cert-v01 @ openssh.com、ecdsa-sha2-nistp256、ecdsa-sha2-nistp384、ecdsa-sha2-nistp521、 ssh-ed25519-cert-v01 @ openssh.com、ssh-rsa-cert-v01 @ openssh.com、ssh-ed25519、rsa-sha2-512、rsa-sha2-256、ssh-rsa \ r \ ndebug2:暗号ctos :chacha20-po ly1305 @ openssh.com、aes128-ctr、aes192-ctr、aes256-ctr、aes128-gcm @ openssh.com、aes256-gcm @ openssh.com、aes128-cbc、aes192-cbc、aes256-cbc、3des-cbc \ r \ ndebug2:暗号stoc:chacha20-poly1305 @ openssh.com、aes128-ctr、aes192-ctr、aes256-ctr、aes128-gcm @ openssh.com、aes256-gcm @ openssh.com、aes128-cbc、aes192-cbc 、aes256-cbc、3des-cbc \ r \ ndebug2:MACs ctos:umac-64-etm @ openssh.com、umac-128-etm @ openssh.com、hmac-sha2-256-etm @ openssh.com、hmac- sha2-512-etm @ openssh.com、hmac-sha1-etm @ openssh.com、umac-64 @ openssh.com、umac-128 @ openssh.com、hmac-sha2-256、hmac-sha2-512、hmac- sha1 \ r \ ndebug2:MACs stoc:umac-64-etm @ openssh.com、umac-128-etm @ openssh.com、hmac-sha2-256-etm @ openssh.com、hmac-sha2-512-etm @ openssh .com、hmac-sha1-etm @ openssh.com、umac-64 @ openssh.com、umac-128 @ openssh.com、hmac-sha2-256、hmac-sha2-512、hmac-sha1 \ r \ ndebug2:圧縮ctos:zlib @ openssh.com、zlib、none \ r \ ndebug2:圧縮stoc:zlib @ openssh.com、zlib、none \ r \ ndebug2:言語ctos:\ r \ ndebug2:言語stoc:\ r \ ndebug2:first_kex_follows 0 \ r \ ndebug2:r eserved 0 \ r \ ndebug2:ピアサーバーKEXINIT提案\ r \ ndebug2:KEXアルゴリズム:curve25519-sha256 @ libssh.org、ecdh-sha2-nistp256、ecdh-sha2-nistp384、ecdh-sha2-nistp521、diffie-hellman-group -exchange-sha256、diffie-hellman-group14-sha1 \ r \ ndebug2:ホストキーアルゴリズム:ssh-rsa、rsa-sha2-512、rsa-sha2-256、ecdsa-sha2-nistp256、ssh-ed25519 \ r \ ndebug2 :ciphers ctos:chacha20-poly1305 @ openssh.com、aes128-ctr、aes192-ctr、aes256-ctr、aes128-gcm @ openssh.com、aes256-gcm @ openssh.com \ r \ ndebug2:ciphers stoc:chacha20-poly1305 @ openssh.com、aes128-ctr、aes192-ctr、aes256-ctr、aes128-gcm @ openssh.com、aes256-gcm @ openssh.com \ r \ ndebug2:MACs ctos:[email protected]、 umac-128-etm @ openssh.com、hmac-sha2-256-etm @ openssh.com、hmac-sha2-512-etm @ openssh.com、hmac-sha1-etm @ openssh.com、umac-64 @openssh。 com、umac-128 @ openssh.com、hmac-sha2-256、hmac-sha2-512、hmac-sha1 \ r \ ndebug2:MAC stoc:umac-64-etm @ openssh.com、umac-128-etm @ openssh .com、hmac-sha2-256-etm @ openssh.com、hmac-sha2-512-etm @ openssh.com、hmac-sha1-etm @ openssh.com、umac-64 @ open ssh.com、umac-128 @ openssh.com、hmac-sha2-256、hmac-sha2-512、hmac-sha1 \ r \ ndebug2:圧縮ctos:なし、zlib @ openssh.com \ r \ ndebug2:圧縮stoc: none、zlib @ openssh.com \ r \ ndebug2:言語ctos:\ r \ ndebug2:言語stoc:\ r \ ndebug2:first_kex_follows 0 \ r \ ndebug2:予約済み0 \ r \ ndebug1:kex:アルゴリズム:curve25519-sha256 @ libssh.org \ r \ ndebug1:kex:ホストキーアルゴリズム:ecdsa-sha2-nistp256 \ r \ ndebug1:kex:サーバー->クライアント暗号:[email protected] MAC:圧縮:[email protected] \ r \ ndebug1:kex:クライアント->サーバー暗号:[email protected] MAC:圧縮:[email protected] \ r \ ndebug3:パケットの送信:タイプ30 \ r \ ndebug1:SSH2_MSG_KEX_ECDH_REPLYを期待\ r \ ndebug3:パケットの受信:タイプ31 \ r \ ndebug1:サーバーホストキー:ecdsa-sha2-nistp256 SHA256: JDiSsUdyRJfRGvtqAURzMtKu / Ghp0adBt / l9VbvgDfg \ r \ ndebug3:hostkeys_foreach:読み取りファイル "/root/.ssh/known_hosts" \ r \ ndebug3:record_hostkey:ファイル/root/.ssh/known_hostsでキータイプECDSAが見つかりました\ 1 load_hostkeys:10.0.3.36 \ r \ ndebug1からロードされた1つのキー:ホスト\ '10 .0.3.36 \ 'は既知であり、ECDSAホストキーと一致します。\ r \ ndebug1:/root/.ssh/known_hosts:1 \ rでキーが見つかりました\ ndebug3:パケットの送信:タイプ21 \ r \ ndebug2:set_newkeys:モード1 \ r \ ndebug1:134217728ブロック後にキーを再生成\ r \ ndebug1:SSH2_MSG_NEWKEYSが送信されました\ r \ ndebug1:SSH2_MSG_NEWKEYSを期待しています\ r \ ndebug3:パケットの受信:タイプ21 \ r \ ndebug2:set_newkeys:モード0 \ r \ ndebug1:134217728ブロック後にキーを再生成します\ r \ ndebug1:SSH2_MSG_NEWKEYSを受信しました\ r \ ndebug2:キー:/root/.ssh/id_ecdsa(0x55cbdc34d840)、エージェント\ r \ ndebug2:キー:/root/.ssh/id_rsa(0x55cbdc33fc30)\ r \ ndebug 2:キー:/root/.ssh/id_dsa((nil))\ r \ ndebug2:キー:/root/.ssh/id_ed25519((nil))\ r \ ndebug3:パケットの送信:タイプ5 \ r \ ndebug3:パケットの受信:タイプ7 \ r \ ndebug1:SSH2_MSG_EXT_INFO受信\ r \ ndebug1:kex_input_ext_info:server-sig-algs =\ r \ ndebug3:受信パケット:タイプ6 \ r \ ndebug2:service_accept:ssh-userauth \ r \ ndebug1:SSH2_MSG_SERVICE_ACCEPT受信\ r \ ndebug3:送信パケット:タイプ50 \ r \ ndebug3:受信パケット:タイプ51 \ r \ ndebug1:続行できる認証:publickey、password \ r \ ndebug3:最初からやり直し、別のリストを渡しましたpublickey、password \ r \ ndebug3:優先gssapi-with-mic、gssapi-keyex、hostbased、publickey \ r \ ndebug3:authmethod_lookup publickey \ r \ ndebug3:引き続き優先:、gssapi-keyex、hostbased、publickey \ r \ ndebug3:authmethod_is_enabled publickey \ r \ ndebug1:次の認証方法:publickey \ r \ ndebug1:ECDSA公開鍵の提供:/root/.ssh/ id_ecdsa \ r \ ndebug3:send_pubkey_test \ r \ ndebug3:パケットの送信:タイプ50 \ r \ ndebug2:公開鍵パケットを送信し、応答を待ちます\ r \ ndebug3:パケットの受信:タイプ51 \ r \ ndebug1:続行できる認証:publickey、password \ r \ ndebug1:RSA公開鍵の提供:/root/.ssh/id_rsa \ r \ ndebug3:send_pubkey_test \ r \ ndebug3:パケットの送信:タイプ50 \ r \ ndebug2:公開鍵を送信しましたパケット、応答を待つ\ r \ ndebug3:パケットを受信:タイプ51 \ r \ ndebug1:続行できる認証:publickey、password \ r \ ndebug1:秘密鍵を試行しています:/root/.ssh/id_dsa \ r \ ndebug3:いいえそのようなID:/root/.ssh/id_dsa:そのようなファイルまたはディレクトリはありません\ r \ ndebug1:秘密鍵を試しています:/root/.ssh/id_ed25519 \ r \ ndebug3:そのようなIDはありません:/root/.ssh/id_ed25519:いいえそのようなファイルまたはディレクトリ\ r \ ndebug2:パケットを送信しませんでした。メソッドを無効にします\ r \ ndebug1:試行する認証メソッドはこれ以上ありません。\ r \ nアクセスが拒否されました(公開鍵、パスワード)。\ r \ n ')
10.0.3.36 | 到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでした:OpenSSH_7.2p2 Ubuntu-4ubuntu2.2、OpenSSL 1.0.2g 2016年3月1日\ r \ ndebug1:構成データの読み取り/ etc / ssh / ssh_config \ r \ ndebug1:/ etc / ssh / ssh_config 19行目: \ r \ ndebug1のオプションを適用していますバグ1:IDファイル/root/.ssh/id_dsa-certタイプ-1 \ r \ ndebug1:IDファイル/root/.ssh/id_ecdsaタイプ3 \ r \ ndebug1:key_load_public:そのようなファイルまたはディレクトリはありません\ r \ ndebug1:identity file /root/.ssh/id_ecdsa-cert type -1 \ r \ ndebug1:key_load_public:そのようなファイルまたはディレクトリはありません\ r \ ndebug1:IDファイル/root/.ssh/id_ed25519 type -1 \ r \ ndebug1:key_load_public:いいえそのようなファイルまたはディレクトリ\ r \ ndebug1:IDファイル/root/.ssh/id_ed25519-cert type -1 \ r \ ndebug1:プロトコル2.0の互換性モードの有効化\ r \ ndebug1:ローカルバージョン文字列SSH-2.0-OpenSSH_7.2p2 Ubuntu -4ubuntu2.2 \ r \ ndebug1:リモートプロトコルバージョン2.0、リモートソフトウェアバージョンOpenSSH_7.2p2 Ubuntu-4ubuntu2.2 \ r \ ndebug1:一致:OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH compat 0x04000000 \ r \ ndebug2:fd 3 O_NONBLOCK \ r \ ndebug1:Authenticating to 10.0.3.36:22 as'root '\ r \ ndebug3:hostkeys_foreach:reading file \ "/root/.ssh/known_hosts \" \ r \ ndebug3:record_hostkey:found key type ECDSAファイル/root/.ssh/known_hosts:1\r\ndebug3:load_hostk eys:10.0.3.36から1つのキーをロード\ r \ ndebug3:order_hostkeyalgs:hostkeyalgsを優先:ecdsa-sha2-nistp256-cert-v01 @ openssh.com、ecdsa-sha2-nistp384-cert-v01 @ openssh.com、ecdsa-sha2 -nistp521-cert-v01 @ openssh.com、ecdsa-sha2-nistp256、ecdsa-sha2-nistp384、ecdsa-sha2-nistp521 \ r \ ndebug3:パケットの送信:タイプ20 \ r \ ndebug1:SSH2_MSG_KEXINITの送信\ r \ ndebug3:受信パケット:タイプ20 \ r \ ndebug1:SSH2_MSG_KEXINIT受信\ r \ ndebug2:ローカルクライアントKEXINIT提案\ r \ ndebug2:KEXアルゴリズム:curve25519-sha256 @ libssh.org、ecdh-sha2-nistp256、ecdh-sha2-nistp384、ecdh -sha2-nistp521、diffie-hellman-group-exchange-sha256、diffie-hellman-group-exchange-sha1、diffie-hellman-group14-sha1、ext-info-c \ r \ ndebug2:ホストキーアルゴリズム:ecdsa-sha2 -nistp256-cert-v01 @ openssh.com、ecdsa-sha2-nistp384-cert-v01 @ openssh.com、ecdsa-sha2-nistp521-cert-v01 @ openssh.com、ecdsa-sha2-nistp256、ecdsa-sha2-nistp384 、ecdsa-sha2-nistp521、ssh-ed25519-cert-v01 @ openssh.com、ssh-rsa-cert-v01 @ openssh.com、ssh-ed25519、rsa-sha2-512、rsa-sha2-256、ssh-rsa \ r \ ndebug 2:暗号ctos:chacha20-poly1305 @ openssh.com、aes128-ctr、aes192-ctr、aes256-ctr、aes128-gcm @ openssh.com、aes256-gcm @ openssh.com、aes128-cbc、aes192-cbc、aes256 -cbc、3des-cbc \ r \ ndebug2:ciphers stoc:chacha20-poly1305 @ openssh.com、aes128-ctr、aes192-ctr、aes256-ctr、aes128-gcm @ openssh.com、aes256-gcm @ openssh.com、 aes128-cbc、aes192-cbc、aes256-cbc、3des-cbc \ r \ ndebug2:MACs ctos:umac-64-etm @ openssh.com、umac-128-etm @ openssh.com、hmac-sha2-256-etm @ openssh.com、hmac-sha2-512-etm @ openssh.com、hmac-sha1-etm @ openssh.com、umac-64 @ openssh.com、umac-128 @ openssh.com、hmac-sha2-256、hmac -sha2-512、hmac-sha1 \ r \ ndebug2:MACs stoc:umac-64-etm @ openssh.com、umac-128-etm @ openssh.com、hmac-sha2-256-etm @ openssh.com、hmac- sha2-512-etm @ openssh.com、hmac-sha1-etm @ openssh.com、umac-64 @ openssh.com、umac-128 @ openssh.com、hmac-sha2-256、hmac-sha2-512、hmac- sha1 \ r \ ndebug2:圧縮ctos:zlib @ openssh.com、zlib、none \ r \ ndebug2:圧縮stoc:zlib @ openssh.com、zlib、none \ r \ ndebug2:言語ctos:\ r \ ndebug2:言語stoc :\ r \ ndebug2:最初 _kex_follows 0 \ r \ ndebug2:予約済み0 \ r \ ndebug2:ピアサーバーKEXINIT提案\ r \ ndebug2:KEXアルゴリズム:curve25519-sha256 @ libssh.org、ecdh-sha2-nistp256、ecdh-sha2-nistp384、ecdh-sha2- nistp521、diffie-hellman-group-exchange-sha256、diffie-hellman-group14-sha1 \ r \ ndebug2:ホストキーアルゴリズム:ssh-rsa、rsa-sha2-512、rsa-sha2-256、ecdsa-sha2-nistp256、 ssh-ed25519 \ r \ ndebug2:暗号ctos:chacha20-poly1305 @ openssh.com、aes128-ctr、aes192-ctr、aes256-ctr、aes128-gcm @ openssh.com、aes256-gcm @ openssh.com \ r \ ndebug2 :ciphers stoc:chacha20-poly1305 @ openssh.com、aes128-ctr、aes192-ctr、aes256-ctr、aes128-gcm @ openssh.com、aes256-gcm @ openssh.com \ r \ ndebug2:MACs ctos:umac-64 -etm @ openssh.com、umac-128-etm @ openssh.com、hmac-sha2-256-etm @ openssh.com、hmac-sha2-512-etm @ openssh.com、hmac-sha1-etm @ openssh.com 、umac-64 @ openssh.com、umac-128 @ openssh.com、hmac-sha2-256、hmac-sha2-512、hmac-sha1 \ r \ ndebug2:MACs stoc:[email protected]、 umac-128-etm @ openssh.com、hmac-sha2-256-etm @ openssh.com、hmac-sha2-512-etm @ openssh.com、hmac-sha1- etm @ openssh.com、umac-64 @ openssh.com、umac-128 @ openssh.com、hmac-sha2-256、hmac-sha2-512、hmac-sha1 \ r \ ndebug2:圧縮ctos:none、zlib @ openssh .com \ r \ ndebug2:圧縮stoc:なし、zlib @ openssh.com \ r \ ndebug2:言語ctos:\ r \ ndebug2:言語stoc:\ r \ ndebug2:first_kex_follows 0 \ r \ ndebug2:予約済み0 \ r \ ndebug1:kex:アルゴリズム:[email protected] \ r \ ndebug1:kex:ホストキーアルゴリズム:ecdsa-sha2-nistp256 \ r \ ndebug1:kex:サーバー->クライアント暗号:[email protected] MAC :圧縮:[email protected] \ r \ ndebug1:kex:クライアント->サーバー暗号:[email protected] MAC:圧縮:[email protected] \ r \ ndebug3:パケットの送信:タイプ30 \ r \ ndebug1:SSH2_MSG_KEX_ECDH_REPLYを期待\ r \ ndebug3:パケットの受信:タイプ31 \ r \ ndebug1:サーバーホストキー:ecdsa-sha2-nistp256 SHA256: JDiSsUdyRJfRGvtqAURzMtKu / Ghp0adBt / l9VbvgDfg \ r \ ndebug3:hostkeys_foreach:読み取りファイル\ "/root/.ssh/known_hosts \" \ r \ ndebug3:record_hostkey:ファイル/root/.ssh/known_hostsでキータイプECDSAが見つかりましたndebug3:load_hostkeys:10.0.3.36から1つのキーをロードしました\ r \ ndebug1:ホスト「10.0.3.36」は既知であり、ECDSAホストキーと一致します。\ r \ ndebug1:/root/.ssh/known_hosts:1 \ rでキーが見つかりました\ ndebug3:パケットの送信:タイプ21 \ r \ ndebug2:set_newkeys:モード1 \ r \ ndebug1:134217728ブロック後にキーを再生成\ r \ ndebug1:SSH2_MSG_NEWKEYSが送信されました\ r \ ndebug1:SSH2_MSG_NEWKEYSを期待しています\ r \ ndebug3:パケットの受信:タイプ21 \ r \ ndebug2:set_newkeys:モード0 \ r \ ndebug1:134217728ブロック後にキーを再生成します\ r \ ndebug1:SSH2_MSG_NEWKEYSを受信しました\ r \ ndebug2:キー:/root/.ssh/id_ecdsa(0x55cbdc34d840)、エージェント\ r \ ndebug2:キー:/root/.ssh/id_rsa(0x55cbdc33fc30)\ r \ ndebug 2:キー:/root/.ssh/id_dsa((nil))\ r \ ndebug2:キー:/root/.ssh/id_ed25519((nil))\ r \ ndebug3:パケットの送信:タイプ5 \ r \ ndebug3:パケットの受信:タイプ7 \ r \ ndebug1:SSH2_MSG_EXT_INFO受信\ r \ ndebug1:kex_input_ext_info:server-sig-algs =\ r \ ndebug3:受信パケット:タイプ6 \ r \ ndebug2:service_accept:ssh-userauth \ r \ ndebug1:SSH2_MSG_SERVICE_ACCEPT受信\ r \ ndebug3:送信パケット:タイプ50 \ r \ ndebug3:受信パケット:タイプ51 \ r \ ndebug1:続行できる認証:publickey、password \ r \ ndebug3:最初からやり直し、別のリストを渡しましたpublickey、password \ r \ ndebug3:優先gssapi-with-mic、gssapi-keyex、hostbased、publickey \ r \ ndebug3:authmethod_lookup publickey \ r \ ndebug3:引き続き優先:、gssapi-keyex、hostbased、publickey \ r \ ndebug3:authmethod_is_enabled publickey \ r \ ndebug1:次の認証方法:publickey \ r \ ndebug1:ECDSA公開鍵の提供:/root/.ssh/ id_ecdsa \ r \ ndebug3:send_pubkey_test \ r \ ndebug3:パケットの送信:タイプ50 \ r \ ndebug2:公開鍵パケットを送信し、応答を待ちます\ r \ ndebug3:パケットの受信:タイプ51 \ r \ ndebug1:続行できる認証:publickey、password \ r \ ndebug1:RSA公開鍵の提供:/root/.ssh/id_rsa \ r \ ndebug3:send_pubkey_test \ r \ ndebug3:パケットの送信:タイプ50 \ r \ ndebug2:公開鍵を送信しましたパケット、応答を待つ\ r \ ndebug3:パケットを受信:タイプ51 \ r \ ndebug1:続行できる認証:publickey、password \ r \ ndebug1:秘密鍵を試行しています:/root/.ssh/id_dsa \ r \ ndebug3:いいえそのようなID:/root/.ssh/id_dsa:そのようなファイルまたはディレクトリはありません\ r \ ndebug1:秘密鍵を試しています:/root/.ssh/id_ed25519 \ r \ ndebug3:そのようなIDはありません:/root/.ssh/id_ed25519:いいえそのようなファイルまたはディレクトリ\ r \ ndebug2:パケットを送信しませんでした。メソッドを無効にします\ r \ ndebug1:試行する認証メソッドはこれ以上ありません。\ r \ nアクセスが拒否されました(公開鍵、パスワード)。\ r \ n "、
「到達不能」:true
}
root @ ip-172-31-31-140:〜/ .ssh#

同じ問題が発生しました。ansibleは現在のユーザー名を使用して接続しようとします。そのため、私の方法はユーザー名を上書きすることでした。たとえば、次のようになります。
ansible all -m ping -u ec2-user

'ansible all -m ping'の実行中に2つのエラーが発生し、このスレッドでt-shootに遭遇しました。 これを理解するのに役立ったので、みんなの意見に感謝したいと思います。

:ERROR-1:
このメッセージを修正する手順: "msg": "ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey、password)。\ r \ n"
1)/ etc / ansible / hostsにある修正構成ファイルを変更して、適切なユーザー名「ubuntu」を含めました
2) '-private-key = / Users / my-user / .ssh / my-key.pem'の引数を渡したので、コマンドは次のようになりました。
ansible all -m ping --private-key = / Users / my-user / .ssh / my-key.pem
このガイドは、引数としてキーを渡す方法について教えてくれました。
https://ansible-tips-and-tricks.readthedocs.io/en/latest/ansible/commands/

:エラー2:
"module_stdout": "/ bin / sh:1:/ usr / bin / python:見つかりません\ r \ n"、
修正するには、 'sudo apt-getupdate;を実行しました。 sudo apt-get install python 'リモートホストに。 ec2インスタンスを使用しています。 ちなみに、起動スクリプトの一部としてインストールコマンドを実行すると、2番目の問題の解決に役立ちます。

乾杯!

Ubuntu16.04サーバーにPythonがないようです。 すべてのリモートホストにインストールしたところ、問題が修正されました。
sudo apt-get install python-minimal -y

SSHは端末には接続しますが、vstsやansibleには接続しません。誰かが私を助けてくれますか?

SSH接続を* @ 10.130.2.142:22に設定しようとしています
2018-04-04T21:56:46.6533908Z
2018-04-04T21:56:46.6549162Z PLAY [すべて] * * * * * * * * * * * * * * * * * * * * *
2018-04-04T21:56:46.6555625Z
2018-04-04T21:56:46.6603308Z
2018-04-04T21:56:46.6616154Z TASK [ディレクトリの作成] * * * * * * * * * * * * * * * *
2018-04-04T21:56:46.6622522Z
2018-04-04T21:56:46.8874071Zが失敗しました:[10.130.2.206](item = / home / * / myagent /)=> {"item": "/ home / * / myagent /"、 "msg": " ssh経由でホストに接続できませんでした:アクセスが拒否されました(公開キー)。\ r \ n "、"到達不能 ":true}
2018-04-04T21:56:46.8880968Z
2018-04-04T21:56:47.0341093Zが失敗しました:[10.130.2.206](item = / home / * / mywork /)=> {"item": "/ home / * / mywork /"、 "msg": " ssh経由でホストに接続できませんでした:アクセスが拒否されました(公開キー)。\ r \ n "、"到達不能 ":true}
2018-04-04T21:56:47.0349137Z
2018-04-04T21:56:47.0363780Z致命的:[10.130.2.206]:到達不能! => {"changed":false、 "msg": "すべてのアイテムが完了しました"、 "results":[{"_ ansible_ignore_errors":null、 "_ ansible_item_result":true、 "item": "/ home / * / myagent /" 、 "msg": "ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey)。\ r \ n"、 "unreachable":true}、{"_ ansible_ignore_errors":null、 "_ansible_item_result":true、 "item" : "/ home / * / mywork /"、 "msg": "ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey)。\ r \ n"、 "unreachable":true}]}
2018-04-04T21:56:47.0371817Z
2018-04-04T21:56:47.0387681Z再試行するには、次を使用します:-limit @ / tmp / Infrastructure / Agent_config.retry
2018-04-04T21:56:47.0397434Z
2018-04-04T21:56:47.0403265Z
2018-04-04T21:56:47.0415230Z PLAY RECAP * * * * * * * * * * * * * * * * * * * * *
2018-04-04T21:56:47.0421749Z
2018-04-04T21:56:47.0434107Z 10.130.2.206:ok = 0変更= 0到達不能= 1失敗= 0
2018-04-04T21:56:47.0440861Z
2018-04-04T21:56:47.0446720Z
2018-04-04T21:56:47.0452765Z
2018-04-04T21:56:47.0850279Z ## [エラー]コマンドansible-playbook-i "10.130.2.206、" /tmp/Infrax/Agent_config.yaml -b --become-user *コード4で終了しました。
2018-04-04T21:56:47.0948275Z ## [セクション]終了:プレイブックを実行する

これをヒットしたとき、私はOSXでAnsibleを使用して、pem証明書を使用してawsボックスに接続していました。 〜/ .ssh / configファイルがありませんでした。 作成してこれ以上追加しないと、次のようになります。

ホスト *
IdentityFile〜 / .ssh / id_rsa
AddKeysToAgentはい

それから私は魔法のようにプレイブックを実行することができました。

コントロールマシンからノードにファイルをコピーしようとすると、以下のエラーが発生します。

コマンド:sudo ansible dbservers -m copy -a "src = / etc / ansible / Taha dest = / etc / Taha"
エラー:
52.186.71.70 | 到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey、gssapi-keyex、gssapi-with-mic、password、keyboard-interactive)。\ r \ n"、
「到達不能」:true
}

上記のすべての手順を試しましたが、まだ成功しませんでした。

インベントリファイルとsshキーをユーザー名で渡してみてください。 ノードのインベントリにユーザーが定義されていないので、コマンドを使用して渡すと、常に機能します。 したがって、コマンドは次のようになります-

sudo ansible dbservers -m -i Inventory / Inventory-file --user = ubuntu --private-key = "private-key.pem" copy -a "src = / etc / ansible / Taha dest = / etc / Taha"

助けてくれてありがとうLokesh ...

私はansibleを初めて使用するので、pemファイルをコントロールサーバーのどこに保存できるか知りたいだけです。 インベントリファイルを変更する必要がありますか?

tこんにちはみんな、
私も同じ問題を抱えていました。
私のdevopsユーザーはすべてのサーバーにSSHで接続できましたが、(mysuerを使用して)実行しようとすると、ansibleコマンドで常にエラーが発生しました...到達不能です! ..。
「mysuer」sshserverDestiny(インベントリファイルにあるサーバー)を使用して、fqdnを使用する場合はFQDNに対してsshを作成する必要があることに注意してください。
例:
猫の在庫
server1

[ myuser @workstation ansible-deploy-cr] ssh-keygen
[ myuser @workstation ansible-deploy-cr] ssh-copy-id -i devops @ server1
テスト..
[ myuser @workstation ansible-deploy-cr] ssh'devops @ server1

これがお役に立てば幸いです。
もしそうなら、いいねをあげてください👍
ありがとう、
MBrito

10.20.2.42
ansibleclient.com

[root @ ansibleserver〜 ] #ansible all -m ping
10.20.2.42 | 到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey、gssapi-keyex、gssapi-with-mic、password)。\ r \ n"、
「到達不能」:true
}
ansibleclient.com | 到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey、password)。\ r \ n"、
「到達不能」:true
}
[ root @ ansibleserver〜 ]#

この問題について私を助けてください..私たちはsshキーを作成する必要があると思いますステップバイステップのプロセスを作成する方法私は専門家ではありません

親切に助けて

これは、サーバーにsshキーの生成を追加し、それをクライアントにコピーすることで修正されます。

コマンド:

$ ssh-keygen -t rsa

Enterキーを押します

$ cd root /
$ la -la

id_rsa.pubを宛先VMにコピーします
$ ssh-copy-id宛先VM

ssh-copy-id -i user @ localhost
ssh-copy-id -i user @ servers_in_inventory

うまくいくようです

このURLは、このエラーでGoogleが最もヒットしたURLであるため、この「問題」は解決されていますが、当面の間、人々はこれをヒットし続けます。 python3ansible 2.5 (どちらも、virutualenvのPIPバージョン)、およびOSX HighSierraで修正した方法は次のとおりです。
私のシナリオについて、私の「修正」を報告します。 ランニング:
$ python3 $(これはansible)localhost -m ping -vvvv

このエラーが発生します。 -vvvvは、それがキー/認証の失敗であることを明らかにします。 すごい。 [email protected]を実行するだけで、Ansibleをこれから分離できますが、私にとっては失敗しました(SSHキーを使用したログインの失敗は失敗だと考えています)。

簡単な修正: at ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

私も同じ問題を抱えていて、自分で解決策を見つけました。私に何が起こっているのかをお話しします。
私は同じエラーを受け取り、hostsファイルを持っていたのと同じproyectフォルダーでそれを解決しました。何らかの理由でエラーが発生したので、rm -rhostsだけで解決しました。
あなたが私が得たのと同じ問題を抱えているなら、私はあなたにさらします。

ハッピークリスマスX)、xoxo。

インベントリファイルを編集するまで同じ問題が発生しました
[testserver]
<target_ip> ansible_user=<target_domain_name> ansible_ssh_pass=<target_pass>
次に、テストします。
ansible testserver -m ping

ubuntu @ ip-172-31-1-85 :/ etc / ansible $ sudo ansible-playbook tomserver.yml

PLAY [ウェブサーバー] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **

TASK [事実の収集] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
致命的:[54.153.119.230]:到達不能! => {"changed":false、 "msg": "ssh経由でホストに接続できませんでした:そのようなIDはありません:/root/UbuntuAnsible.pem:そのようなファイルまたはディレクトリはありません\ r \ nアクセスが拒否されました(公開キー)。\ r \ n "、"到達不能 ":true}
再試行するには、次を使用します:-limit @ / etc / ansible / tomserver.retry

助けてください

単に接続しようとしていますか? ホストファイルはどのように見えますか?

2018年9月12日(水曜日)には、FALCON-SJSU [email protected]
書きました:

致命的:[54.153.119.230]:到達不能! => {"変更":false、 "msg": "失敗
ssh経由でホストに接続するには:そのようなIDはありません:/root/UbuntuAnsible.pem:
そのようなファイルまたはディレクトリはありません\ r \ nアクセスが拒否されました(公開キー)。\ r \ n "、
「到達不能」:true}
再試行するには、次を使用します:-limit @ / etc / ansible / tomserver.retry

助けてください


コメントしたのでこれを受け取っています。
このメールに直接返信し、GitHubで表示してください
https://github.com/ansible/ansible/issues/19584#issuecomment-420827308
またはスレッドをミュートします
https://github.com/notifications/unsubscribe-auth/An-8H0G3NUSkpFXpcm2hkAXXGco3eMmyks5uaZO0gaJpZM4LSWpz

私は解決策を見つけました。
私のオペレーティングシステムはMacOSで、「remote_user = root」の行の「ansible.cfg」を変更すると問題は解決しました。

うん! 私は同じことをしなければなりませんでした! 解決してよかった!

4:09 ZhangZhongyuanで火、2018年9月18日には[email protected]
書きました:

私は解決策を見つけました。
私のオペレーティングシステムはMacOSで、「ansible.cfg」を変更します。
行 'remote_user = root'、問題は解決されました。


コメントしたのでこれを受け取っています。
このメールに直接返信し、GitHubで表示してください
https://github.com/ansible/ansible/issues/19584#issuecomment-422297005
またはスレッドをミュートします
https://github.com/notifications/unsubscribe-auth/An-8H0zGJ4zE4mKmaMtXDAtInZNDlrW4ks5ucKpCgaJpZM4LSWpz

次のフラグを使用してプレイブックを実行しました。

ansible-playbook playbook.yml--ask-pass-これは役に立ちました。

ホストでは、ansibleuser = "user" ansiblepass = "pass" rightを実行することもできます
ターゲットのIPの横。 これにより、プレイブックを何もせずに実行できます
追加のパスワードプロンプト。

火、2018年10月2日には11:15でjluntnscc [email protected]書きました:

次のフラグを使用してプレイブックを実行しました。

ansible-playbook playbook.yml--ask-pass-これは役に立ちました。


コメントしたのでこれを受け取っています。
このメールに直接返信し、GitHubで表示してください
https://github.com/ansible/ansible/issues/19584#issuecomment-426312089
またはスレッドをミュートします
https://github.com/notifications/unsubscribe-auth/An-8HzRVj8-BqcUiQywgQYKIVbcr4yzdks5ug4MEgaJpZM4LSWpz

これを試して

すべてのサーバー-サーバーとクライアントの両方のユーザー名が同じ場合に機能します(パスワードなし)

ansible all -m ping

すべてのサーバー-「raj」は管理対象ノードのユーザーです(パスワードなし)

ansible all -u raj -m ping

また

デモサーバーグループのみ-「raj」は管理対象ノードのユーザーです(パスワードなし)

ansibleデモサーバー-uraj -m ping

また

パスワード認証を使用する場合

ansible -m ping all -u raj --ask-pass

または、このリンクをたどって詳細を確認できます
https://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/install-ansible-automation-tool-for-it-management-on-centos-7-ubuntu-14-04-fedora- 22-part-1.html

私にとってうまくいったのは、sshキーへのパスを持つようにhostsファイルを更新することでした。

[webserver]
IP_ADDRESS ansible_user=ubuntu ansible_connection=ssh ansible_private_key_file=~/.ssh/key.pem

素晴らしい解決策。 これにより、複数のターゲットが処理されます。

16:02時月、2018年10月29日にはfhackenb [email protected]書きました:

私にとってうまくいったのは、sshへのパスを持つようにhostsファイルを更新することでした
鍵:

[ウェブサーバー]
IP_ADDRESS ansible_user = ubuntu ansible_connection = ssh ansible_private_key_file =〜/ .ssh / key.pem


コメントしたのでこれを受け取っています。
このメールに直接返信し、GitHubで表示してください
https://github.com/ansible/ansible/issues/19584#issuecomment-434057611
またはスレッドをミュートします
https://github.com/notifications/unsubscribe-auth/An-8HzLY4PQVaWdPDOH0bHGnh9xpzmDWks5up17AgaJpZM4LSWpz

@ riteshpuj2013ソリューションの後で

ansible-playbook test.yml --ask-pass

この問題が発生しました。進行方法がわかりません

[email protected] | 到達不能! => {
「変更された」:false、
"msg": "認証またはアクセス許可の失敗。場合によっては、認証できて、ターゲットディレクトリに対するアクセス許可がなかった可能性があります。ansible.cfgのリモートtmpパスを\" / tmpをルートとするパスに変更することを検討してください。 \ "。失敗したコマンドは次のとおりです:(umask 77 && mkdir -p \" echo /tmp/.ansible/tmp/ansible-tmp-1543139945.24-52208136278646 \ "&& echo ansible-tmp-1543139945.24-52208136278646 = \" echo /tmp/.ansible/tmp/ansible-tmp-1543139945.24-52208136278646 \ ")、結果1で終了しました"、
「到達不能」:true
}

ansibleでプレイブックを実行できますが、ansibleタワーで同じプレイブックを実行しているときにエラーが発生します


<192.168.0.17>ユーザーのSSH接続を確立する:admin
<192.168.0.17> SSH:EXEC ssh -C -o ControlMaster = auto -o ControlPersist = 60s -o StrictHostKeyChecking = no -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic、gssapi-keyex、hostbased、publickey -o PasswordAuthentication = no -o User = admin -o ConnectTimeout = 10 -o ControlPath = / tmp / awx_86_9cdeKb / cp / 86796477d7 192.168.0.17 '/ bin / sh -c' "'"' echo〜admin && sleep 0 '"'" ''
<192.168.0.17>(255、 ''、 "警告:既知のホストのリストに「192.168.0.17」(ECDSA)が恒久的に追加されました。\ r \ n許可が拒否されました(publickey、gssapi-keyex、gssapi-with-mic、password )。\ r \ n ")
致命的:[192.168.0.17]:到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでした:警告:既知のホストのリストに「192.168.0.17」(ECDSA)が恒久的に追加されました。\ r \ n許可が拒否されました(publickey、gssapi-keyex、gssapi-with-mic 、password)。\ r \ n "、「到達不能」:true
}

この問題が発生しました。解決策を教えてください

ubuntu @master :〜$ ansible-playbook playbook2.yml -b PLAY [172.31.42.20] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * TASK [事実の収集] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
致命的:[172.31.42.20]:到達不能! => {"changed":false、 "msg": "ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey、password)。\ r \ n"、 "unreachable":true}
再試行するには、次を使用します。--limit @ / home / ubuntu / playbook2.retry PLAY RECAP * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

172.31.42.20:ok = 0変更= 0到達不能= 1失敗= 0

この問題が発生しました。解決策を教えてください

ubuntu @ master :〜$ ansible-playbook playbook2.yml -b PLAY [172.31.42.20] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * TASK [事実の収集] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

致命的:[172.31.42.20]:到達不能! => {"changed":false、 "msg": "ssh経由でホストに接続できませんでした:アクセスが拒否されました(publickey、password)。\ r \ n"、 "unreachable":true}
再試行するには、次を使用します。--limit @ / home / ubuntu / playbook2.retry PLAY RECAP * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
172.31.42.20:ok = 0変更= 0到達不能= 1失敗= 0

私たちが持っている2つの解決策:-

password less auth (you can refer google how to generate rsa key )
add ask_pass=true in ancible.cfg file. (This will ask password when you run ansible)

ホストマシンへのSSH接続をセットアップしてテストしてください。
完了したら、/ etc / ansible / hostsファイルで適切なホストIPを指定します。
次に、ansibleとゲストマシン間の安全な接続をテストするには、次のコマンドを使用します。
-> ansible -i hosts -u vagrant --ask-pass -m ping all
hosts-> hostsファイル(適切なゲストIPを指定)
-u vagrant-> vagrantは私のゲストマシンのユーザー名です
--ask-pass->ゲストm / cに接続するためのSSHパスワードを入力できます。
注:-ask-passを使用しない場合、エラーがスローされます。

それが役立つならありがとう:)

/ etc / ansible / hostsが間違っている可能性があります

私はansibleを初めて使用しますが、誰かが私を助けてくれますか

34.201.109.32 | 到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでしたpublickey )。\ r \ n"、
「到達不能」:true
}

ターゲットマシンのパスワードをhostsファイルに含めるようにしてください。
通常、既存のssh接続が必要です。
ホストとローカルマシンのRSAキーを生成します。 sshを試してみてください
その後、ホストはansibleを再度実行します。

2019年1月20日日曜日11:22 AM Venkata Bhanusree Vadlamudi <
[email protected]>は次のように書いています:

私はansibleを初めて使用しますが、誰かが私を助けてくれますか

34.201.109.32 | 到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでした
許可が拒否されました(公開キー)。\ r \ n "、
「到達不能」:true
}


コメントしたのでこれを受け取っています。
このメールに直接返信し、GitHubで表示してください
https://github.com/ansible/ansible/issues/19584#issuecomment-455880089
またはスレッドをミュートします
https://github.com/notifications/unsubscribe-auth/An-8H0nPfSdUELQxzoQAvvHHlsau7uyBks5vFJfOgaJpZM4LSWpz

ローカルターミナルからsshコマンドを使用すると、ec2インスタンスに接続できます。 ただし、ansibleスクリプトを実行すると、エラーが発生します。

34.201.109.32 | 到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでしたpublickey )。\ r \ n"、
「到達不能」:true
}

AWS ec2インスタンスでは、AWSを介して公開鍵を生成する必要があります。
ダウンロードして、sshセッションでそのキーを指定します。 のチュートリアルがあります
この手順はオンラインです。

2019年1月20日日曜日午後4時48分VenkataBhanusree Vadlamudi <
[email protected]>は次のように書いています:

ローカル端末からsshコマンドを使用すると、接続できません
ec2インスタンスに。 ただし、ansibleスクリプトを実行すると、エラーが発生します。

34.201.109.32 | 到達不能! => {
「変更された」:false、
"msg": "ssh経由でホストに接続できませんでした
許可が拒否されました(公開キー)。\ r \ n "、
「到達不能」:true
}


コメントしたのでこれを受け取っています。
このメールに直接返信し、GitHubで表示してください
https://github.com/ansible/ansible/issues/19584#issuecomment-455905472
またはスレッドをミュートします
https://github.com/notifications/unsubscribe-auth/An-8Hya_SkLrHT-HLYEOPEE2QXsSuDOJks5vFOQOgaJpZM4LSWpz

tこんにちはみんな、
私も同じ問題を抱えていました。
私のdevopsユーザーはすべてのサーバーにSSHで接続できましたが、(mysuerを使用して)実行しようとすると、ansibleコマンドで常にエラーが発生しました...到達不能です! ..。
「mysuer」sshserverDestiny(インベントリファイルにあるサーバー)を使用して、fqdnを使用する場合はFQDNに対してsshを作成する必要があることに注意してください。
例:
猫の在庫
server1

[ myuser @workstation ansible-deploy-cr] ssh-keygen
[ myuser @workstation ansible-deploy-cr] ssh-copy-id -i devops @ server1
テスト..
[ myuser @workstation ansible-deploy-cr] ssh'devops @ server1

これがお役に立てば幸いです。
もしそうなら、いいねをあげてください👍
ありがとう、
MBrito

これにより、プライベートVPC上のAWSでの問題が修正されました。すべてのサーバーに内部fqdnが必要です。

やあみんな、
私はローカルホストで同じ問題に直面していて、「$ sshlocalhost」がパスワードを要求していることに気づきました。 localhostの「user」の公開鍵をauthorized_keyに移動することで解決しました。

ssh-copy-id -i〜 / .ssh / id_rsa.pub test @ localhost

authorized_keyファイルに必要なキーがあるかどうかを確認するだけです

testはユーザー名です

うわー.....コメントを読んだ。 問題がまだ存在しているとは信じられません。 私は最新のansibleを使用しています。 これはオープンソースを使うことの苦痛の一つだと思います。

vagrant<strong i="6">@mgmt</strong>:~$ ansible lb -u vagrant -m ping -vvv
ansible 2.7.8
  config file = /home/vagrant/ansible.cfg
  configured module search path = [u'/home/vagrant/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0 20160609]
Using /home/vagrant/ansible.cfg as config file
[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it can also be a list of hosts, a directory or a list of paths , use [defaults] inventory=/path/to/file|dir 
instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
/home/vagrant/inventory.ini did not meet host_list requirements, check plugin documentation if this is unexpected
/home/vagrant/inventory.ini did not meet script requirements, check plugin documentation if this is unexpected
/home/vagrant/inventory.ini did not meet yaml requirements, check plugin documentation if this is unexpected
Parsed /home/vagrant/inventory.ini inventory source with ini plugin
 [WARNING]: Found both group and host with same name: lb

META: ran handlers
<lb> ESTABLISH SSH CONNECTION FOR USER: vagrant
<lb> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/2302ac11ec lb '/bin/sh -c '"'"'echo ~vagrant && sleep 0'"'"''
<lb> (255, '', 'Permission denied (publickey).\r\n')
lb | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Permission denied (publickey).", 
    "unreachable": true
}

解決

さて、これが私のために働いたものです-
リモートマシンlbにログインしました。 〜/ .ssh / authorised_keysを編集し、ansibleマスターのid_rsa.pubキーを追加しました。 保存して終了しました。 lbでsshdをバウンスしました。

これは完璧な方法ではありませんが、最初のテストに取り掛かることができます。

編集1-また、リモートマシン(ansibleによって管理されるクライアント)にPythonがインストールされていることを確認する必要があります。

PS-ssh-copy-id -iのメソッドでさえ、同じ許可エラーが拒否されて失敗していました(publickey)

vagrant @ mgmt :〜$ ansible lb -m ping -vvv
ansible 2.7.8
設定ファイル= / home / vagrant / ansible.cfg
構成されたモジュール検索パス= [u '/ home / vagrant / .ansible / plugins / modules'、u '/ usr / share / ansible / plugins / modules']
ansiblepythonモジュールの場所= / usr / lib / python2.7 / dist-packages / ansible
実行可能ファイルの場所= / usr / bin / ansible
Pythonバージョン= 2.7.12(デフォルト、2018年11月12日、14:36:49)[GCC 5.4.0 20160609]
設定ファイルとして/home/vagrant/ansible.cfgを使用する
[非推奨の警告]:[デフォルト] hostfileオプション、ホストのリスト、ディレクトリ、またはパスのリストである可能性があるため、キーは誤解を招く可能性があります。[デフォルト] Inventory = / path / to / file | dirを使用してください
代わりは。 この機能はバージョン2.8で削除されます。 非推奨の警告は、ansible.cfgでdeprecation_warnings = Falseを設定することで無効にできます。
/home/vagrant/inventory.iniがhost_listの要件を満たしていませんでした。予期しない場合は、プラグインのドキュメントを確認してください
/home/vagrant/inventory.iniがスクリプト要件を満たしていませんでした。予期しない場合は、プラグインのドキュメントを確認してください
/home/vagrant/inventory.iniがyamlの要件を満たしていませんでした。予期しない場合は、プラグインのドキュメントを確認してください
iniプラグインを使用して/home/vagrant/inventory.iniインベントリソースを解析しました
[警告]:同じ名前のグループとホストの両方が見つかりました:lb

META:ハンドラーを実行しました
ユーザーのSSH接続を確立する:なし
SSH:EXEC ssh -C -o ControlMaster = auto -o ControlPersist = 60s -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic、gssapi-keyex、hostbased、publickey -o PasswordAuthentication = no -o ConnectTimeout = 10 -o ControlPath = / home / vagrant / .ansible / cp / e51df67eb4 lb '/ bin / sh -c' "'"' echo〜 && sleep 0 '"'" ''
(0、 '/ home / vagrant \ n'、 '')
ユーザーのSSH接続を確立する:なし
SSH:EXEC ssh -C -o ControlMaster = auto -o ControlPersist = 60s -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic、gssapi-keyex、hostbased、publickey -o PasswordAuthentication = no -o ConnectTimeout = 10 -o ControlPath = / home / vagrant / .ansible / cp / e51df67eb4 lb '/ bin / sh -c' "'"'(umask 77 && mkdir -p " echo /home/vagrant/.ansible/tmp/ansible-tmp-1552670816.4-42574892310286 " && echo ansible-tmp-1552670816.4-42574892310286 = " echo /home/vagrant/.ansible/tmp/ansible-tmp-1552670816.4-42574892310286 ")&& sleep 0 '"'" ''
(0、 'ansible-tmp-1552670816.4-42574892310286 = / home / vagrant / .ansible / tmp / ansible-tmp-1552670816.4-42574892310286 \ n'、 '')
モジュールファイル/usr/lib/python2.7/dist-packages/ansible/modules/system/ping.pyを使用する
PUT /home/vagrant/.ansible/tmp/ansible-local-2173_L8KXK/tmpXoK8R8 TO /home/vagrant/.ansible/tmp/ansible-tmp-1552670816.4-42574892310286/AnsiballZ_ping.py
SSH:EXEC sftp -b --- C -o ControlMaster = auto -o ControlPersist = 60s -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic、gssapi-keyex、hostbased、publickey -o PasswordAuthentication = no -o ConnectTimeout = 10 -o ControlPath = / home / vagrant / .ansible / cp / e51df67eb4 '[lb]'
(0、 'sftp> put /home/vagrant/.ansible/tmp/ansible-local-2173_L8KXK/tmpXoK8R8 /home/vagrant/.ansible/tmp/ansible-tmp-1552670816.4-42574892310286/AnsiballZ_ping.py \ n'、 ' ')
ユーザーのSSH接続を確立する:なし
SSH:EXEC ssh -C -o ControlMaster = auto -o ControlPersist = 60s -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic、gssapi-keyex、hostbased、publickey -o PasswordAuthentication = no -o ConnectTimeout = 10 -o ControlPath = / home / vagrant / .ansible / cp / e51df67eb4 lb '/ bin / sh -c' "'"' chmod u + x /home/vagrant/.ansible/tmp/ansible-tmp-1552670816.4-42574892310286/ / home /vagrant/.ansible/tmp/ansible-tmp-1552670816.4-42574892310286/AnsiballZ_ping.py && sleep 0 '"'" ''
(0、 ''、 '')
ユーザーのSSH接続を確立する:なし
SSH:EXEC ssh -C -o ControlMaster = auto -o ControlPersist = 60s -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic、gssapi-keyex、hostbased、publickey -o PasswordAuthentication = no -o ConnectTimeout = 10 -o ControlPath = / home / vagrant / .ansible / cp / e51df67eb4 -tt lb '/ bin / sh -c' "'"' / usr / bin / python /home/vagrant/.ansible/tmp/ansible-tmp-1552670816.4- 42574892310286 / AnsiballZ_ping.py && sleep 0 '"'" ''
(0、 '\ r \ n {"invocation":{"module_args":{"data": "pong"}}、 "ping": "pong"} \ r \ n'、 'lbへの共有接続が閉じられました。 \ r \ n ')
ユーザーのSSH接続を確立する:なし
SSH:EXEC ssh -C -o ControlMaster = auto -o ControlPersist = 60s -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic、gssapi-keyex、hostbased、publickey -o PasswordAuthentication = no -o ConnectTimeout = 10 -o ControlPath = / home / vagrant / .ansible / cp / e51df67eb4 lb '/ bin / sh -c' "'"' rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1552670816.4-42574892310286/> / dev / null 2>&1 && sleep 0 '"'" ''
(0、 ''、 '')
ポンド| 成功=> {
「変更された」:false、
「呼び出し」:{
"module_args":{
「データ」:「ポン」
}
}、
"卓球"
}

このページは役に立ちましたか?
0 / 5 - 0 評価