ssh - 即使在添加到 ssh-add 之后,Ansible 也总是要求输入 ssh 关键字
问题描述
我ssh-add
在初始化后添加了我的密钥$(ssh-agent)
原始 ssh 命令完全可以正常工作,只需密钥且无需密码
ssh -i key.pem ubuntu@someip
到目前为止一切顺利,问题是如果我运行 ansible playbook 在同一个终端运行,它要求输入密钥密码!并且不允许自动化它
TASK [deploy-all : Copy something to remote host] *******************
Wednesday 30 June 2021 18:04:56 +0200 (0:00:00.609) 0:00:03.063 ********
Enter passphrase for key 'key.pem':
它甚至多次询问密码......在同一个剧本执行期间。(我有一些任务委托给 localhost delegate_to:“{{ delegate_build_to_host }}”,所以当上下文切换到远程主机时似乎再次询问密码)
库存文件:
[webserver]
dockerall ansible_host=some.host.ip.xy ansible_user=ubuntu ansible_ssh_private_key_file=key.pem
Playbook 只是使用唯一的主机组网络服务器
---
- hosts: webserver
become: true
gather_facts: false
environment:
CI: "true"
vars:
working_user: root
- { role: deploy, tags: 'deploy' }
部署角色的第一项任务非常简单,我被要求输入密码:
roles/deploy/tasks/main.yaml
# identation is wrong but doesn't matter just copied for example
copy:
src: "{{ role_path }}/files/docker/"
dest: "{{ dc_path }}"
mode: preserve
// more tasks here some delegated to localhost
- name: "create tmp build directory in build host to contain all sort of tmp files that can be deleted after execution"
delegate_to: "localhost"
file:
path: "{{ tmp_build_path }}"
recurse: yes
state: directory
// again after this comment, copy tasks for remote host
关键文件权限:
stat -c "%a %n" key.pem
600 key.pem
解决方案
推荐阅读
- snowflake-cloud-data-platform - 雪花像另一个表一样创建表,但将所有列设置为可为空
- python - Python:如何同时执行 100 个进程?
- node.js - 安装带有 EACCES 符号链接错误的 expo-cli
- javascript - 运行存储在对象中的函数
- webgl - 将单个纹理的子集渲染到 WebGL 画布上的最快方法是什么?
- time - 如何在时间 x 后改变形状的颜色?
- ios - Xcode 应用程序
- latex - 如何不平衡乳胶中的书目列?
- c - 假设 realloc()ing 到较小的大小总是会成功,这是否安全?
- reactjs - Firebase 数据未保存到我的反应状态