Ansible脚本ssh错误
Ansible script ssh error
我正在 openstack (linux 虚拟机) 中创建一个虚拟机并从 there.I 启动 ansible 脚本,我收到以下 ssh 错误。
---
- hosts: licproxy
user: my-user
sudo: yes
tasks:
- name: Install tinyproxy#
command: sudo apt-get install tinyproxy
- name: Update tinyproxy
command: sudo apt-get update
- name: Install bind9
shell: yes '' | sudo apt-get install bind9
尽管我可以直接从 openstack admin-keydev29
中的 linux 框中通过 ssh 连接到机器 10.32.1.40
PLAY [licproxy] ***********************************************************
GATHERING FACTS ***************************************************************
<10.32.1.40> ESTABLISH CONNECTION FOR USER: my-user
<10.32.1.40> REMOTE_MODULE setup
<10.32.1.40> EXEC ssh -C -tt -vvv -o StrictHostKeyChecking=no -o IdentityFile="/opt/apps/installer/tenant-dev29/ssh/admin-key-dev29" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=my-user -o ConnectTimeout=10 10.32.1.40 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1450797442.33-90087292637238 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1450797442.33-90087292637238 && echo $HOME/.ansible/tmp/ansible-tmp-1450797442.33-90087292637238'
EXEC previous known host file not found for 10.32.1.40
fatal: [10.32.1.40] => SSH Error: ssh: connect to host 10.32.1.40 port 22: Connection refused
while connecting to 10.32.1.40:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
TASK: [Install tinyproxy] *****************************************************
FATAL: no hosts matched or all hosts have already failed -- aborting
我从 known_host 条目和 运行 脚本中删除了它仍然向我显示相同的消息。
更新
我发现手动 ssh 正在运行 fine.but ansible 脚本出现 ssh 错误。
我使用 ssh 密钥登录到新创建的虚拟机并检查了 /var/log/auth.log file
Dec 30 13:00:33 licproxy-vm sshd[1184]: Server listening on :: port 22.
Dec 30 13:01:10 licproxy-vm sshd[1448]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Dec 30 13:01:10 licproxy-vm sshd[1448]: Connection closed by 192.168.0.106 [preauth]
Dec 30 13:01:32 licproxy-vm sshd[1450]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
虚拟机有sshd版本OpenSSH_6.6.1版本
我检查了 /etc/ssh 文件夹,我发现 ssh_host_ed25519_key 和 ssh_host_ed25519_key.pub 丢失了
我使用命令 ssh-keygen -A 创建了这些文件。
现在我想知道为什么 ssh 中缺少这些文件folder.Is这是一个错误吗?
问题是因为 ssh 端口 22.The 端口未启动。
我添加了以下 code.which 基本上等待 ssh 端口出现。
while ! nc -z $PROXY_SERVER_IP 22; do
sleep 10s
done
我正在 openstack (linux 虚拟机) 中创建一个虚拟机并从 there.I 启动 ansible 脚本,我收到以下 ssh 错误。
---
- hosts: licproxy
user: my-user
sudo: yes
tasks:
- name: Install tinyproxy#
command: sudo apt-get install tinyproxy
- name: Update tinyproxy
command: sudo apt-get update
- name: Install bind9
shell: yes '' | sudo apt-get install bind9
尽管我可以直接从 openstack admin-keydev29
中的 linux 框中通过 ssh 连接到机器 10.32.1.40 PLAY [licproxy] ***********************************************************
GATHERING FACTS ***************************************************************
<10.32.1.40> ESTABLISH CONNECTION FOR USER: my-user
<10.32.1.40> REMOTE_MODULE setup
<10.32.1.40> EXEC ssh -C -tt -vvv -o StrictHostKeyChecking=no -o IdentityFile="/opt/apps/installer/tenant-dev29/ssh/admin-key-dev29" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=my-user -o ConnectTimeout=10 10.32.1.40 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1450797442.33-90087292637238 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1450797442.33-90087292637238 && echo $HOME/.ansible/tmp/ansible-tmp-1450797442.33-90087292637238'
EXEC previous known host file not found for 10.32.1.40
fatal: [10.32.1.40] => SSH Error: ssh: connect to host 10.32.1.40 port 22: Connection refused
while connecting to 10.32.1.40:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
TASK: [Install tinyproxy] *****************************************************
FATAL: no hosts matched or all hosts have already failed -- aborting
我从 known_host 条目和 运行 脚本中删除了它仍然向我显示相同的消息。
更新
我发现手动 ssh 正在运行 fine.but ansible 脚本出现 ssh 错误。 我使用 ssh 密钥登录到新创建的虚拟机并检查了 /var/log/auth.log file
Dec 30 13:00:33 licproxy-vm sshd[1184]: Server listening on :: port 22.
Dec 30 13:01:10 licproxy-vm sshd[1448]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Dec 30 13:01:10 licproxy-vm sshd[1448]: Connection closed by 192.168.0.106 [preauth]
Dec 30 13:01:32 licproxy-vm sshd[1450]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
虚拟机有sshd版本OpenSSH_6.6.1版本 我检查了 /etc/ssh 文件夹,我发现 ssh_host_ed25519_key 和 ssh_host_ed25519_key.pub 丢失了
我使用命令 ssh-keygen -A 创建了这些文件。
现在我想知道为什么 ssh 中缺少这些文件folder.Is这是一个错误吗?
问题是因为 ssh 端口 22.The 端口未启动。 我添加了以下 code.which 基本上等待 ssh 端口出现。
while ! nc -z $PROXY_SERVER_IP 22; do
sleep 10s
done