Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ansible vault加密的私钥连接到远程主机不起作用_Ansible_Ssh Keys_Ansible Vault - Fatal编程技术网

使用ansible vault加密的私钥连接到远程主机不起作用

使用ansible vault加密的私钥连接到远程主机不起作用,ansible,ssh-keys,ansible-vault,Ansible,Ssh Keys,Ansible Vault,如果使用ansible命令模块,我可以使用ssh连接到远程服务器 e、 g 但是,由于这将存储在github中,因此我使用ansible vault对ssh私钥进行了加密。 使用vault解密密码(--ask vault pass)重新运行同一命令后,它将无法连接。这就好像加密/反加密不返回相同的ssh密钥一样。 我做错了什么?如果其他人遇到同样的问题,我传奇般的同事会找到解决办法 您需要先将加密的ssh私钥复制到另一个文件中进行解密,然后才能使用它,例如 - hosts: localhost

如果使用ansible命令模块,我可以使用ssh连接到远程服务器

e、 g

但是,由于这将存储在github中,因此我使用ansible vault对ssh私钥进行了加密。
使用vault解密密码(--ask vault pass)重新运行同一命令后,它将无法连接。这就好像加密/反加密不返回相同的ssh密钥一样。
我做错了什么?

如果其他人遇到同样的问题,我传奇般的同事会找到解决办法

您需要先将加密的ssh私钥复制到另一个文件中进行解密,然后才能使用它,例如

- hosts: localhost
  gather_facts: false
  vars:
    source_key: key
    dest_key: key2
  tasks:
  - name: Install ssh key
    copy:
      src: "{{ source_key }}"
      dest: "{{ dest_key }}"
      mode: 0600

  - name: scp over the cert and key to remote server
    command: ssh -i key2 ec2-user@1.1.1.1
- hosts: localhost
  gather_facts: false
  vars:
    source_key: key
    dest_key: key2
  tasks:
  - name: Install ssh key
    copy:
      src: "{{ source_key }}"
      dest: "{{ dest_key }}"
      mode: 0600

  - name: scp over the cert and key to remote server
    command: ssh -i key2 ec2-user@1.1.1.1