具有多个 SSH 密钥对的 Ansible [英] Ansible with multiple SSH key pair
问题描述
我是 Ansible 的新手.我能够测试它并且它可以很好地满足我的测试要求.为了在管理节点和客户端节点之间建立连接,我使用了已经创建的 ssh 密钥对.如何使用具有不同 SSH 密钥对的另一个节点?作为参考,我正在考虑 3 个具有不同密钥对的 ec2-instance.
I am new to Ansible. I am able to test it and its working fine with my test requirment. For making connection between management node and the client node I am using already created ssh key pair. How can I use another node with different SSH key pair? For reference I am considering 3 ec2-instance with different key pairs.
推荐答案
好消息 - 在基本用例中,这相当容易.只需在您的 Ansible 库存 中使用 ansible_ssh_private_key_file
参数.
Good news- in a basic use case, this is fairly easy. Simply use the ansible_ssh_private_key_file
parameter in your Ansible inventory.
以下是从我的个人档案中窃取的一些示例:
Here are some examples purloined from my personal file:
$ cat hosts.ini
[server1]
54.1.2.3 ansible_ssh_private_key_file=~/.ssh/server1.pem
[testservers]
ec2-54-2-3-4.compute-1.amazonaws.com ansible_ssh_private_key_file=~/.ssh/aws-testserver.pem ansible_ssh_user=ubuntu
ec2-54-2-3-5.compute-1.amazonaws.com ansible_ssh_private_key_file=~/.ssh/aws-testserver.pem ansible_ssh_user=ubuntu
[piwall]
10.0.0.88 ansible_ssh_private_key_file=~/.ssh/raspberrypi.pem ansible_ssh_user=pi
这篇关于具有多个 SSH 密钥对的 Ansible的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!